Qual: Move independant external modules to the repository of modules.

This commit is contained in:
Laurent Destailleur 2009-10-20 16:17:58 +00:00
parent 9ab461819e
commit 74908715c3
494 changed files with 4 additions and 69450 deletions

View File

@ -80,6 +80,8 @@ For developers:
- Can use an alternate document_root directory to develop with
sources on two repositories.
- Removed useless code of old commercial module.
- Move some modules into the CVS modules repository dolibarrmod. This reduces
amount of code in main branch.
- Updated wiki documentation.
- Better W3C standard.
- Can add init data when enabling a module.

View File

@ -1,231 +0,0 @@
<?php
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/energie/EnergieCompteur.class.php
\ingroup energie
\brief Fichier des classes de compteur
\version $Revision$
*/
/**
\class Compteur
\brief Classe de gestion des compteurs
*/
class EnergieCompteur
{
var $db ;
var $id ;
var $user;
/** \brief Constructeur
*/
function EnergieCompteur($DB, $user)
{
global $langs;
$this->db = $DB;
$this->user = $user;
$this->energies[1] = $langs->trans("Electricity");
$this->energies[2] = $langs->trans("Water");
$this->energies[3] = $langs->trans("NaturalGaz");
$this->couleurs[1] = "gray";
$this->couleurs[2] = "blue";
$this->couleurs[3] = "yellow";
}
/**
* Lecture
*
*/
function fetch ($id)
{
$sql = "SELECT c.rowid, c.libelle, fk_energie";
$sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur as c";
$sql .= " WHERE c.rowid = ".$id;
$resql = $this->db->query($sql) ;
if ( $resql )
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->libelle = $obj->libelle;
$this->energie = $obj->fk_energie;
$this->db->free();
return 0;
}
else
{
dol_syslog("");
return -1;
}
}
/**
* Lecture
*
*/
function Create ($libelle, $energie)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."energie_compteur";
$sql .= " (libelle, datec, fk_user_author, fk_energie, note)";
$sql .= " VALUES (";
$sql .= "'".trim($libelle)."'";
$sql .= ",now()";
$sql .= ",'".$this->user->id."'";
$sql .= ",'".$energie."'";
$sql .= ",'');";
$resql = $this->db->query($sql) ;
if ( $resql )
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."energie_compteur");
return 0;
}
else
{
dol_syslog("EnergieCompteur::Create Erreur 1");
dol_syslog($this->db->error());
return -1;
}
}
/**
* Ajout d'une valeur relev<EFBFBD>e
*
*/
function AjoutReleve ($date_releve, $valeur)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."energie_compteur_releve";
$sql .= " (fk_compteur, date_releve, valeur, datec, fk_user_author)";
$sql .= " VALUES (";
$sql .= "'".$this->id."'";
$sql .= ",'".$this->db->idate($date_releve)."'";
$sql .= ",'".$valeur."'";
$sql .= ",now()";
$sql .= ",'".$this->user->id."');";
$resql = $this->db->query($sql) ;
if ( $resql )
{
return 0;
}
else
{
dol_syslog("EnergieCompteur::AjoutReleve Erreur 1");
dol_syslog($this->db->error());
return -1;
}
}
/**
* Suppression d'une valeur relev<EFBFBD>e
*
*/
function DeleteReleve ($rowid)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."energie_compteur_releve";
$sql .= " WHERE rowid = '".$rowid."';";
$resql = $this->db->query($sql) ;
if ( $resql )
{
return 0;
}
else
{
dol_syslog("EnergieCompteur::AjoutReleve Erreur 1");
dol_syslog($this->db->error());
return -1;
}
}
/**
* Ajout d'une valeur relev<EFBFBD>e
*
*/
function AddGroup ($groupe)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."energie_compteur_groupe";
$sql .= " (fk_energie_compteur, fk_energie_groupe)";
$sql .= " VALUES ('".$this->id."','".$groupe."');";
$resql = $this->db->query($sql);
if ( $resql )
{
return 0;
}
else
{
dol_syslog("EnergieCompteur::AddGroup Erreur 1");
dol_syslog($this->db->error());
return -1;
}
}
/**
*
*
*/
function GroupsAvailable ()
{
$this->groups_available = array();
$sql = "SELECT g.rowid, g.libelle";
$sql .= " FROM ".MAIN_DB_PREFIX."energie_groupe as g";
$resql = $this->db->query($sql) ;
if ( $resql )
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$this->groups_available[$obj->rowid] = $obj->libelle;
$i++;
}
$this->db->free();
return 0;
}
else
{
dol_syslog("");
return -1;
}
}
}
?>

View File

@ -1,95 +0,0 @@
<?php
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
class EnergieGroupe
{
var $db ;
var $user ;
/** \brief Constructeur
*/
function EnergieGroupe($DB, $user)
{
$this->db = $DB;
$this->user = $user;
}
/**
* Lecture
*
*/
function fetch ($id)
{
$sql = "SELECT c.rowid, c.libelle";
$sql .= " FROM ".MAIN_DB_PREFIX."energie_groupe as c";
$sql .= " WHERE c.rowid = ".$id;
$resql = $this->db->query($sql) ;
if ( $resql )
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->libelle = $obj->libelle;
$this->db->free();
return 0;
}
else
{
dol_syslog("EnergieGroupe::fetch Erreur");
return -1;
}
}
/**
* Creation
*
*/
function Create ($libelle)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."energie_groupe";
$sql .= " (libelle, datec, fk_user_author, note)";
$sql .= " VALUES (";
$sql .= "'".trim($libelle)."'";
$sql .= ",now()";
$sql .= ",'".$this->user->id."'";
$sql .= ",'".$libelle."');";
$resql = $this->db->query($sql) ;
if ( $resql )
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."energie_groupe");
return 0;
}
else
{
dol_syslog("EnergieGroupe::Create Erreur 1");
dol_syslog($this->db->error());
return -1;
}
}
}
?>

View File

@ -1,228 +0,0 @@
<?php
/* Copyright (C) 2005-2007 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/energie/compteur.php
* \ingroup energie
* \brief Fiche compteur
* \version $Revision$
*/
require("./pre.inc.php");
/*
* Actions
*/
if ($_POST["action"] == 'add')
{
$compteur = new EnergieCompteur($db, $user);
if ( $compteur->create($_POST["libelle"],$_POST["energie"]) == 0)
{
Header("Location: compteur.php?id=".$compteur->id);
}
else
{
Header("Location: compteur.php?action=create");
}
}
if ($_POST["action"] == 'addvalue')
{
if ($_POST["releve"] > 0)
{
$compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0)
{
$date = mktime(12,
0 ,
0,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]);
$compteur->AjoutReleve($date, $_POST["releve"]);
Header("Location: compteur.php?id=".$_GET["id"]);
}
}
}
/*
* Views
*/
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
/*********************************************************************
*
* Mode creation
*
************************************************************************/
if ($_GET["action"] == 'create')
{
$head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?action=create';
$head[0][1] = "Nouveau compteur";
$h++;
$a = 0;
dol_fiche_head($head, $a, $soc->nom);
$html = new Form($db);
$compteur = new EnergieCompteur($db, $user);
print '<form action="compteur.php" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<table class="border" width="100%">';
print "<tr $bc[$var]>";
print '<td>'.$langs->trans("Label").'</td>';
print '<td><input type="text" size="40" maxlength="255" name="libelle"></td></tr>';
print "<tr $bc[$var]>";
print '<td>Energie</td><td>';
print $html->select_array("energie", $compteur->energies);
print '</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Add").'" class="button"></td></tr>';
print "</table></form>";
print '</div>';
}
else
/* *************************************************************************** */
/* */
/* Mode vue */
/* */
/* *************************************************************************** */
{
if ($_GET["id"] > 0)
{
$compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0)
{
$head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id;
$head[0][1] = $langs->trans("Compteur");
$h++;
$a = 0;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Graph");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Releves");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Groups");
$h++;
dol_fiche_head($head, $a, $soc->nom);
print '<table class="border" width="100%">';
print "<tr><td>".$langs->trans("Compteur")."</td>";
print '<td width="50%">';
print $compteur->libelle;
print "</td></tr>";
print "</table><br>";
$html = new Form($db);
print '<form name="addvalue" action="compteur.php?id='.$compteur->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addvalue">';
print '<table class="border" width="100%">';
$var=!$var;
print "<tr $bc[$var]>";
print '<td>Date</td><td>';
print $html->select_date('','','','','',"addvalue");
print '</td><td>Valeur relevee</td>';
print '<td align="center"><input type="text" size="11" maxlength="10" name="releve"></td>';
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
print "</table></form><br>";
print '<table class="noborder" width="100%">';
print '<tr><td><a href="compteur_graph.php?id='.$compteur->id.'">';
$file = "all.".$compteur->id.".png";
print '<img border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</a></td></tr></table>';
print '</div>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Releve").'</td></tr>';
$sql = "SELECT ".$db->pdate("date_releve")." as date_releve, valeur";
$sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur_releve as ecr";
$sql .= " WHERE ecr.fk_compteur = '".$compteur->id."'";
$sql .= " ORDER BY ecr.date_releve DESC LIMIT 5";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]><td>";
print dol_print_date($obj->date_releve,'%a %d %B %Y');
print '</td><td>'.$obj->valeur.'</td>';
$i++;
}
}
print '</table>';
print "<br>\n";
}
else
{
/* Commande non trouv<75>e */
print "Compteur inexistant";
}
}
else
{
print "Compteur inexistant";
}
}
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -1,108 +0,0 @@
<?php
/* Copyright (C) 2005-2007 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.
*/
/**
* \file htdocs/energie/compteur_graph.php
* \ingroup energie
* \brief Fiche de gestion des graphs des compteurs
* \version $Id$
*/
require("./pre.inc.php");
/*
* View
*/
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
/* *************************************************************************** */
/* */
/* Mode vue */
/* */
/* *************************************************************************** */
if ($_GET["id"] > 0)
{
$compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0)
{
$head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id;
$head[0][1] = $langs->trans("Compteur");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Graph");
$a = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Releves");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Groups");
$h++;
dol_fiche_head($head, $a, $soc->nom);
print '<table class="border" width="100%">';
print "<tr><td>".$langs->trans("Compteur")."</td>";
print '<td width="50%">';
print $compteur->libelle;
print "</td></tr>";
print "</table><br>";
print '<table class="noborder" width="100%">';
print '<tr><td align="center" colspan="2">';
$file = "day.".$compteur->id.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td></tr>';
print '<tr><td align="center" colspan="2">';
$file = "week.".$compteur->id.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td></tr>';
print '<tr><td align="center">';
$file = "month.".$compteur->id.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td><td align="center">';
$file = "year.".$compteur->id.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td></tr></table><br>';
print '</div>';
}
else
{
/* Compteur non trouv<75>e */
print "Compteur inexistant";
}
}
else
{
print "Compteur inexistant";
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,121 +0,0 @@
<?php
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/energie/compteur_groupe.php
* \ingroup energie
* \brief Fiche de gestion des groupes des compteurs
* \version $Id$
*/
require("./pre.inc.php");
/*
* Actions
*/
if ($_POST["action"] == 'addvalue')
{
$compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0)
{
if ( $compteur->AddGroup($_POST["groupe"]) == 0)
{
Header("Location: compteur.php?id=".$_GET["id"]);
}
}
}
/*
* View
*/
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
if ($_GET["id"] > 0)
{
$compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0)
{
$head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id;
$head[0][1] = $langs->trans("Compteur");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Graph");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Releves");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Groups");
$a = $h;
$h++;
dol_fiche_head($head, $a, $soc->nom);
print '<table class="border" width="100%">';
print "<tr><td>".$langs->trans("Compteur")."</td>";
print '<td width="50%">';
print $compteur->libelle;
print "</td></tr>";
print "</table><br>";
$html = new Form($db);
print '<form action="compteur_groupe.php?id='.$compteur->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addvalue">';
print '<table class="border" width="100%">';
$var=!$var;
print "<tr $bc[$var]>";
$compteur->GroupsAvailable();
print '<td>Groupe</td><td>';
print $html->select_array("groupe", $compteur->groups_available);
print '</td>';
print '<td align="center"><input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
print "</table></form><br>";
print '</div>';
print "<br>\n";
}
else
{
/* Commande non trouv<75>e */
print "Compteur inexistant";
}
}
else
{
print "Compteur inexistant";
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,126 +0,0 @@
<?php
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/commande/fiche.php
\ingroup commande
\brief Fiche commande
\version $Revision$
*/
require("./pre.inc.php");
/*
*
*/
if ($_POST["action"] == 'addvalue')
{
if ($_POST["releve"] > 0)
{
$compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0)
{
$date = mktime(12,
0 ,
0,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]);
$compteur->AjoutReleve($date, $_POST["releve"]);
Header("Location: compteur.php?id=".$_GET["id"]);
}
}
}
/*
*
*/
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
if ($_GET["period"] == '')
{
$period = "day";
}
else
{
$period = $_GET["period"];
}
$head[0][0] = DOL_URL_ROOT.'/energie/graph.php?period=day';
$head[0][1] = $langs->trans("Day");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/graph.php?period=week';
$head[$h][1] = $langs->trans("Week");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/graph.php?period=month';
$head[$h][1] = $langs->trans("Month");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/graph.php?period=year';
$head[$h][1] = $langs->trans("Year");
$h++;
$as["day"] = 0;
$as["week"] = 1;
$as["month"] = 2;
$as["year"] = 3;
dol_fiche_head($head, $as[$period], $soc->nom);
print '<table class="noborder" width="100%">';
$sql = "SELECT c.rowid, c.libelle";
$sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur as c";
$sql .= " ORDER BY c.libelle DESC";
$resql = $db->query($sql);
if ( $resql)
{
$num = $db->num_rows($resql);
if ($num)
{
$i = 0;
$var = True;
while ($i < $num)
{
$var=!$var;
$obj = $db->fetch_object($resql);
print '<tr><td align="center">';
$file = $period.".".$obj->rowid.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td></tr>';
$i++;
}
}
}
print '</table><br>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,159 +0,0 @@
<?php
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
/**
* \file htdocs/energie/groupe.php
* \ingroup energie
* \brief Fiche groupe
* \version $Revision$
*/
require("./pre.inc.php");
/*
* Actions
*/
if ($_POST["action"] == 'add')
{
$groupe = new EnergieGroupe($db, $user);
if ( $groupe->create($_POST["libelle"]) == 0)
{
Header("Location: groupe.php?id=".$groupe->id);
}
else
{
Header("Location: groupe.php?action=create");
}
}
/*
* View
*/
llxHeader($langs, '',$langs->trans("Group"), "Group");
/*********************************************************************
*
* Mode creation
*
*
************************************************************************/
if ($_GET["action"] == 'create')
{
$head[0][0] = DOL_URL_ROOT.'/energie/groupe.php?action=create';
$head[0][1] = $langs->trans("NewGroup");
$h++;
$a = 0;
dol_fiche_head($head, $a, $soc->nom);
$html = new Form($db);
print '<form action="groupe.php" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<table class="border" width="100%">';
print "<tr $bc[$var]>";
print '<td>'.$langs->trans("Label").'</td>';
print '<td><input type="text" size="40" maxlength="255" name="libelle"></td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
print "</table></form>";
print '</div>';
}
else
/* *************************************************************************** */
/* */
/* Mode vue */
/* */
/* *************************************************************************** */
{
if ($_GET["id"] > 0)
{
$groupe = new EnergieGroupe($db, $user);
if ( $groupe->fetch($_GET["id"]) == 0)
{
$head[0][0] = DOL_URL_ROOT.'/energie/groupe.php?id='.$commande->id;
$head[0][1] = $langs->trans("Group");
$h++;
$a = 0;
dol_fiche_head($head, $a, $soc->nom);
print '<table class="border" width="100%">';
print "<tr><td>".$langs->trans("Group")."</td>";
print '<td width="50%">';
print $groupe->libelle;
print "</td></tr>";
print "</table><br>";
/*
*
*/
print '<table class="noborder" width="100%">';
print '<tr><td align="center">';
$file = "groupe.day.".$groupe->id.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td><td align="center">';
$file = "groupe.week.".$groupe->id.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td></tr>';
print '<tr><td align="center">';
$file = "groupe.month.".$groupe->id.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td><td align="center">';
$file = "groupe.year.".$groupe->id.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file='.$file.'" alt="" title="">';
print '</td></tr></table><br>';
print '</div>';
print "<br>\n";
}
else
{
/* Commande non trouv<75>e */
print "Groupe inexistant";
}
}
else
{
print "Groupe inexistant";
}
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,107 +0,0 @@
<?php
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/commande/index.php
\ingroup compta
\brief Page acceuil zone comptabilité
\version $Revision$
*/
require("./pre.inc.php");
llxHeader($langs,"",$langs->trans("Energy"),$langs->trans("Energy"));
print_fiche_titre($langs->trans("Energy"));
print '<table class="notopnoleftnoright" width="100%">';
print '<tr><td valign="top" width="30%" class="notopnoleft">';
/*
* Groupe
*/
$sql = "SELECT c.rowid, c.libelle";
$sql .= " FROM ".MAIN_DB_PREFIX."energie_groupe as c";
$sql .= " ORDER BY c.libelle DESC";
$resql = $db->query($sql);
if ( $resql)
{
$num = $db->num_rows($resql);
if ($num)
{
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("Groupes").'</td></tr>';
$var = True;
while ($i < $num)
{
$var=!$var;
$obj = $db->fetch_object($resql);
print "<tr $bc[$var]><td><a href=\"groupe.php?id=$obj->rowid\">".$obj->libelle."</a></td>";
print '</tr>';
$i++;
}
print "</table><br>";
}
}
/*
* Compteurs
*/
$sql = "SELECT c.rowid, c.libelle";
$sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur as c";
$sql .= " ORDER BY c.libelle DESC";
$resql = $db->query($sql);
if ( $resql)
{
$num = $db->num_rows($resql);
if ($num)
{
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("Compteurs").'</td></tr>';
$var = True;
while ($i < $num)
{
$var=!$var;
$obj = $db->fetch_object($resql);
print "<tr $bc[$var]><td><a href=\"compteur.php?id=$obj->rowid\">".$obj->libelle."</a></td>";
print '</tr>';
$i++;
}
print "</table><br>";
}
}
print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=energie&file=month.png" alt="" title=""><br /><br />'."\n";
print '</td></tr></table>';
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -1,53 +0,0 @@
<?php
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
/**
\file htdocs/energie/pre.inc.php
\ingroup energie
\brief Gestionnaire du menu energie
\version $Revision$
*/
require("../main.inc.php");
require("./EnergieCompteur.class.php");
require("./EnergieGroupe.class.php");
$langs->load("energy");
function llxHeader($langs, $head = "", $title="", $help_url='')
{
top_menu($head, $title);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/energie/", $langs->trans("Energy"));
$menu->add_submenu(DOL_URL_ROOT."/energie/compteur.php?action=create", $langs->trans("NewCounter"));
$menu->add_submenu(DOL_URL_ROOT."/energie/groupe.php?action=create", $langs->trans("NewGroup"));
$menu->add_submenu(DOL_URL_ROOT."/energie/graph.php", $langs->trans("Statistics"));
left_menu($menu->liste, $help_url);
}
?>

View File

@ -1,144 +0,0 @@
<?php
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
/**
* \file htdocs/energie/compteur.php
* \ingroup energie
* \brief Fiche compteur
* \version $Revision$
*/
require("./pre.inc.php");
/*
* Actions
*/
if ($_GET["action"] == 'delete')
{
if ($_GET["rowid"] > 0)
{
$compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0)
{
$compteur->DeleteReleve($_GET["rowid"]);
}
}
}
/*
* View
*/
llxHeader($langs, '',$langs->trans("Compteur"),"Compteur");
if ($_GET["id"] > 0)
{
$compteur = new EnergieCompteur($db, $user);
if ( $compteur->fetch($_GET["id"]) == 0)
{
$head[0][0] = DOL_URL_ROOT.'/energie/compteur.php?id='.$compteur->id;
$head[0][1] = $langs->trans("Compteur");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_graph.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Graph");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/energie/releve.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Releves");
$h++;
$a = 2;
$head[$h][0] = DOL_URL_ROOT.'/energie/compteur_groupe.php?id='.$compteur->id;
$head[$h][1] = $langs->trans("Groups");
$h++;
dol_fiche_head($head, $a, $soc->nom);
print '<table class="border" width="100%">';
print "<tr><td>".$langs->trans("Compteur")."</td>";
print '<td width="50%">';
print $compteur->libelle;
print "</td></tr>";
print "</table><br>";
print '</div>';
$page = $_GET["page"];
$limit = $conf->liste_limit;
$offset = $limit * $page ;
$sql = "SELECT ".$db->pdate("date_releve")." as date_releve, valeur, rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."energie_compteur_releve as ecr";
$sql .= " WHERE ecr.fk_compteur = '".$compteur->id."'";
$sql .= " ORDER BY ecr.date_releve DESC";
$sql .= $db->plimit($limit + 1 ,$offset);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$var=True;
print_barre_liste("Releves", $page, "", "&amp;id=".$compteur->id, $sortfield, $sortorder,'',$num, 0, '');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Date").'</td>';
print '<td colspan="2">'.$langs->trans("Releve").'</td></tr>';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]><td>";
print dol_print_date($obj->date_releve,'%a %d %B %Y');
print '</td><td>'.$obj->valeur.'</td>';
print '<td><a href="releve.php?id='.$compteur->id.'&amp;action=delete&amp;rowid='.$obj->rowid.'&amp;page='.$page.'">';
print img_delete().'</a></td></tr>';
$i++;
}
}
print '</table>';
print "<br>\n";
}
else
{
/* Commande non trouv<75>e */
print "Compteur inexistant";
}
}
else
{
print "Compteur inexistant";
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -20,8 +20,6 @@ insert into `llx_menu` (`enabled`, `rowid`, `menu_handler`, `type`, `mainmenu`,
insert into `llx_menu` (`enabled`, `rowid`, `menu_handler`, `type`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->compta->enabled || $conf->accounting->enabled || $conf->banque->enabled || $conf->facture->enabled', 6__+MAX_llx_menu__, 'auguria', 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&amp;leftmenu=', 'MenuFinancial', -1, 'compta', '$user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->commande->lire || $user->rights->facture->lire || $user->rights->banque->lire', '', 2, 6, __ENTITY__);
insert into `llx_menu` (`enabled`, `rowid`, `menu_handler`, `type`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->projet->enabled', 7__+MAX_llx_menu__, 'auguria', 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&amp;leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 0, 7, __ENTITY__);
insert into `llx_menu` (`enabled`, `rowid`, `menu_handler`, `type`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->mailing->enabled || $conf->export->enabled || $conf->global->MAIN_MODULE_IMPORT || $conf->global->MAIN_MODULE_DOMAIN', 8__+MAX_llx_menu__, 'auguria', 'top', 'tools', '', 0, '/index.php?mainmenu=tools&amp;leftmenu=', 'Tools', -1, 'other', '$user->rights->mailing->lire || $user->rights->bookmark->lire || $user->rights->export->lire', '', 2, 8, __ENTITY__);
insert into `llx_menu` (`enabled`, `rowid`, `menu_handler`, `type`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('! empty($conf->telephonie->enabled) && $user->rights->telephonie->lire', 9__+MAX_llx_menu__, 'auguria', 'top', 'telephony', '', 0, '/telephonie/index.php?mainmenu=telephony&amp;leftmenu=', 'Telephony', -1, 'telephony', '$user->rights->telephonie->lire', '', 2, 9, __ENTITY__);
insert into `llx_menu` (`enabled`, `rowid`, `menu_handler`, `type`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('! empty($conf->energie->enabled)', 10__+MAX_llx_menu__, 'auguria', 'top', 'energy', '', 0, '/energie/index.php?mainmenu=energy&amp;leftmenu=', 'Energy', -1, 'energy', '', '', 2, 10, __ENTITY__);
insert into `llx_menu` (`enabled`, `rowid`, `menu_handler`, `type`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('! empty($conf->boutique->enabled)', 11__+MAX_llx_menu__, 'auguria', 'top', 'shop', '', 0, '/boutique/index.php?mainmenu=shop&amp;leftmenu=', 'OSCommerce', -1, 'shop', '', '', 0, 11, __ENTITY__);
insert into `llx_menu` (`enabled`, `rowid`, `menu_handler`, `type`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('! empty($conf->oscommercews->enabled)', 12__+MAX_llx_menu__, 'auguria', 'top', 'shop', '', 0, '/oscommerce_ws/index.php?mainmenu=shop&amp;leftmenu=', 'OSCommerce', -1, 'shop', '', '', 0, 12, __ENTITY__);
insert into `llx_menu` (`enabled`, `rowid`, `menu_handler`, `type`, `mainmenu`, `leftmenu`, `fk_menu`, `url`, `titre`, `level`, `langs`, perms, `target`, `user`, position, entity) values ('$conf->adherent->enabled', 13__+MAX_llx_menu__, 'auguria', 'top', 'members', '', 0, '/adherents/index.php?mainmenu=members&amp;leftmenu=', 'Members', -1, 'members', '', '', 2, 15, __ENTITY__);

View File

@ -1,116 +0,0 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2007 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.
*/
/**
* \defgroup energie Module energy
* \brief Module pour le suivi de la consommation d'energie
* \version $Id$
*/
/**
* \file htdocs/includes/modules/modEnergie.class.php
* \ingroup energie
* \brief Fichier de description et activation du module Energie
*/
include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php");
/**
* \class modEnergie
* \brief Classe de description et activation du module Energie
*/
class modEnergie extends DolibarrModules
{
/**
* \brief Constructeur. Definit les noms, constantes et boites
* \param DB handler d'acces base
*/
function modEnergie($DB)
{
$this->db = $DB ;
$this->numero = 23 ;
$this->family = "other";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = eregi_replace('^mod','',get_class($this));
$this->description = "Suivi de la consommation des energies";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'dolibarr';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->special = 3;
$this->picto='energie';
// Data directories to create when module is enabled
$this->dirs = array('/energie/temp','/energie/graph');
// Dependances
$this->depends = array();
// Config pages
$this->config_page_url = array("energie.php");
// Constantes
$this->const = array();
// Boxes
$this->boxes = array();
$r=0;
$this->boxes[$r][1] = "box_energie_releve.php";
$r++;
$this->boxes[$r][1] = "box_energie_graph.php";
$r++;
// Permissions
$this->rights = array();
}
/**
* \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module.
* Definit egalement les repertoires de donnees a creer pour ce module.
*/
function init()
{
global $conf;
// Permissions et valeurs par defaut
$this->remove();
$sql = array();
return $this->_init($sql);
}
/**
* \brief Fonction appelee lors de la desactivation d'un module.
* Supprime de la base les constantes, boites et permissions du module.
*/
function remove()
{
$sql = array();
return $this->_remove($sql);
}
}
?>

View File

@ -50,7 +50,8 @@ class modImport extends DolibarrModules
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = eregi_replace('^mod','',get_class($this));
$this->description = "Outils d'imports de donnees Dolibarr (via un assistant)";
$this->version = 'development'; // 'experimental' or 'dolibarr' or version
// Possible values for version are: 'experimental' or 'dolibarr' or version
$this->version = 'experimental'; // 'experimental' or 'dolibarr' or version
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->special = 0;
$this->picto = '';

View File

@ -1,315 +0,0 @@
<?php
/* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2007 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.
*/
/**
\defgroup telephonie Module telephonie
\brief Module pour gerer la telephonie
*/
/**
\file htdocs/includes/modules/modTelephonie.class.php
\ingroup telephonie
\brief Fichier de description et activation du module de Telephonie
\version $Id$
*/
include_once(DOL_DOCUMENT_ROOT."/includes/modules/DolibarrModules.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
/**
\class modTelephonie
\brief Classe de description et activation du module Telephonie
*/
class modTelephonie extends DolibarrModules
{
/**
* \brief Constructeur. Definit les noms, constantes et boites
* \param DB handler d'acces base
*/
function modTelephonie($DB)
{
$this->db = $DB ;
$this->numero = 56 ;
$this->family = "other";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = eregi_replace('^mod','',get_class($this));
$this->description = "Gestion de la Telephonie";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'dolibarr';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->special = 3;
$this->picto='phoning';
// Relative path to module style sheet if exists
$this->style_sheet = '/telephonie/telephonie.css';
// Data directories to create when module is enabled
$this->dirs = array("/telephonie/temp",
"/telephonie/graph",
"/telephonie/logs",
"/telephonie/client",
"/telephonie/rapports",
"/telephonie/ligne/commande/retour/traite",
"/telephonie/cdr/archives",
"/telephonie/cdr/atraiter");
// Dependancies
$this->depends = array();
$this->requiredby = array();
// Constants
$this->const = array();
// Boxes
$this->boxes = array();
// Permissions
$this->rights = array();
$this->rights_class = 'telephonie';
$this->rights[1][0] = 211; // id de la permission
$this->rights[1][1] = 'Consulter la telephonie'; // libelle de la permission
$this->rights[1][2] = 'r'; // type de la permission (deprecie a ce jour)
$this->rights[1][3] = 1; // La permission est-elle une permission par defaut
$this->rights[1][4] = 'lire';
$this->rights[2][0] = 212; // id de la permission
$this->rights[2][1] = 'Commander les lignes'; // libelle de la permission
$this->rights[2][2] = 'w'; // type de la permission (deprecie a ce jour)
$this->rights[2][3] = 0; // La permission est-elle une permission par defaut
$this->rights[2][4] = 'ligne_commander';
$this->rights[3][0] = 213;
$this->rights[3][1] = 'Activer une ligne';
$this->rights[3][2] = 'w';
$this->rights[3][3] = 0;
$this->rights[3][4] = 'ligne_activer';
$this->rights[4][0] = 214; // id de la permission
$this->rights[4][1] = 'Configurer la telephonie'; // libelle de la permission
$this->rights[4][2] = 'w';
$this->rights[4][3] = 0;
$this->rights[4][4] = 'configurer';
$this->rights[5][0] = 215;
$this->rights[5][1] = 'Configurer les fournisseurs';
$this->rights[5][2] = 'w';
$this->rights[5][3] = 0;
$this->rights[5][4] = 'fournisseur';
$this->rights[5][5] = 'config';
$this->rights[6][0] = 192;
$this->rights[6][1] = 'Creer des lignes';
$this->rights[6][2] = 'w';
$this->rights[6][3] = 0;
$this->rights[6][4] = 'ligne';
$this->rights[6][5] = 'creer';
$this->rights[7][0] = 202;
$this->rights[7][1] = 'Creer des liaisons ADSL';
$this->rights[7][2] = 'w';
$this->rights[7][3] = 0;
$this->rights[7][4] = 'adsl';
$this->rights[7][5] = 'creer';
$this->rights[8][0] = 203;
$this->rights[8][1] = "Demander la commande des liaisons";
$this->rights[8][2] = 'w';
$this->rights[8][3] = 0;
$this->rights[8][4] = 'adsl';
$this->rights[8][5] = 'requete';
$this->rights[9][0] = 204;
$this->rights[9][1] = 'Commander les liaisons';
$this->rights[9][2] = 'w';
$this->rights[9][3] = 0;
$this->rights[9][4] = 'adsl';
$this->rights[9][5] = 'commander';
$this->rights[10][0] = 205;
$this->rights[10][1] = 'Gerer les liaisons';
$this->rights[10][2] = 'w';
$this->rights[10][3] = 0;
$this->rights[10][4] = 'adsl';
$this->rights[10][5] = 'gerer';
$r = 10;
$r++;
$this->rights[$r][0] = 271;
$this->rights[$r][1] = 'Consulter le CA';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'ca';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 272;
$this->rights[$r][1] = 'Consulter les factures';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'facture';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 273;
$this->rights[$r][1] = 'Emmettre les factures';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'facture';
$this->rights[$r][5] = 'ecrire';
$r++;
$this->rights[$r][0] = 206;
$this->rights[$r][1] = 'Consulter les liaisons';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'adsl';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 231;
$this->rights[$r][1] = 'Definir le mode de reglement';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'contrat';
$this->rights[$r][5] = 'paiement';
$r++;
$this->rights[$r][0] = 193;
$this->rights[$r][1] = 'Resilier des lignes';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'ligne';
$this->rights[$r][5] = 'resilier';
$r++;
$this->rights[$r][0] = 194;
$this->rights[$r][1] = 'Consulter la marge des lignes';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'ligne';
$this->rights[$r][5] = 'gain';
$r++;
$this->rights[$r][0] = 146;
$this->rights[$r][1] = 'Consulter les fournisseurs';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'fournisseur';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 147;
$this->rights[$r][1] = 'Consulter les stats';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'stats';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 311;
$this->rights[$r][1] = 'Consulter les services';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'service';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 312;
$this->rights[$r][1] = 'Affecter des services a un contrat';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'service';
$this->rights[$r][5] = 'affecter';
$r++;
$this->rights[$r][0] = 291;
$this->rights[$r][1] = 'Consulter les tarifs';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'tarifs';
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 292;
$this->rights[$r][1] = 'Definir les permissions sur les tarifs';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'tarif';
$this->rights[$r][5] = 'permission';
$r++;
$this->rights[$r][0] = 293;
$this->rights[$r][1] = 'Modifier les tarifs clients';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'tarif';
$this->rights[$r][5] = 'client_modifier';
$r++;
}
/**
* \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module.
* Definit egalement les repertoires de donnees a creer pour ce module.
*/
function init()
{
global $conf;
// Permissions
$this->remove();
//
$this->load_tables();
//
return $this->_init($sql);
}
/**
\brief Fonction appelee lors de la desactivation d'un module.
Supprime de la base les constantes, boites et permissions du module.
*/
function remove()
{
$sql = array();
return $this->_remove($sql);
}
/**
* \brief Create tables and keys required by module
* Files mymodule.sql and mymodule.key.sql with create table and create keys
* commands must be stored in directory /mymodule/sql/.
* This function is called by this->init.
* \return int <=0 if KO, >0 if OK
*/
function load_tables()
{
return $this->_load_tables('/telephonie/sql/');
}
}
?>

View File

@ -1,917 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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("./pre.inc.php");
if (!$user->rights->telephonie->adsl->lire) accessforbidden();
$mesg = '';
$dt = time();
$h = strftime("%H",$dt);
$m = strftime("%M",$dt);
$s = strftime("%S",$dt);
if ($_POST["action"] == 'add')
{
$ligne = new LigneAdsl($db);
$ligne->numero = $_POST["numero"];
$ligne->client = $_POST["client"];
$ligne->client_install = $_POST["client_install"];
$ligne->client_facture = $_POST["client_facture"];
$ligne->contrat = $_POST["contrat"];
$ligne->fournisseur = $_POST["fournisseur"];
$ligne->commercial = $_POST["commercial"];
$ligne->type = $_POST["type"];
$ligne->note = $_POST["note"];
if ( $ligne->create($user) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
else
{
$_GET["action"] = 'create_line';
$_GET["client"] = $_POST["client"];
}
}
if ($_GET["action"] == 'delete' && $user->rights->telephonie->adsl->creer)
{
$ligne = new LigneAdsl($db);
if ( $ligne->delete($_GET["id"]) == 0)
{
Header("Location: liste.php");
}
}
if ($_GET["action"] == 'ordertech')
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
if ( $ligne->set_statut($user, 1) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'cancelordertech')
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
if ( $ligne->set_statut($user, -1) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'refuse')
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
$datea = $db->idate(mktime($h, $m , $s,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]));
if ( $ligne->set_statut($user, 7, $datea, $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'resilier')
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
$datea = $db->idate(mktime($h, $m , $s,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]));
if ( $user->rights->telephonie->adsl->gerer && $ligne->statut == 4)
{
if ( $ligne->set_statut($user, 5, $datea, $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
else
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'annuleresilier')
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
if ( $user->rights->telephonie->adsl->gerer && $ligne->statut == 5)
{
if ( $ligne->set_statut($user, 4) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
else
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'resilierfourn')
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
$datea = $db->idate(mktime($h, $m , $s,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]));
if ( $user->rights->telephonie->adsl->gerer && $ligne->statut == 5)
{
if ( $ligne->set_statut($user, 6, $datea, $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
else
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'acquitresilierfourn')
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
$datea = $db->idate(mktime($h, $m , $s,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]));
if ( $user->rights->telephonie->adsl->gerer && $ligne->statut == 6)
{
if ( $ligne->set_statut($user, 7, $datea, $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
else
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'commandefourn' && $user->rights->telephonie->adsl->commander)
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
$datea = $db->idate(mktime($h, $m , $s,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]));
if ( $ligne->set_statut($user, 2, $datea, $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'activefourn' && $user->rights->telephonie->adsl->gerer)
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
$datea = $db->idate(mktime($h, $m , $s,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]));
$ligne->update_info($_POST["ip"], $_POST["login"], $_POST["password"]);
if ( $ligne->set_statut($user, 3, $datea, $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'livraison' && $user->rights->telephonie->adsl->gerer)
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
$datea = $db->idate(mktime($h, $m , $s,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]));
if ( $ligne->set_statut($user, 4, $datea, $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'backbone' && $user->rights->telephonie->adsl->gerer)
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
$datea = $db->idate(mktime($h, $m , $s,
$_POST["remonth"],
$_POST["reday"],
$_POST["reyear"]));
if ( $ligne->set_statut($user, 9, $datea, $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'acommander')
{
$ligne = new LigneAdsl($db);
$ligne->fetch_by_id($_GET["id"]);
if ( $ligne->set_statut($user, 1, '', $_POST["commentaire"]) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
{
$ligne = new LigneAdsl($db);
$ligne->id = $_GET["id"];
$ligne->numero = $_POST["numero"];
$ligne->client_comm = $_POST["client_comm"];
$ligne->client = $_POST["client"];
$ligne->client_facture = $_POST["client_facture"];
$ligne->fournisseur = $_POST["fournisseur"];
$ligne->commercial = $_POST["commercial"];
$ligne->concurrent = $_POST["concurrent"];
$ligne->remise = $_POST["remise"];
$ligne->note = $_POST["note"];
if ( $ligne->update($user) )
{
$action = '';
$mesg = 'Fiche mise <20> jour';
}
else
{
$action = 're-edit';
$mesg = 'Fiche non mise <20> jour !' . "<br>" . $entrepot->mesg_error;
}
}
llxHeader("","","Fiche Liaison");
if ($cancel == $langs->trans("Cancel"))
{
$action = '';
}
/*
* Cr<EFBFBD>ation en 2 <EFBFBD>tape
*
*/
if ($_GET["action"] == 'create')
{
$form = new Form($db);
print_titre("Nouvelle liaison ADSL");
if (is_object($ligne))
{
// La cr<63>ation a <20>chou<6F>e
print $ligne->error_message;
}
else
{
$ligne = new LigneAdsl($db);
}
print '<form action="fiche.php" method="GET">';
print '<input type="hidden" name="action" value="create_line">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="20%">Client</td><td >';
$ff = array();
$sql = "SELECT rowid, nom, ville FROM ".MAIN_DB_PREFIX."societe WHERE client=1 ORDER BY nom ";
$resql = $db->query($sql);
if ( $resql )
{
$num = $db->num_rows($resql);
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$ff[$row[0]] = stripslashes($row[1]) . " (".$row[2].")";
$i++;
}
}
$db->free($resql);
}
$form->select_array("client",$ff,$ligne->client_comm);
print '</td></tr>';
print '<tr><td>&nbsp;</td><td><input type="submit" value="Cr<43>er"></td></tr>'."\n";
print '</table>'."\n";
print '</form>';
}
elseif ($_GET["action"] == 'create_line' && $_GET["client"] > 0)
{
$form = new Form($db);
print_titre("Nouvelle liaison ADSL");
if (is_object($ligne))
{
// La cr<63>ation a <20>chou<6F>e
print '<div class="errormessage">'.$ligne->error_message.'</div>';
}
else
{
$ligne = new LigneAdsl($db);
$ligne->client_install_id = $_GET["client"];
$ligne->client_facture_id = $_GET["client"];
}
$socc = new Societe($db);
if ( $socc->fetch($_GET["client"]) == 1)
{
if (strlen($socc->code_client) == 0)
{
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="20%">Client</td><td >';
print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$socc->id.'">'.$socc->nom.'</a>';
print '</td></tr>';
print '<tr><td width="20%">Code client</td><td >';
print $socc->code_client;
print '</td></tr>';
print '</table><br /><br />';
print 'Impossible de cr<63>er une ligne pour cette societe, vous devez au prealablement lui affecter un code client.';
}
elseif (strlen($socc->code_client) > 0 && $socc->check_codeclient() <> 0)
{
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="20%">Client</td><td >';
print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$socc->id.'">'.$socc->nom.'</a>';
print '</td></tr>';
print '<tr><td width="20%">Code client</td><td >';
print $socc->code_client;
print '</td></tr>';
print '</table><br /><br />';
print 'Le code client de cette societe est incorrect, vous devez lui affecter un code client correct.';
}
else
{
print "<form action=\"fiche.php\" method=\"post\">\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="client" value="'.$socc->id.'">'."\n";
if ($_GET['contratid'] > 0)
{
print '<input type="hidden" name="contrat" value="'.$_GET['contratid'].'">'."\n";
}
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="20%">Client</td><td >';
print "$socc->nom ($socc->code_client)";
print '</td></tr>';
print '<tr><td width="20%">Contrat</td><td>';
$contrats = array();
$contrats_id = array();
$sql = "SELECT rowid, ref FROM ".MAIN_DB_PREFIX."telephonie_contrat WHERE fk_soc = ".$socc->id.";";
if ( $resql = $db->query( $sql) )
{
$i = 0;
while ($row = $db->fetch_row($resql))
{
$contrats[$i] = $row;
$contrats_id[$row[0]] = $row[1];
$i++;
}
$db->free($resql);
}
if ($i == 0)
{
print "Pas de contrat en cours";
print '</td></tr>';
}
elseif($i == 1)
{
print $contrats[0][1];
print '</td></tr>';
print '<input type="hidden" name="contrat" value="'.$contrats[0][1].'">'."\n";
}
else
{
$form->select_array("contrat",$contrats_id);
print '</td></tr>';
}
// On continue si il existe des contrats
if (sizeof($contrats) > 0)
{
print '<tr><td width="20%">Num<75>ro de la ligne t<>l<EFBFBD>phonique</td><td><input name="numero" size="12" value="'.$ligne->numero.'"></td></tr>';
print '<tr><td width="20%">Client (Agence/Filiale)</td><td >';
$ff = array();
$sql = "SELECT rowid, nom, ville FROM ".MAIN_DB_PREFIX."societe WHERE client=1 ORDER BY nom ";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row();
$ff[$row[0]] = stripslashes($row[1]) . " (".$row[2].")";
$i++;
}
}
$db->free();
}
$form->select_array("client_install",$ff,$ligne->client_install_id);
print " (Correspond <20> l'adresse d'installation)</td></tr>";
print '<tr><td width="20%">Client <20> facturer</td><td >';
$ff = array();
$sql = "SELECT rowid, nom, ville FROM ".MAIN_DB_PREFIX."societe WHERE client=1 ORDER BY nom ";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row();
$ff[$row[0]] = stripslashes($row[1]) . " (".$row[2].")";
$i++;
}
}
$db->free();
}
$form->select_array("client_facture",$ff,$ligne->client_facture_id);
print '</td></tr>';
/*
* Type
*/
print '<tr><td width="20%">D<>bit de la ligne</td><td >';
$ff = array();
$sql = "SELECT rowid, intitule FROM ".MAIN_DB_PREFIX."telephonie_adsl_type WHERE commande_active = 1 ORDER BY intitule ";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row();
$ff[$row[0]] = $row[1];
$i++;
}
}
$db->free();
}
$form->select_array("type",$ff,$ligne->type);
print '</td></tr>';
/*
* Fournisseur
*/
print '<tr><td width="20%">Fournisseur</td><td >';
$ff = array();
$sql = "SELECT f.rowid, f.nom FROM ".MAIN_DB_PREFIX."societe as f";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_adsl_fournisseur as fa";
$sql .= " WHERE fa.commande_active = 1 AND fa.fk_soc = f.rowid ORDER BY f.nom ";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row();
$ff[$row[0]] = stripslashes($row[1]);
$i++;
}
}
$db->free();
}
else
{
print $db->error();
}
$form->select_array("fournisseur",$ff,$ligne->fournisseur);
print '</td></tr>';
/*
* Commercial
*/
print '<tr><td width="20%">Commercial</td><td >';
$ff = array();
$sql = "SELECT rowid, name, firstname FROM ".MAIN_DB_PREFIX."user ORDER BY name ";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
$ff[$row[0]] = stripslashes($row[1]) . " " . stripslashes($row[2]);
$i++;
}
}
$db->free();
}
$form->select_array("commercial",$ff,$ligne->commercial);
print '</td></tr>';
print '<tr><td width="20%" valign="top">Note</td><td>'."\n";
print '<textarea name="note" rows="4" cols="50">'."\n";
print stripslashes($ligne->note);
print '</textarea></td></tr>'."\n";
print '<tr><td>&nbsp;</td><td><input type="submit" value="Cr<43>er"></td></tr>'."\n";
print '</table>'."\n";
print '</form>';
}
else
{
print '</table>'."\n";
print '</form>';
print '<a href="../contrat/fiche.php?action=create_line&amp;client_comm='.$_GET["client"].'">Nouveau contrat</a>';
}
}
}
else
{
print "Erreur";
}
}
else
{
if ($_GET["id"] or $_GET["numero"])
{
if ($_GET["action"] <> 're-edit')
{
$ligne = new LigneAdsl($db);
if ($_GET["id"])
{
$result = $ligne->fetch_by_id($_GET["id"]);
}
if ($_GET["numero"])
{
$result = $ligne->fetch($_GET["numero"]);
}
}
if ( $result )
{
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/adsl/fiche.php?id=".$ligne->id;
$head[$h][1] = $langs->trans("Liaison ADSL");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/adsl/history.php?id=".$ligne->id;
$head[$h][1] = $langs->trans('Historique');
$h++;
dol_fiche_head($head, $hselected, 'Liaison ADSL : '.$ligne->numero);
print_fiche_titre('Fiche Liaison ADSL', $mesg);
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
$client = new Societe($db, $ligne->client_id);
$client->fetch($ligne->client_id);
print '<tr><td width="20%">Client</td><td>';
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$client->id.'">';
print $client->nom.'</a></td><td>'.$client->code_client;
print '</td></tr>';
print '<tr><td width="20%">Num<75>ro</td><td>'.dol_print_phone($ligne->numero,0,0,true).'</td>';
print '<td>&nbsp;</td></tr>';
print '<tr><td width="20%">D<>bit de la liaison</td><td>'.$ligne->type.'</td>';
print '<td>Prix de vente : '.price($ligne->prix).' euros HT</td></tr>';
$client_install = new Societe($db, $ligne->client_install_id);
$client_install->fetch($ligne->client_install_id);
print '<tr><td width="20%">Client (Agence/Filiale)</td><td colspan="2">';
print $client_install->nom.'<br />';
print $client_install->cp . " " .$client_install->ville;
print '</td></tr>';
$client_facture = new Societe($db);
$client_facture->fetch($ligne->client_facture_id);
print '<tr><td width="20%">Client Factur<75></td><td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid=';
print $client_facture->id.'">';
print $client_facture->nom.'</a><br />';
print $client_facture->cp . " " .$client_facture->ville;
print '</td><td>';
if ($ligne->mode_paiement == 'pre')
{
print 'RIB : '.$client_facture->display_rib();
}
else
{
print 'Paiement par virement';
}
print '</td></tr>';
print '<tr><td width="20%">Contrat</td>';
print '<td colspan="2"><a href="'.DOL_URL_ROOT.'/telephonie/contrat/fiche.php?id='.$ligne->contrat_id.'">';
print substr("00000000".$ligne->contrat_id,-8).'</a></td></tr>';
$commercial = new User($db, $ligne->commercial_id);
$commercial->fetch();
print '<tr><td width="20%">Commercial</td>';
print '<td colspan="2">'.$commercial->fullname.'</td></tr>';
if ( $user->rights->telephonie->adsl->gerer)
{
print '<tr><td width="20%">IP</td><td colspan="2">'.$ligne->ip.'</td></tr>';
print '<tr><td width="20%">Login</td><td colspan="2">'.$ligne->login.'</td></tr>';
print '<tr><td width="20%">Password</td><td colspan="2">'.$ligne->password.'</td></tr>';
}
print '<tr><td width="20%">Statut</td><td colspan="2">';
print '<img src="./statut'.$ligne->statut.'.png">&nbsp;';
print $ligne->statuts[$ligne->statut];
print '</td></tr>';
print "</table>";
}
print '</div>';
}
}
else
{
print "Error";
}
}
$form = new Form($db);
if ( $user->rights->telephonie->adsl->commander && $ligne->statut == 1)
{
/**
*
*/
print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td>';
print '<form name="commandefourn" action="fiche.php?id='.$ligne->id.'&amp;action=commandefourn" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="2" cellspacing="0">';
print '<tr class="liste_titre"><td colspan="2">Commande chez le fournisseur</td><td>';
print '<tr><td>Date de la commande</td><td>';
print $form->select_date('','','','','',"commandefourn");
print '</td>';
print '<td colspan="2"><input type="submit" name="Commander"></td></tr>';
print '<tr><td colspan="3">Commentaire <input size="30" type="text" name="commentaire"></td></tr>';
print '</table>';
print '</form></td><td>';
print '&nbsp;</td></tr></table>';
}
if ( $user->rights->telephonie->adsl->gerer && $ligne->statut == 2)
{
/**
*
*/
print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td>';
print '<form name="activefourn" action="fiche.php?id='.$ligne->id.'&amp;action=activefourn" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="2" cellspacing="0">';
print '<tr class="liste_titre"><td colspan="2">Activ<69>e chez le fournisseur</td><td>';
print "<tr><td>Date de l'activation</td><td>";
print $form->select_date('','','','','',"activefourn");
print '</td></tr>';
print '<tr><td>Commentaire</td><td><input size="30" type="text" name="commentaire"></td></tr>';
print '<tr><td>Adresse IP affect<63>e</td><td><input size="30" type="text" name="ip"></td></tr>';
print '<tr><td>Login</td><td><input size="30" type="text" name="login"></td></tr>';
print '<tr><td>Password</td><td><input size="30" type="text" name="password"></td></tr>';
print '<tr><td colspan="2"><input type="submit" name="Commander"></td></tr>';
print '</table>';
print '</form></td><td>';
print '&nbsp;</td></tr></table>';
}
if ( $user->rights->telephonie->adsl->gerer && $ligne->statut == 3)
{
print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td>';
print '<form name="backbone" action="fiche.php?id='.$ligne->id.'&amp;action=backbone" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="2" cellspacing="0">';
print '<tr class="liste_titre"><td colspan="2">Programm<6D> sur le backbone</td><td>';
print "<tr><td>Date de la programmation</td><td>";
print $form->select_date('','','','','',"backbone");
print '</td>';
print '<td colspan="2"><input type="submit" name="Programmer"></td></tr>';
print '<tr><td colspan="3">Commentaire <input size="30" type="text" name="commentaire"></td></tr>';
print '</table>';
print '</form></td><td>';
print '&nbsp;</td></tr></table>';
}
if ( $user->rights->telephonie->adsl->gerer && $ligne->statut == 9)
{
print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td>';
print '<form name="livraison" action="fiche.php?id='.$ligne->id.'&amp;action=livraison" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="2" cellspacing="0">';
print '<tr class="liste_titre"><td colspan="2">Livr<76>e au client</td><td>';
print "<tr><td>Date de la livraison client</td><td>";
print $form->select_date('','','','','',"livraison");
print '</td>';
print '<td colspan="2"><input type="submit" name="Commander"></td></tr>';
print '<tr><td colspan="3">Commentaire <input size="30" type="text" name="commentaire"></td></tr>';
print '</table>';
print '</form></td><td>';
print '&nbsp;</td></tr></table>';
}
if ( $user->rights->telephonie->adsl->gerer && $ligne->statut == 4)
{
print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td>';
print '<form name="resilier" action="fiche.php?id='.$ligne->id.'&amp;action=resilier" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="4" cellspacing="0">';
print '<tr class="liste_titre"><td colspan="2">A r<>silier</td><td>';
print '<tr class="pair"><td>Date de r<>siliation demand<6E>e</td><td>';
print $form->select_date('','','','','',"resilier");
print '</td></tr>';
print '<tr class="pair"><td>Commentaire</td><td><input size="30" type="text" name="commentaire"></td></tr>';
print '<tr class="pair"><td colspan="2" align="center"><input type="submit" name="Commander"></td></tr>';
print '</table></form></td><td>';
print '&nbsp;</td></tr></table>';
}
if ( $user->rights->telephonie->adsl->gerer && $ligne->statut == 5)
{
print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td>';
print '<form name="resilierfourn" action="fiche.php?id='.$ligne->id.'&amp;action=resilierfourn" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="4" cellspacing="0">';
print '<tr class="liste_titre"><td colspan="2">Demande de r<>siliatin fournisseur</td><td>';
print '<tr class="pair"><td>Date de la demande de r<>siliation</td><td>';
print $form->select_date('','','','','',"resilierfourn");
print '</td></tr>';
print '<tr class="pair"><td>Commentaire</td><td><input size="30" type="text" name="commentaire"></td></tr>';
print '<tr class="pair"><td colspan="2" align="center"><input type="submit" name="Commander"></td></tr>';
print '</table></form></td><td>';
print '&nbsp;</td></tr></table>';
}
if ( $user->rights->telephonie->adsl->gerer && $ligne->statut == 6)
{
print '<table class="noborder" cellpadding="2" cellspacing="0" width="100%"><tr><td>';
print '<form name="acquitresilierfourn" action="fiche.php?id='.$ligne->id.'&amp;action=acquitresilierfourn" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="4" cellspacing="0">';
print '<tr class="liste_titre"><td colspan="2">Confirmation de r<>siliatin fournisseur</td><td>';
print '<tr class="pair"><td>Date de la confirmation de r<>siliation</td><td>';
print $form->select_date('','','','','',"acquitresilierfourn");
print '</td></tr>';
print '<tr class="pair"><td>Commentaire</td><td><input size="30" type="text" name="commentaire"></td></tr>';
print '<tr class="pair"><td colspan="2" align="center"><input type="submit" name="Commander"></td></tr>';
print '</table></form></td><td>';
print '&nbsp;</td></tr></table>';
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<br>\n<div class=\"tabsAction\">\n";
if ($_GET["action"] == '')
{
if ( $user->rights->telephonie->adsl->requete && $ligne->statut == -1)
{
print "<a class=\"butAction\" href=\"fiche.php?action=ordertech&amp;id=$ligne->id\">".$langs->trans("Commander")."</a>";
}
if ( $user->rights->telephonie->adsl->requete && $ligne->statut == 1)
{
print "<a class=\"butAction\" href=\"fiche.php?action=cancelordertech&amp;id=$ligne->id\">".$langs->trans("Annuler la commande")."</a>";
}
if ( $user->rights->telephonie->adsl->requete && $ligne->statut == 5)
{
print "<a class=\"butAction\" href=\"fiche.php?action=annuleresilier&amp;id=$ligne->id\">".$langs->trans("Annuler la demande de r<EFBFBD>siliation")."</a>";
}
if ( $user->rights->telephonie->adsl->creer && $ligne->statut == -1)
{
print "<a class=\"butAction\" href=\"fiche.php?action=delete&amp;id=$ligne->id\">".$langs->trans("Delete")."</a>";
}
}
print "</div>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,129 +0,0 @@
<?PHP
/* Copyright (C) 2005-2007 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 FournisseurXdsl {
var $db;
var $id;
/**
* Constructeur de la classe
*
*/
function FournisseurXdsl($DB, $id=0, $user=0)
{
global $config;
$this->id = $id;
$this->db = $DB;
$this->error_message = '';
return 1;
}
/**
* Cree le fournisseur dans la base de donnees
*
*/
function Create($user)
{
if ($this->socid > 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_adsl_fournisseur";
$sql .= " (fk_soc, commande_active)";
$sql .= " VALUES (";
$sql .= " $this->socid,1)";
$resql = $this->db->query($sql);
if ( $resql )
{
$this->id = $this->db->last_insert_id($resql);
return 0;
}
else
{
dol_syslog("FournisseurXdsl::Create Error -3");
return -3;
}
}
else
{
dol_syslog("FournisseurXdsl::Create Error -2");
return -2;
}
}
/**
*
*
*/
function SwitchCommandeActive($id)
{
$sql= "UPDATE ".MAIN_DB_PREFIX."telephonie_adsl_fournisseur as f";
$sql.= " SET commande_active = abs(commande_active -1) WHERE f.rowid =".$id.";";
$resql=$this->db->query($sql);
if ($resql)
{
return 0;
}
else
{
dol_syslog("FournisseurXdsl::SwithCommandeActive Error -20", LOG_ERR);
return -20;
}
}
/**
* Retourne la liste des fournisseurs
*
*/
function ListArray()
{
$arr = array();
$sql = "SELECT f.rowid, s.nom, f.commande_active";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."telephonie_adsl_fournisseur as f";
$sql.= " WHERE s.fournisseur = 1 AND s.rowid=f.fk_soc";
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$arr[$obj->rowid]['rowid'] = $obj->rowid;
$arr[$obj->rowid]['name'] = stripslashes($obj->nom);
$arr[$obj->rowid]['commande_active'] = $obj->commande_active;
}
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
}
return $arr;
}
}
?>

View File

@ -1,136 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if (!$user->rights->telephonie->adsl->lire) accessforbidden();
$mesg = '';
llxHeader("","","Historique Liaison ADSL");
/*
* Affichage
*
*/
if ($_GET["id"])
{
if ($_GET["action"] <> 're-edit')
{
$ligne = new LigneADSL($db);
$result = $ligne->fetch_by_id($_GET["id"]);
}
if ( $result )
{
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/adsl/fiche.php?id=".$ligne->id;
$head[$h][1] = $langs->trans("Liaison ADSL");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/adsl/history.php?id=".$ligne->id;
$head[$h][1] = $langs->trans('Historique');
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, 'Liaison ADSL : '.$ligne->numero);
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="20%">Num<75>ro de support</td><td colspan="2">'.dol_print_phone($ligne->numero,0,0,true).'</td></tr>';
$client = new Societe($db, $ligne->client_id);
$client->fetch($ligne->client_id);
print '<tr><td width="20%">Client</td><td colspan="2">'.$client->nom.'</td></tr>';
print '<tr><td width="20%">Statut</td><td colspan="2">';
print '<img src="./statut'.$ligne->statut.'.png">&nbsp;';
print $ligne->statuts[$ligne->statut];
print '</td></tr>';
print '<tr class="liste_titre"><td colspan="3">Historique</td></tr>';
/* historique */
$sql = "SELECT ".$db->pdate("l.tms").", l.statut, l.fk_user, u.name, u.firstname, l.comment";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_adsl_ligne_statut as l";
$sql .= ",".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.rowid = l.fk_user AND l.fk_ligne = ".$ligne->id;
$sql .= " ORDER BY l.tms DESC ";
$resql = $db->query($sql);
if ( $resql )
{
$num = $db->num_rows($resql);
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
print '<tr><td valign="top" width="20%">'.strftime("%a %d %B %Y %H:%M:%S",$row[0]).'</td>';
print '<td><img src="./statut'.$row[1].'.png">&nbsp;';
print $ligne->statuts[$row[1]];
if ($row[5])
{
print '<br />'.$row[5];
}
print '</td><td>'.$row[4] . " " . $row[3] . "</td></tr>";
$i++;
}
}
$db->free($resql);
}
else
{
print $sql;
}
/* Fin Contacts */
print "</table>";
}
/*
*
*
*
*/
}
else
{
print "Error";
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,116 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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("./pre.inc.php");
if (!$user->rights->telephonie->adsl->lire) accessforbidden();
llxHeader('','Telephonie');
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
/*
* Mode Liste
*
*/
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="30%" valign="top">';
print '<form method="GET" action="'.DOL_URL_ROOT.'/telephonie/adsl/liste.php">';
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Recherche ligne</td>';
print "</tr>\n";
print "<tr $bc[1]>";
print '<td>Numéro <input name="search_ligne" size="12"></td></tr>';
print '</table>';
print '<br />';
$sql = "SELECT distinct statut, count(*) as cc";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_adsl_ligne as l";
$sql .= " GROUP BY statut";
if ($db->query($sql))
{
$num = $db->num_rows();
$i = 0;
$ligne = new LigneAdsl($db);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Liaisons Statuts</td><td valign="center">Nb</td>';
print "<td>&nbsp;</td></tr>\n";
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object();
$values[$obj->statut] = $obj->cc;
$i++;
}
foreach ($ligne->statuts_order as $keyo => $statut)
{
$var=!$var;
$key = $statut;
print "<tr $bc[$var]>";
print "<td>".$ligne->statuts[$statut]."</td>\n";
print "<td>".$values[$key]."</td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/adsl/liste.php?statut='.$key.'"><img border="0" src="./statut'.$key.'.png"></a></td>';
print "</tr>\n";
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '<br />';
/*
*
*
*/
print '</td><td width="70%" valign="top">';
print '</td></tr>';
print '</table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,298 +0,0 @@
<?PHP
/* Copyright (C) 2005-2007 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_once(DOL_DOCUMENT_ROOT.'/telephonie/workflowtel.class.php');
class LigneAdsl {
var $db;
var $id;
var $ligne;
function LigneAdsl($DB, $id=0)
{
global $config;
$this->id = $id;
$this->db = $DB;
$this->error_message = '';
$this->statuts[-1] = "En attente";
$this->statuts[1] = "A commander";
$this->statuts[2] = "Commandée chez le fournisseur";
$this->statuts[3] = "Activée chez le fournisseur";
$this->statuts[4] = "Installée chez le client";
$this->statuts[5] = "A résilier";
$this->statuts[6] = "Résiliation demandée";
$this->statuts[7] = "Résiliée";
$this->statuts[8] = "Rejetée";
$this->statuts[9] = "Backbone programmé";
$this->statuts_order[0] = -1;
$this->statuts_order[1] = 1;
$this->statuts_order[2] = 2;
$this->statuts_order[3] = 3;
$this->statuts_order[4] = 9;
$this->statuts_order[5] = 4;
$this->statuts_order[6] = 5;
$this->statuts_order[7] = 6;
$this->statuts_order[8] = 7;
$this->statuts_order[9] = 8;
return 1;
}
/*
*
*
*/
function update($user)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_societe_ligne";
$sql .= " SET ";
$sql .= " fk_client_comm = $this->client_comm, ";
$sql .= " fk_soc = $this->client, ";
$sql .= " ligne = '$this->numero', ";
$sql .= " fk_soc_facture = $this->client_facture, ";
$sql .= " fk_fournisseur = $this->fournisseur, ";
$sql .= " fk_commercial = $this->commercial, ";
$sql .= " fk_concurrent = $this->concurrent, ";
$sql .= " note = '$this->note',";
$sql .= " remise = '$this->remise'";
$sql .= " WHERE rowid = $this->id";
if ( $this->db->query($sql) )
{
return 1;
}
else
{
print $this->db->error();
print $sql ;
return 0;
}
}
/*
*
*
*/
function create($user)
{
if (strlen(trim($this->numero)) == 10)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_adsl_ligne";
$sql .= " (fk_client, fk_client_install, fk_client_facture, fk_contrat, numero_ligne, fk_type, fk_fournisseur, note, fk_commercial, statut, fk_user_creat)";
$sql .= " VALUES (";
$sql .= " $this->client,$this->client_install,$this->client_facture,'$this->contrat','$this->numero',$this->type,$this->fournisseur, '$this->note',$this->commercial, -1,$user->id)";
$resql = $this->db->query($sql);
if ( $resql )
{
$this->id = $this->db->last_insert_id($resql);
// Appel le workflow
$wkf = new WorkflowTelephonie($this->db);
$wkf->notify('xdsl', -1, $this->numero);
return 0;
}
else
{
$lex = new LigneAdsl($this->db);
if ($lex->fetch($this->numero) == 1)
{
$this->error_message = "Echec de la création de la ligne, cette ligne existe déjà !";
dol_syslog("LigneAdsl::Create Error -3");
return -3;
}
else
{
$this->error_message = "Echec de la création de la ligne";
dol_syslog("LigneAdsl::Create Error -1");
dol_syslog("LigneAdsl::Create $sql");
return -1;
}
}
}
else
{
$this->error_message = "Echec de la création de la ligne, le numéro de la ligne est incorrect !";
dol_syslog("LigneAdsl::Create Error -2");
return -2;
}
}
/*
*
*
*/
function fetch_by_id($id)
{
return $this->fetch(0, $id);
}
function delete($id)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_adsl_ligne_statut";
$sql .= " WHERE fk_ligne = ".$id;
if ($this->db->query($sql))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_adsl_ligne";
$sql .= " WHERE rowid = ".$id;
if ($this->db->query($sql))
{
return 0;
}
else
{
dol_syslog("LigneAdsl::Delete Error -1");
return -1;
}
}
else
{
dol_syslog("LigneAdsl::Delete Error -2");
return -2;
}
}
function fetch($ligne, $id = 0)
{
$sql = "SELECT l.rowid, l.fk_client, l.fk_client_install, l.fk_client_facture, l.fk_fournisseur, l.numero_ligne, l.note, l.statut, l.fk_commercial";
$sql .= ", l.ip, l.login, l.password, l.prix, l.fk_contrat";
$sql .= " , t.intitule AS type";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_adsl_ligne as l";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_adsl_type as t";
$sql .= " WHERE t.rowid = l.fk_type";
if ($id > 0)
{
$sql .= " AND l.rowid = ".$id;
}
else
{
$sql .= " AND l.numero_ligne = ".$ligne;
}
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->socid = $obj->fk_soc;
$this->numero = $obj->numero_ligne;
$this->remise = $obj->remise;
$this->client_id = $obj->fk_client;
$this->client_install_id = $obj->fk_client_install;
$this->client_facture_id = $obj->fk_client_facture;
$this->fournisseur_id = $obj->fk_fournisseur;
$this->commercial_id = $obj->fk_commercial;
$this->contrat_id = $obj->fk_contrat;
$this->type = $obj->type;
$this->prix = $obj->prix;
$this->statut = $obj->statut;
$this->ip = $obj->ip;
$this->login = $obj->login;
$this->password = $obj->password;
$this->mode_paiement = 'pre';
$result = 1;
}
else
{
$result = -2;
}
$this->db->free($resql);
}
else
{
/* Erreur select SQL */
print $this->db->error();
$result = -1;
}
return $result;
}
/**
*
*
*
*/
function update_info($ip, $login, $password)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_adsl_ligne";
$sql .= " SET ip = '".$ip ."'";
$sql .= " , login = '".$login."'" ;
$sql .= " , password = '".$password."'" ;
$sql .= " WHERE rowid =".$this->id;
$this->db->query($sql);
}
/**
* Change le statut de la ligne
*
*/
function set_statut($user, $statut, $datea='', $commentaire='')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_adsl_ligne";
$sql .= " SET statut = ".$statut ;
$sql .= " WHERE rowid =".$this->id;
$this->db->query($sql);
if ($datea <> '')
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_adsl_ligne_statut";
$sql .= " (tms,fk_ligne, fk_user, statut, comment) ";
$sql .= " VALUES ($datea,$this->id, $user->id, $statut, '$commentaire' )";
$this->db->query($sql);
}
else
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_adsl_ligne_statut";
$sql .= " (tms, fk_ligne, fk_user, statut, comment) ";
$sql .= " VALUES (now(), $this->id, $user->id, $statut, '$commentaire' )";
$this->db->query($sql);
}
// Appel le workflow
$wkf = new WorkflowTelephonie($this->db);
$wkf->notify('xdsl', $statut, $this->numero, $commentaire);
return 0;
}
}
?>

View File

@ -1,157 +0,0 @@
<?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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if (!$user->rights->telephonie->adsl->lire) accessforbidden();
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
llxHeader('','Telephonie - Ligne - Liste');
/*
* S<EFBFBD>curit<EFBFBD> acc<EFBFBD>s client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
/*
* Recherche
*
*
*/
$offset = $conf->liste_limit * $page ;
if ($sortorder == "") $sortorder="ASC";
if ($sortfield == "") $sortfield="la.statut ASC, s.nom";
/*
* Mode Liste
*
*
*/
$sql = "SELECT la.rowid, fk_client, s.nom as nom, la.numero_ligne, la.statut, t.intitule";
$sql .= " , s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_adsl_ligne as la";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_adsl_type as t";
$sql .= " WHERE la.fk_client = s.rowid";
$sql .= " AND t.rowid = la.fk_type";
if ($_GET["search_ligne"])
{
$sel =urldecode($_GET["search_ligne"]);
$sel = ereg_replace("\.","",$sel);
$sel = ereg_replace(" ","",$sel);
$sql .= " AND la.numero_ligne LIKE '%".$sel."%'";
}
if ($_GET["search_client"])
{
$sel =urldecode($_GET["search_client"]);
$sql .= " AND s.nom LIKE '%".$sel."%'";
}
if (strlen($_GET["statut"]))
{
$sql .= " AND la.statut = ".$_GET["statut"];
}
$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;
$urladd= "&amp;statut=".$_GET["statut"];
print_barre_liste("Liaisons ADSL", $page, "liste.php", $urladd, $sortfield, $sortorder, '', $num);
print"\n<!-- debut table -->\n";
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print_liste_field_titre("Ligne","liste.php","l.ligne");
print_liste_field_titre("Client","liste.php","s.nom");
print '<td>Type</td>';
print '<td align="center">Statut</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="liste.php" method="GET">';
print '<td><input type="text" name="search_ligne" value="'. $_GET["search_ligne"].'" size="10"></td>';
print '<td><input type="text" name="search_client" value="'. $_GET["search_client"].'" size="10"></td>';
print '<td>&nbsp;</td>';
print '<td><input type="submit" value="Chercher"></td>';
print '</form>';
print '</tr>';
$var=True;
$ligne = new LigneAdsl($db);
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<img src="./statut'.$obj->statut.'.png">&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/adsl/fiche.php?id='.$obj->rowid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="fiche.php?id='.$obj->rowid.'">'.dol_print_phone($obj->numero_ligne,0,0,true)."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->socid.'">'.img_object($langs->trans("Fiche Compta"),"bill")."</a> ";
print '&nbsp;<a href="'.DOL_URL_ROOT.'/telephonie/comm/fiche.php?socid='.$obj->socid.'">'.$obj->nom.'</a></td>';
print '<td>'.$obj->intitule.'</td>';
print '<td align="center">'.$ligne->statuts[$obj->statut]."</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free($resql);
}
else
{
print $db->error($resql) . ' ' . $sql;
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,51 +0,0 @@
<?PHP
/* Copyright (C) 2005-2007 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(DOL_DOCUMENT_ROOT."/telephonie/adsl/ligneadsl.class.php");
$user->getrights('telephonie');
function llxHeader($head = "", $title="") {
global $user, $conf;
/*
*
*
*/
top_menu($head, $title);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/telephonie/adsl/index.php", "Liens xDSL");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/adsl/liste.php", "Liste");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/adsl/fiche.php?action=create", "Nouvelle liaison");
$menu->add(DOL_URL_ROOT."/telephonie/index.php", "Telephonie");
if ($user->rights->telephonie->configurer)
$menu->add(DOL_URL_ROOT."/telephonie/config/xdsl_product.php", "Configuration");
left_menu($menu->liste);
}
?>

View File

@ -1,129 +0,0 @@
<?PHP
/* Copyright (C) 2005-2007 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 ProductXdsl {
var $db;
var $id;
/**
* Constructeur de la classe
*
*/
function ProductXdsl($DB, $id=0, $user=0)
{
global $config;
$this->id = $id;
$this->db = $DB;
$this->error_message = '';
return 1;
}
/**
* Cree le product dans la base de donnees
*
*/
function Create($user)
{
if ($this->prodid > 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_adsl_type";
$sql .= " (fk_product, commande_active, intitule)";
$sql .= " VALUES (";
$sql .= " $this->prodid,1,'".addslashes($this->intitule)."')";
$resql = $this->db->query($sql);
if ( $resql )
{
$this->id = $this->db->last_insert_id($resql);
return 0;
}
else
{
dol_syslog("ProductXdsl::Create Error -3");
return -3;
}
}
else
{
dol_syslog("ProductXdsl::Create Error -2");
return -2;
}
}
/**
*
*
*/
function SwitchCommandeActive($id)
{
$sql= "UPDATE ".MAIN_DB_PREFIX."telephonie_adsl_type as t";
$sql.= " SET commande_active = abs(commande_active -1) WHERE t.rowid =".$id.";";
$resql=$this->db->query($sql);
if ($resql)
{
return 0;
}
else
{
dol_syslog("ProductXdsl::SwithCommandeActive Error -20", LOG_ERR);
return -20;
}
}
/**
* Retourne la liste des produits
*
*/
function ListArray()
{
$arr = array();
$sql = "SELECT t.rowid, t.intitule, t.commande_active";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p,".MAIN_DB_PREFIX."telephonie_adsl_type as t";
$sql.= " WHERE p.rowid=t.fk_product;";
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$arr[$obj->rowid]['rowid'] = $obj->rowid;
$arr[$obj->rowid]['intitule'] = stripslashes($obj->intitule);
$arr[$obj->rowid]['commande_active'] = $obj->commande_active;
}
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
}
return $arr;
}
}
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 B

View File

@ -1,111 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
/*
* Sécurité accés client
*/
if (!$user->rights->telephonie->ca->lire) accessforbidden();
llxHeader('','Telephonie - CA par client');
/*
*
*
*
*/
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="50%" valign="top">';
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($sortorder == "") $sortorder="DESC";
if ($sortfield == "") $sortfield="ca";
$sql = "SELECT nom, ca, gain, cout, marge, fk_client_comm";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_client_stats";
$sql .= " , " .MAIN_DB_PREFIX."societe";
$sql .= " WHERE rowid = fk_client_comm";
$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("CA cumulé par client", $page, "gain.php", $urladd, $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Client</td><td align="right">Chiffre d\'affaire</td>';
print '<td align="right">Gain</td>';
print_liste_field_titre("Marge","gain.php","marge",'','','align="right"');
print "<td>&nbsp;</td></tr>\n";
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$row = $db->fetch_row($resql);
$var=!$var;
$marge = $row[4];
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/stats.php?id='.$row[5].'">'.$row[0]."</a></td>\n";
print '<td align="right">'.price($row[1])." HT</td>\n";
print '<td align="right">'.price($row[2])." HT</td>\n";
print '<td align="right">'.number_format(round($marge), 2, '.', ' ')." %</td>\n";
if ($marge < 0)
{
print '<td align="center">!!</td>';
}
else
{
print '<td>&nbsp;</td>';
}
print "</tr>\n";
$i++;
}
print "</table>";
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
//print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=telephoniegraph&file=ca/gain_moyen_par_client.png" alt="Gain moyen par client"><br /><br />';
print '</td></tr>';
print '</table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,99 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
if (!$user->rights->telephonie->ca->lire)
accessforbidden();
llxHeader('','Telephonie');
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
/*
* Mode Liste
*
*
*
*/
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="50%" valign="top">';
$sql = "SELECT date, sum(cout_vente), sum(gain), count(ligne)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture";
$sql .= " GROUP BY date DESC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$ligne = new LigneTel($db);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Mois</td><td align="right">Chiffre d\'affaire</td>';
print '<td align="right">Gain</td><td align="right">Marge</td>';
print "</tr>\n";
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$row = $db->fetch_row($resql);
$var=!$var;
print "<tr $bc[$var]>";
print "<td>".substr($row[0],5,2)." ".substr($row[0],0,4)."</td>\n";
print '<td align="right">'.price($row[1])." HT</td>\n";
print '<td align="right">'.price($row[2])." HT</td>\n";
print '<td align="right">'.number_format(round(($row[2]/$row[1])*100,2),2)." %</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free($resql);
}
else
{
dol_print_error($db);
}
print '</td><td valign="top" width="50%">'."\n";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=telephoniegraph&file=ca/ca.mensuel.png" alt="CA Mensuel"><br /><br />';
print "\n</td></tr>\n";
print '</table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,70 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
$user->getrights('telephonie');
function llxHeader($head = "", $title="") {
global $user, $conf;
top_menu($head, $title);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/telephonie/index.php", "Telephonie");
if (TELEPHONIE_MODULE_SIMULATION == 1)
{
$menu->add(DOL_URL_ROOT."/telephonie/simulation/fiche.php", "Simulation");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/simulation/fiche.php?action=create", "Nouvelle");
}
$menu->add(DOL_URL_ROOT."/telephonie/client/index.php", "Clients");
$menu->add(DOL_URL_ROOT."/telephonie/contrat/", "Contrats");
$menu->add(DOL_URL_ROOT."/telephonie/ligne/index.php", "Lignes");
if ($user->rights->telephonie->ligne_commander)
$menu->add(DOL_URL_ROOT."/telephonie/ligne/commande/", "Commande");
if ($user->rights->telephonie->stats->lire)
$menu->add(DOL_URL_ROOT."/telephonie/stats/", "Statistiques");
$menu->add(DOL_URL_ROOT."/telephonie/facture/", "Factures");
$menu->add(DOL_URL_ROOT."/telephonie/tarifs/", "Tarifs");
if ($user->rights->telephonie->fournisseur->lire)
$menu->add(DOL_URL_ROOT."/telephonie/fournisseur/", "Fournisseurs");
if ($user->rights->telephonie->ca->lire)
{
$menu->add(DOL_URL_ROOT."/telephonie/ca/", "Chiffre d'affaire");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/ca/ratiofourn.php", "Ratio fournisseur");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/ca/gain.php", "Gain par client");
}
left_menu($menu->liste);
}
?>

View File

@ -1,95 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
/*
* Sécurité accés client
*/
if (!$user->rights->telephonie->ca->lire) accessforbidden();
llxHeader('','Telephonie - Ratio fournisseur');
/*
*
*
*
*/
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="50%" valign="top">';
$page = $_GET["page"];
$offset = $conf->liste_limit * $page ;
$sql = "SELECT s.nom, af.mois, af.achat, af.vente";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_analyse_fournisseur as af";
$sql .= " , " .MAIN_DB_PREFIX."telephonie_fournisseur as s";
$sql .= " WHERE s.rowid = af.fk_fournisseur";
$sql .= " ORDER BY mois DESC " . $db->plimit($conf->liste_limit+1, $offset);
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print_barre_liste("Ratio fournisseur", $page, "ratiofourn.php", $urladd, $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Mois</td><td>Fournisseur</td><td align="right">Achat</td>';
print '<td align="right">Revente</td>';
print "</tr>\n";
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$row = $db->fetch_row($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.strftime ("%B %Y",mktime(12,0,0,substr($row[1],-2),1,substr($row[1],0,4)))."</td>\n";
print "<td>".$row[0]."</td>\n";
print '<td align="right">'.price($row[2])." HT</td>\n";
print '<td align="right">'.price($row[3])." HT</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
//print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=telephoniegraph&file=ca/gain_moyen_par_client.png" alt="Gain moyen par client"><br /><br />';
print '</td></tr>';
print '</table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,201 +0,0 @@
<?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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
$mesg = '';
llxHeader("","","Fiche client");
if ($cancel == $langs->trans("Cancel"))
{
$action = '';
}
/*
* Affichage
*
*/
if ($_GET["id"])
{
$soc = new Societe($db);
$result = $soc->fetch($_GET["id"], $user);
if ($_GET["action"] == 'add')
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_societe_commentaire";
$sql .= " (fk_soc, fk_user, commentaire,datec)";
$sql .= " VALUES ('".$soc->id."','".$user->id."','".$_POST["comment"]."',now());";
$db->query($sql);
}
if ($_GET["action"] == 'del')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_societe_commentaire";
$sql .= " WHERE rowid = '".$_GET["commid"]."'";
$sql .= " AND fk_user = '".$user->id."';";
$db->query($sql);
}
if (!$soc->perm_read)
{
print "Lecture non authoris<69>e";
}
if ( $result == 1 && $soc->perm_read)
{
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/fiche.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Contrats");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/lignes.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Lignes");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/factures.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Factures");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/stats.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Stats");
$h++;
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."telephonie_tarif_client";
$sql .= " WHERE fk_client = '".$soc->id."';";
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$db->free($resql);
}
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/tarifs.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Tarifs (".$row[0].")");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/commentaires.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Commentaires");
$hselected = $h;
$h++;
if ($soc->perm_perms)
{
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/permissions.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Permissions");
$h++;
}
dol_fiche_head($head, $hselected, 'Client : '.$soc->nom);
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td>'.$soc->nom.'</td><td>'.$langs->trans('Code client').'</td><td>'.$soc->code_client.'</td></tr>';
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->adresse)."<br>".$soc->cp." ".$soc->ville." ".$soc->pays."</td></tr>";
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id).'</td>';
print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($soc->fax,$soc->pays_code,0,$soc->id).'</td></tr>';
print '<tr><td><a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'">'.img_edit() ."</a>&nbsp;";
print $langs->trans('RIB').'</td><td colspan="3">';
print $soc->display_rib();
print '</td></tr>';
print '</table><br />';
print '<form method="POST" action="commentaires.php?id='.$soc->id.'&action=add">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="15%" valign="center">Nouveau<br>commentaire';
print '</td><td><textarea cols="60" rows="3" name="comment"></textarea></td>';
print '<td><input type="submit" value="Ajouter"></td></tr>';
print "</table></form><br />";
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
/* Commentaires */
$sql = "SELECT c.commentaire, u.firstname, u.name, u.login, c.rowid, c.fk_user";
$sql .= " , ".$db->pdate("c.datec") ." as datec";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_commentaire as c";
$sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE fk_soc = ".$soc->id;
$sql .= " AND c.fk_user = u.rowid";
$sql .= " ORDER BY c.datec DESC";
$resql = $db->query($sql);
if ($resql)
{
print '<tr class="liste_titre"><td width="15%" valign="center">Date';
print '</td><td>Commentaire</td><td align="center">Auteur</td><td>&nbsp;</td>';
print "</tr>\n";
while ($obj = $db->fetch_object($resql))
{
print "<tr $bc[$var]><td>".strftime("%d/%m/%y %H:%M",$obj->datec);
print "</td>\n";
print '<td>'.nl2br(stripslashes($obj->commentaire))."</td>\n";
print '<td align="center">'.$obj->login."</td>\n";
print '<td align="center">&nbsp;';
if ($obj->fk_user == $user->id)
{
print '<a href="commentaires.php?id='.$soc->id.'&amp;commid='.$obj->rowid.'&amp;action=del">';
print img_delete().'</a>';
}
print "</td></tr>\n";
$var=!$var;
}
$db->free($resql);
}
else
{
print $sql;
}
print "</table>";
}
}
else
{
print "Error";
}
print '</div>';
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
/*
print "\n<br>\n<div class=\"tabsAction\">\n";
print "<a class=\"butAction\" href=\"commentaires.php?action=add&amp;id=$soc->id\">".$langs->trans("Ajouter un commentaire")."</a>";
print "</div>";
*/
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,152 +0,0 @@
<?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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
llxHeader('','Telephonie - Clients - Contacts');
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
if ($sortorder == "") {
$sortorder="ASC";
}
if ($sortfield == "") {
$sortfield="s.nom";
}
/*
* Recherche
*
*
*/
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*/
$sql = "SELECT distinct cont.email, cont.rowid, cont.name, cont.firstname, s.nom, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ",".MAIN_DB_PREFIX."societe_perms as sp";
$sql .= ",".MAIN_DB_PREFIX."telephonie_contrat_contact_facture as cf";
$sql .= ",".MAIN_DB_PREFIX."socpeople as cont";
$sql .= " WHERE cont.fk_soc = s.rowid ";
$sql .= " AND cf.fk_contact = cont.rowid";
$sql .= " AND s.rowid = sp.fk_soc";
$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1";
if ($_GET["search_client"])
{
$sel = urldecode($_GET["search_client"]);
$sql .= " AND s.nom LIKE '%".$sel."%'";
}
if ($_GET["search_email"])
{
$sel = urldecode($_GET["search_email"]);
$sql .= " AND cont.email LIKE '%".$sel."%'";
}
//$sql .= " GROUP BY s.rowid";
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0;
$urladd= "&amp;statut=".$_GET["statut"];
print_barre_liste("Clients", $page, "liste.php", $urladd, $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print_liste_field_titre("Client","contacts.php","s.nom","","",' width="50%"');
print '<td width="25%">Prénom Nom</td>';
print_liste_field_titre("Email","contacts.php","cont.email","","",' width="50%"');
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="contacts.php" method="GET">';
print '<td><input type="text" name="search_client" value="'. $_GET["search_client"].'" size="12"></td>';
print '<td>&nbsp;</td>';
print '<td><input type="text" name="search_email" value="'. $_GET["search_email"].'" size="12">';
print '&nbsp;<input type="submit" class="button" value="'.$langs->trans("Search").'"></td>';
print '</form>';
print '</tr>';
$var=True;
$ligne = new LigneTel($db);
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.$obj->nom.'</a></td>';
print '<td>'.$obj->firstname.' '.$obj->name."</td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->rowid.'">';
print $obj->email."</a></td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,732 +0,0 @@
<?php
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 <EFBFBD>ric Seigne <eric.seigne@ryxeo.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$
*/
/**
\file htdocs/telephonie/client/facture.php
\ingroup telephonie/facture
\brief Page de visualisation d'une facture
\version $Revision$
*/
require("./pre.inc.php");
$user->getrights('facture');
$user->getrights('banque');
$langs->load("bills");
$warning_delay=31*24*60*60; // Delai affichage warning retard (si retard paiement facture > delai)
require_once DOL_DOCUMENT_ROOT."/facture.class.php";
require_once DOL_DOCUMENT_ROOT."/paiement.class.php";
require_once DOL_DOCUMENT_ROOT."/lib/CMailFile.class.php";
include_once DOL_DOCUMENT_ROOT."/contact.class.php";
include_once DOL_DOCUMENT_ROOT."/actioncomm.class.php";
if ($_GET["socid"]) { $socid=$_GET["socid"]; }
if (isset($_GET["msg"])) { $msg=urldecode($_GET["msg"]); }
// S<>curit<69> acc<63>s client
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
/*
* Action envoi de mail
*/
if ($_POST["action"] == 'send' || $_POST["action"] == 'relance')
{
$langs->load("mails");
$fac = new Facture($db,"",$_POST["facid"]);
if ( $fac->fetch($_POST["facid"]) )
{
$facref = dol_sanitizeFileName($fac->ref);
$file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf";
if (is_readable($file))
{
$soc = new Societe($db, $fac->socid);
if ($_POST["sendto"]) {
// Le destinataire a <20>t<EFBFBD> fourni via le champ libre
$sendto = $_POST["sendto"];
$sendtoid = 0;
}
elseif ($_POST["receiver"]) {
// Le destinataire a <20>t<EFBFBD> fourni via la liste d<>roulante
$sendto = $soc->contact_get_email($_POST["receiver"]);
$sendtoid = $_POST["receiver"];
}
if (strlen($sendto))
{
$from = $_POST["fromname"] . " <" . $_POST["frommail"] .">";
$replyto = $_POST["replytoname"]. " <" . $_POST["replytomail"].">";
$message = $_POST["message"];
if ($_POST["action"] == 'send') {
$subject = $langs->trans("Bill")." $fac->ref";
$actiontypeid=9;
$actionmsg ="Mail envoy<6F> par ".$from." <20> ".$sendto.".\n";
if ($message) {
$actionmsg.="Texte utilis<69> dans le corps du message:\n";
$actionmsg.=$message;
}
$actionmsg2="Envoi facture par mail";
}
if ($_POST["action"] == 'relance') {
$subject = "Relance facture $fac->ref";
$actiontypeid=9;
$actionmsg="Mail envoy<6F> par ".$from." <20> ".$sendto.".\n";
if ($message) {
$actionmsg.="Texte utilis<69> dans le corps du message:\n";
$actionmsg.=$message;
}
$actionmsg2="Relance facture par mail";
}
$filepath[0] = $file;
$filename[0] = $fac->ref.".pdf";
$mimetype[0] = "application/pdf";
$filepath[1] = $_FILES['addedfile']['tmp_name'];
$filename[1] = $_FILES['addedfile']['name'];
$mimetype[1] = $_FILES['addedfile']['type'];
$dir = $conf->facture->dir_output . "/" . $fac->ref . "/";
$handle=opendir($dir);
$ifi = 2;
while (($dfile = readdir($handle))!==false)
{
if (is_readable($dir.$dfile) && substr($dfile, -10) == 'detail.pdf')
{
$filepath[$ifi] = $conf->facture->dir_output . "/" . $fac->ref . "/" . $dfile;
$filename[$ifi] = $dfile;
$mimetype[$ifi] = "application/pdf";
$ifi++;
}
}
// Envoi de la facture
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc);
if ($mailfile->sendfile())
{
$msg='<div class="ok">'.$langs->trans("MailSuccessfulySent",$from,$sendto).'.</div>';
// Renvoie sur la fiche
Header("Location: facture.php?facid=".$fac->id."&msg=".urlencode($msg));
exit;
}
else
{
$msg='<div class="error">'.$langs->trans("ErrorFailedToSendMail",$from,$sendto).' !</div>';
}
}
else
{
$msg='<div class="error">'.$langs->trans("ErrorMailRecipientIsEmpty").'</div>';
dol_syslog("Le mail du destinataire est vide");
}
}
else
{
dol_syslog("Impossible de lire :".$file);
}
}
else
{
dol_syslog("Impossible de lire les donn<6E>es de la facture. Le fichier facture n'a peut-<2D>tre pas <20>t<EFBFBD> g<>n<EFBFBD>r<EFBFBD>.");
}
}
llxHeader('',$langs->trans("Bill"),'Facture');
$html = new Form($db);
if ($_GET["facid"] > 0)
{
if ($msg) print "$msg<br>";
$fac = New Facture($db);
if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0)
{
$soc = new Societe($db, $fac->socid);
$soc->fetch($fac->socid, $user);
if (!$soc->perm_read)
{
print "Lecture non authoris<69>e";
}
if ($soc->perm_read)
{
$author = new User($db);
$author->id = $fac->user_author;
$author->fetch();
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$soc->id;
$head[$h][1] = $langs->trans("Fiche client");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/client/factures.php?id='.$soc->id;
$head[$h][1] = $langs->trans("Factures");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/client/facture.php?facid='.$fac->id;
$head[$h][1] = $langs->trans("CardBill");
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, $langs->trans("Bill")." : $fac->ref");
/*
* Facture
*/
print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans("Company").'</td>';
print '<td colspan="3">';
print '<b><a href="fiche.php?id='.$soc->id.'">'.$soc->nom.'</a></b></td>';
print "<td>Conditions de r<>glement</td><td>" . $fac->cond_reglement ."</td></tr>";
print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td colspan=\"3\">".dol_print_date($fac->date,"dayhourtext")."</td>\n";
print '<td>'.$langs->trans("DateMaxPayment").'</td><td>' . dol_print_date($fac->date_lim_reglement,"dayhourtext");
print "</td></tr>";
print '<tr>';
// Projet
if ($conf->projet->enabled)
{
$langs->load("projects");
print '<td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans("Project");
print '</td>';
if ($_GET["action"] != "classer") print '<td align="right"></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($_GET["action"] == "classer")
{
$html->form_project("facture.php?facid=$fac->id",$fac->fk_soc,$fac->projetid,"projetid");
}
else
{
$html->form_project("facture.php?facid=$fac->id",$fac->fk_soc,$fac->projetid,"none");
}
print "</td>";
} else {
print '<td height=\"10\">&nbsp;</td><td colspan="3">&nbsp;</td>';
}
print '<td rowspan="8" colspan="2" valign="top">';
/*
* Paiements
*/
print $langs->trans("Payments").' :<br>';
$sql = "SELECT ".$db->pdate("datep")." as dp, pf.amount,";
$sql.= " c.libelle as paiement_type, p.num_paiement, p.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement_facture as pf";
$sql.= " WHERE pf.fk_facture = ".$fac->id." AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid";
$sql.= " ORDER BY dp DESC";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0; $total = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Amount").'</td><td>&nbsp;</td></tr>';
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]><td>";
print "&nbsp;".strftime("%d %B %Y",$objp->dp)."</td>\n";
print "<td>$objp->paiement_type $objp->num_paiement</td>\n";
print '<td align="right">'.price($objp->amount)."</td><td>".$langs->trans("Currency".$conf->monnaie)."</td>\n";
print "</tr>";
$totalpaye += $objp->amount;
$i++;
}
if ($fac->paye == 0)
{
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\"><b>".price($totalpaye)."</b></td><td>".$langs->trans("Currency".$conf->monnaie)."</td></tr>\n";
print "<tr><td colspan=\"2\" align=\"right\">Factur<75> :</td><td align=\"right\" style=\"border: 1px solid;\">".price($fac->total_ttc)."</td><td>".$langs->trans("Currency".$conf->monnaie)."</td></tr>\n";
$resteapayer = $fac->total_ttc - $totalpaye;
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
print "<td align=\"right\" style=\"border: 1px solid;\" bgcolor=\"#f0f0f0\"><b>".price($resteapayer)."</b></td><td>".$langs->trans("Currency".$conf->monnaie)."</td></tr>\n";
}
print "</table>";
$db->free($result);
} else {
dol_print_error($db);
}
print "</td></tr>";
print "<tr><td height=\"10\">".$langs->trans("Author")."</td><td colspan=\"3\">$author->fullname</td></tr>";
print '<tr><td height=\"10\">'.$langs->trans("GlobalDiscount").'</td>';
if ($fac->brouillon == 1 && $user->rights->facture->creer)
{
print '<form action="facture.php?facid='.$fac->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setremise">';
print '<td colspan="3"><input type="text" name="remise" size="3" value="'.$fac->remise_percent.'">% ';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
print '</form>';
}
else
{
print '<td colspan="3">'.$fac->remise_percent.'%</td>';
}
print '</tr>';
print '<tr><td height=\"10\">'.$langs->trans("AmountHT").'</td>';
print '<td align="right" colspan="2"><b>'.price($fac->total_ht).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td height=\"10\">'.$langs->trans("VAT").'</td><td align="right" colspan="2">'.price($fac->total_tva).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td height=\"10\">'.$langs->trans("AmountTTC").'</td><td align="right" colspan="2">'.price($fac->total_ttc).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td height=\"10\">'.$langs->trans("Status").'</td><td align="left" colspan="3">'.($fac->getLibStatut()).'</td></tr>';
if ($fac->note)
{
print '<tr><td colspan="4">'.$langs->trans("Note").' : '.nl2br($fac->note)."</td></tr>";
}
else {
print '<tr><td colspan="4">&nbsp;</td></tr>';
}
print "</table><br>";
/*
* Lignes de factures
*
*/
$sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux";
$sql .= " , l.remise_percent, l.subprice,";
$sql .= $db->pdate("l.date_start")." as date_start";
$sql .= " , ".$db->pdate("l.date_end")." as date_end, ";
$sql .= " p.fk_product_type";
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l ";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON l.fk_product=p.rowid";
$sql .= " WHERE l.fk_facture = ".$fac->id;
$sql .= " ORDER BY l.rang ASC, l.rowid";
$resql = $db->query($sql);
if ($resql)
{
$num_lignes = $db->num_rows($resql);
$i = 0; $total = 0;
print '<table class="noborder" width="100%">';
if ($num_lignes)
{
print "<tr class=\"liste_titre\">";
print '<td>'.$langs->trans("Description").'</td>';
print '<td width="50" align="right">'.$langs->trans("VAT").'</td>';
print '<td width="80" align="right">'.$langs->trans("PriceUHT").'</td>';
print '<td width="50" align="right">'.$langs->trans("Qty").'</td>';
print '<td width="50" align="right">'.$langs->trans("Discount").'</td>';
print '<td width="80" align="right">'.$langs->trans("AmountHT").'</td>';
print '<td colspan="3">&nbsp;</td>';
print "</tr>\n";
}
$var=True;
while ($i < $num_lignes)
{
$objp = $db->fetch_object($resql);
$var=!$var;
// Update ligne de facture
if ($_GET["action"] != 'editline' || $_GET["rowid"] != $objp->rowid)
{
print "<tr $bc[$var]>";
if ($objp->fk_product > 0)
{
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
if ($objp->fk_product_type==1) print img_object($langs->trans("ShowService"),"service");
else print img_object($langs->trans("ShowProduct"),"product");
print ' '.stripslashes(nl2br($objp->description)).'</a>';
if ($objp->date_start && $objp->date_end) { print " (Du ".dol_print_date($objp->date_start)." au ".dol_print_date($objp->date_end).")"; }
if ($objp->date_start && ! $objp->date_end) { print " (A partir du ".dol_print_date($objp->date_start).")"; }
if (! $objp->date_start && $objp->date_end) { print " (Jusqu'au ".dol_print_date($objp->date_end).")"; }
print '</td>';
}
else
{
print "<td>".stripslashes(nl2br($objp->description));
if ($objp->date_start && $objp->date_end) { print " (Du ".dol_print_date($objp->date_start)." au ".dol_print_date($objp->date_end).")"; }
if ($objp->date_start && ! $objp->date_end) { print " (A partir du ".dol_print_date($objp->date_start).")"; }
if (! $objp->date_start && $objp->date_end) { print " (Jusqu'au ".dol_print_date($objp->date_end).")"; }
print "</td>\n";
}
print '<td align="right">'.$objp->tva_taux.'%</td>';
print '<td align="right">'.price($objp->subprice)."</td>\n";
print '<td align="right">'.$objp->qty.'</td>';
if ($objp->remise_percent > 0)
{
print '<td align="right">'.$objp->remise_percent."%</td>\n";
}
else
{
print '<td>&nbsp;</td>';
}
print '<td align="right">'.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."</td>\n";
// Icone d'edition et suppression
if ($fac->statut == 0 && $user->rights->facture->creer)
{
print '<td align="right"><a href="facture.php?facid='.$fac->id.'&amp;action=editline&amp;rowid='.$objp->rowid.'">';
print img_edit();
print '</a></td>';
print '<td align="right"><a href="facture.php?facid='.$fac->id.'&amp;action=deleteline&amp;rowid='.$objp->rowid.'">';
print img_delete();
print '</a></td>';
print '<td align="right">';
if ($i > 0)
{
print '<a href="facture.php?facid='.$fac->id.'&amp;action=up&amp;rowid='.$objp->rowid.'">';
print img_up();
print '</a>';
}
if ($i < $num_lignes-1)
{
print '<a href="facture.php?facid='.$fac->id.'&amp;action=down&amp;rowid='.$objp->rowid.'">';
print img_down();
print '</a></td>';
}
}
else
{
print '<td colspan="3">&nbsp;</td>';
}
print "</tr>";
}
$total = $total + ($objp->qty * $objp->price);
$i++;
}
$db->free($resql);
}
else
{
dol_print_error($db);
}
/*
* Ajouter une ligne
*/
print "</table>\n";
print "</div>\n";
/*
* Boutons actions
*/
if ($user->societe_id == 0 && $_GET["action"] <> 'valid' && $_GET["action"] <> 'editline')
{
print "<div class=\"tabsAction\">\n";
// Envoyer
if ($fac->statut == 1 && $user->rights->facture->envoyer)
{
print " <a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?facid=$fac->id&amp;action=presend&amp;mode=init\">".$langs->trans("Send")."</a>\n";
}
// Envoyer une relance
/*
if ($fac->statut == 1 && price($resteapayer) > 0 && $user->rights->facture->envoyer)
{
print " <a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?facid=$fac->id&amp;action=prerelance&amp;mode=init\">".$langs->trans("SendRemind")."</a>\n";
}
*/
print "</div>\n";
}
print '<table width="100%"><tr><td width="50%" valign="top">';
/*
* Documents g<EFBFBD>n<EFBFBD>r<EFBFBD>s
* Le fichier de facture d<EFBFBD>taill<EFBFBD>e est de la forme
* REFFACTURE-XXXXXX-detail.pdf ou XXXXX est une forme diverse
*/
$facref = dol_sanitizeFileName($fac->ref);
$file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf";
$relativepath = "${facref}/${facref}.pdf";
$var=true;
if (file_exists($file))
{
print "<br>\n";
print_titre("Documents");
print '<table class="border" width="100%">';
print "<tr $bc[$var]><td>".$langs->trans("Bill")." PDF</td>";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepath).'">'.$fac->ref.'.pdf</a></td>';
print '<td align="right">'.filesize($file). ' bytes</td>';
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>';
print '</tr>';
$dir = $conf->facture->dir_output . "/" . $facref . "/";
$handle=opendir($dir);
while (($file = readdir($handle))!==false)
{
if (is_readable($dir.$file) && substr($file, -10) == 'detail.pdf')
{
print "<tr $bc[$var]><td>Facture d<>taill<6C>e</td>";
$relativepathdetail = "${facref}/$file";
print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=facture&file='.urlencode($relativepathdetail).'">'.$file.'</a></td>';
print '<td align="right">'.filesize($dir.$file). ' bytes</td>';
print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($dir.$file)).'</td>';
print '</tr>';
}
}
print "</table>\n";
}
/*
* Propales
*/
$sql = "SELECT ".$db->pdate("p.datep")." as dp, p.price, p.ref, p.rowid as propalid";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $fac->id";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
$i = 0; $total = 0;
print "<br>";
print_titre($langs->trans("RelatedCommercialProposals"));
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Date").'</td>';
print '<td align="right">'.$langs->trans("Price").'</td>';
print "</tr>\n";
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="propal.php?propalid='.$objp->propalid.'">'.img_object($langs->trans("ShowPropal"),"propal").' '.$objp->ref.'</a></td>';
print "<td>".dol_print_date($objp->dp)."</td>\n";
print '<td align="right">'.price($objp->price).'</td>';
print "</tr>";
$total = $total + $objp->price;
$i++;
}
print "<tr class=\"liste_total\"><td>&nbsp;</td><td align=\"left\">".$langs->trans("TotalHT")."</td><td align=\"right\">".price($total)."</td></tr>\n";
print "</table>";
}
}
else
{
dol_print_error($db);
}
print '</td><td valign="top" width="50%">';
/*
* Liste des actions propres <EFBFBD> la facture
*/
$sql = "SELECT id, ".$db->pdate("a.datep")." as da, a.label, a.note";
$sql .= ", u.login";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."user as u ";
$sql .= " WHERE a.fk_user_author = u.rowid ";
$sql .= " AND a.fk_action in (9,10) ";
$sql .= " AND a.fk_soc = ".$fac->socid ;
$sql .= " AND a.fk_facture = ".$fac->id;
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
print "<br>\n";
print_titre($langs->trans("ActionsOnBill"));
$i = 0; $total = 0;
print '<table class="border" width="100%">';
print '<tr '.$bc[$var].'><td>'.$langs->trans("Ref").'</td><td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Action").'</td><td>'.$langs->trans("By").'</td></tr>';
print "\n";
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.img_object($langs->trans("ShowTask"),"task").' '.$objp->id.'</td>';
print '<td>'.dol_print_date($objp->da)."</td>\n";
print '<td>'.stripslashes($objp->label).'</td>';
print '<td>'.$objp->login.'</td>';
print "</tr>\n";
$i++;
}
print "</table>\n";
}
}
else
{
dol_print_error($db);
}
print "</td></tr></table>";
/*
* Affiche formulaire mail
*/
if ($_GET["action"] == 'presend')
{
print '<br>';
print_titre($langs->trans("SendBillByMail"));
// Cree l'objet formulaire mail
include_once(DOL_DOCUMENT_ROOT."/html.formmail.class.php");
$formmail = new FormMail($db);
$formmail->fromname = $user->fullname;
$formmail->frommail = $user->email;
$formmail->withfrom=1;
$formmail->withto=empty($_POST["sendto"])?1:$_POST["sendto"];
$formmail->withtosocid=$soc->id;
$formmail->withtocc=1;
$formmail->withtoccsocid=0;
$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
$formmail->withtocccsocid=0;
$formmail->withtopic=$langs->trans("SendBillRef","__FACREF__");
$formmail->withfile=1;
$formmail->withbody=1;
// Tableau des substitutions
$formmail->substit["__FACREF__"]=$fac->ref;
// Tableau des param<61>tres compl<70>mentaires du post
$formmail->param["action"]="send";
$formmail->param["models"]="facture_send";
$formmail->param["facid"]=$fac->id;
$formmail->param["returnurl"]=DOL_URL_ROOT."/telephonie/client/facture.php?facid=$fac->id";
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
{
$formmail->clear_attached_files();
}
$formmail->show_form();
print '<br>';
}
if ($_GET["action"] == 'prerelance')
{
print '<br>';
print_titre($langs->trans("SendReminderBillByMail"));
$liste[0]="&nbsp;";
foreach ($soc->contact_email_array() as $key=>$value)
{
$liste[$key]=$value;
}
// Cr<43><72> l'objet formulaire mail
include_once("../html.formmail.class.php");
$formmail = new FormMail($db);
$formmail->fromname = $user->fullname;
$formmail->frommail = $user->email;
$formmail->withfrom=1;
$formmail->withto=$liste;
$formmail->withtocc=1;
$formmail->withtopic=$langs->trans("SendReminderBillRef","__FACREF__");
$formmail->withfile=1;
$formmail->withbody=1;
// Tableau des substitutions
$formmail->substit["__FACREF__"]=$fac->ref;
// Tableau des param<61>tres compl<70>mentaires
$formmail->param["action"]="relance";
$formmail->param["models"]="facture_relance";
$formmail->param["facid"]=$fac->id;
$formmail->param["returnurl"]=DOL_URL_ROOT."/compta/facture.php?facid=$fac->id";
// Init list of files
if (! empty($_REQUEST["mode"]) && $_REQUEST["mode"]=='init')
{
$formmail->clear_attached_files();
}
$formmail->show_form();
print '<br>';
}
}
}
else
{
/* Facture non trouv<75>e */
print $langs->trans("ErrorBillNotFound",$_GET["facid"]);
}
}
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -1,176 +0,0 @@
<?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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
llxHeader("","T<EFBFBD>l<EFBFBD>phonie - Factures client");
if ($cancel == $langs->trans("Cancel"))
{
$action = '';
}
/*
* Affichage
*
*/
if ($_GET["id"])
{
$soc = new Societe($db);
$result = $soc->fetch($_GET["id"], $user);
if (!$soc->perm_read)
{
print "Lecture non authoris<69>e";
}
if ( $result == 1 && $soc->perm_read)
{
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/fiche.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Contrats");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/lignes.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Lignes");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/factures.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Factures");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/stats.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Stats");
$h++;
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."telephonie_tarif_client";
$sql .= " WHERE fk_client = '".$soc->id."';";
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$db->free($resql);
}
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/tarifs.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Tarifs (".$row[0].")");
$h++;
dol_fiche_head($head, $hselected, 'Client : '.$soc->nom);
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td>'.$soc->nom.'</td><td>'.$langs->trans('Code Client').'</td><td>'.$soc->code_client.'</td></tr>';
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->adresse)."<br>".$soc->cp." ".$soc->ville." ".$soc->pays."</td></tr>";
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id).'</td>';
print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($soc->fax,$soc->pays_code,0,$soc->id).'</td></tr>';
print '</table><br />';
/*
* Factures
*
*/
if ($page == -1) { $page = 0 ; }
if ($sortorder == "") {
$sortorder="DESC";
}
if ($sortfield == "") {
$sortfield="f.date";
}
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
$sql = "SELECT f.rowid, f.date, sum(f.cout_vente) as cout_vente, f.fk_facture";
$sql .= " ,s.nom, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
$sql .= " WHERE s.rowid = l.fk_soc_facture AND l.rowid = f.fk_ligne";
$sql .= " AND s.rowid = ".$soc->id;
$sql .= " GROUP BY f.fk_facture";
$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 '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td align="center">Date</td><td align="right">Montant HT</td>';
print '<td align="center">Facture</td>';
print "</tr>\n";
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td align="center">'.$obj->date."</td>\n";
print '<td align="right">'.sprintf("%01.4f",$obj->cout_vente)."</td>\n";
print '<td align="center"><a href="facture.php?facid='.$obj->fk_facture.'">'.$obj->fk_facture."</a></td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
}
}
}
else
{
print "Error";
}
print '</div>';
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,242 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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("./pre.inc.php");
$mesg = '';
llxHeader("","","Fiche client");
if ($cancel == $langs->trans("Cancel"))
{
$action = '';
}
/*
* Affichage
*
*/
if ($_GET["id"])
{
$soc = new TelephonieClient($db);
$result = $soc->fetch($_GET["id"], $user);
if (!$soc->perm_read)
{
print "Lecture non authoris<69>e";
}
if ( $result == 1 && $soc->perm_read)
{
$soc->log_consult($user,'r');
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{
/* Commentaires */
$sql = "SELECT c.commentaire, ".$db->pdate("c.datec") ." as datec";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_commentaire as c";
$sql .= " WHERE fk_soc = ".$soc->id;
$sql .= " ORDER BY c.datec DESC";
$resql = $db->query($sql);
if ($resql)
{
$num_comments = $db->num_rows($resql);
$db->free($resql);
}
/* Fin Commentaires */
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/fiche.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Contrats");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/lignes.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Lignes");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/factures.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Factures");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/stats.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Stats");
$h++;
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."telephonie_tarif_client";
$sql .= " WHERE fk_client = '".$soc->id."';";
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$db->free($resql);
}
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/tarifs.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Tarifs (".$row[0].")");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/commentaires.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Commentaires");
if ($num_comments > 0)
{
$head[$h][1] = $langs->trans("Commentaires ($num_comments)");
}
$h++;
if ($soc->perm_perms)
{
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/permissions.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Permissions");
$h++;
}
dol_fiche_head($head, $hselected, 'Client : '.$soc->nom);
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td>'.$soc->nom.'</td><td>'.$langs->trans('Code client').'</td><td>'.$soc->code_client.'</td></tr>';
print '<tr><td valign="top">'.$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->adresse)."<br>".$soc->cp." ".$soc->ville." ".$soc->pays."</td></tr>";
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id).'</td>';
print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($soc->fax,$soc->pays_code,0,$soc->id).'</td></tr>';
print '<tr><td><a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'">'.img_edit() ."</a>&nbsp;";
print $langs->trans('RIB').'</td><td colspan="3">';
print $soc->display_rib();
print '</td></tr>';
print '</table><br />';
/* Commentaires */
$sql = "SELECT c.commentaire";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_commentaire as c";
$sql .= " WHERE c.fk_soc = ".$soc->id;
$sql .= " ORDER BY c.datec DESC LIMIT 2";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num > 0)
{
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>2 Derniers commentaires</td></tr>';
while ($obj = $db->fetch_object($resql))
{
$var=!$var;
print "<tr $bc[$var]><td>";
print stripslashes($obj->commentaire)."</td>\n";
print "</tr>\n";
}
print "</table><br />";
}
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
/* Contrats */
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
$sql = "SELECT count(l.rowid) as cc, c.rowid, c.ref, c.statut";
$sql .= ", ss.nom as agence, ss.code_client, ss.ville";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= " , ".MAIN_DB_PREFIX."societe as ss";
$sql .= " WHERE c.fk_client_comm = ".$soc->id;
$sql .= " AND c.fk_soc = ss.rowid ";
$sql .= " AND l.fk_contrat = c.rowid";
$sql .= " GROUP BY c.rowid";
$sql .= " ORDER BY ss.rowid ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ( $num > 0 )
{
$i = 0;
$ligne = new LigneTel($db);
print '<tr class="liste_titre"><td width="15%">Contrat';
print '</td><td colspan="3">Agence/Filiale</td><td align="center">Nb Lignes</td>';
print "</tr>\n";
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<img alt="" src="../contrat/statut'.$obj->statut.'.png">&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/contrat/fiche.php?id='.$obj->rowid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/contrat/fiche.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
print '<td>'.$obj->code_client."</td>\n";
print '<td>'.$obj->agence."</td>\n";
print '<td>'.$obj->ville."</td>\n";
print '<td align="center">'.$obj->cc."</td>\n";
print "</tr>\n";
$i++;
}
}
$db->free($resql);
}
else
{
print $sql;
}
print "</table>";
}
}
}
else
{
print "Error";
}
print '</div>';
print '<div id="version">$Revision$</div>';
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,237 +0,0 @@
<?PHP
/* Copyright (C) 2004 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("./pre.inc.php");
if (!$user->rights->telephonie->lire)
accessforbidden();
llxHeader('','Telephonie - Clients');
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
/*
* Mode Liste
*
*
*
*/
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="30%" valign="top">';
print '<form method="GET" action="'.DOL_URL_ROOT.'/telephonie/client/liste.php">';
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Recherche client</td>';
print "</tr>\n";
print "<tr $bc[1]>";
print '<td>Nom <input name="search_client" size="12"></td></tr>';
print '</table>';
print '<br />';
$sql = "SELECT distinct s.rowid as socid ";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.rowid = l.fk_client_comm ";
$sql .= " AND l.fk_commercial_suiv = ".$user->id;
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Clients</td><td valign="center">Nb</td>';
print "</tr>\n";
$var=True;
$row = $db->fetch_row($resql);
print "<tr $bc[$var]>";
print '<td><a href="my.php">Mes clients suivis</a></td>';
print "<td>".$num."</td>\n";
print "</tr>\n";
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '<br />';
/*
* Liste
*
*/
$sql = "SELECT s.rowid as socid, s.nom, max(sc.datec) as dam";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ",".MAIN_DB_PREFIX."societe_consult as sc";
$sql .= " WHERE s.rowid = sc.fk_soc";
$sql .= " AND sc.fk_user = ".$user->id;
$sql .= " GROUP BY s.rowid";
$sql .= " ORDER BY dam DESC LIMIT 10";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>'.min(10,$num).' dernières fiches clients consultées</td></tr>';
$var=True;
while ($obj = $db->fetch_object($resql))
{
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
$nom = $obj->nom;
if (strlen($obj->nom) > 33)
$nom = substr($obj->nom,0,30)."...";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.stripslashes($nom).'</a></td>';
print "</tr>\n";
$var=!$var;
}
print "</table>";
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td><td valign="top" width="70%" rowspan="3">';
/*
* Liste
*
*/
$sql = "SELECT s.rowid as socid, s.nom, count(l.ligne) as ligne";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
$sql .= ",".MAIN_DB_PREFIX."societe_perms as sp";
$sql .= " WHERE l.fk_client_comm = s.rowid ";
$sql .= " AND s.rowid = sp.fk_soc";
$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1";
$sql .= " GROUP BY s.rowid";
$sql .= " ORDER BY s.datec DESC LIMIT 10";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>'.min(10,$num).' derniers nouveaux clients</td>';
print '<td width="25%" align="center">Nb Lignes';
print "</td></tr>\n";
$var=True;
$ligne = new LigneTel($db);
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.stripslashes($obj->nom).'</a></td>';
print '<td align="center">'.$obj->ligne."</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
print "<br />";
/* Commentaires */
$sql = "SELECT s.rowid as socid, s.nom, c.commentaire";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."telephonie_societe_commentaire as c";
$sql .= ",".MAIN_DB_PREFIX."societe_perms as sp";
$sql .= " WHERE c.fk_soc = s.rowid ";
$sql .= " AND s.rowid = sp.fk_soc";
$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1";
$sql .= " ORDER BY c.datec DESC LIMIT 10";
$resql = $db->query($sql);
if ($resql)
{
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td colspan="2">'.min(10,$num).' derniers commentaires</td></tr>';
while ($obj = $db->fetch_object($resql))
{
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
$nom = $obj->nom;
if (strlen($obj->nom) > 33)
$nom = substr($obj->nom,0,30)."...";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.stripslashes($nom).'</a></td>';
print '<td>'.stripslashes($obj->commentaire)."</td>\n";
print "</tr>\n";
}
print "</table>";
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td></tr>';
print '</table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,202 +0,0 @@
<?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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
$mesg = '';
llxHeader("","","Fiche client");
if ($cancel == $langs->trans("Cancel"))
{
$action = '';
}
/*
* Affichage
*
*/
if ($_GET["id"])
{
$soc = new TelephonieClient($db);
$result = $soc->fetch($_GET["id"], $user);
if (!$soc->perm_read)
{
print "Lecture non authoris<69>e";
}
if ( $result == 1 && $soc->perm_read)
{
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/fiche.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Contrats");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/lignes.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Lignes");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/factures.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Factures");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/stats.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Stats");
$h++;
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."telephonie_tarif_client";
$sql .= " WHERE fk_client = '".$soc->id."';";
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$db->free($resql);
}
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/tarifs.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Tarifs (".$row[0].")");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/commentaires.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Commentaires");
$num_comments = $soc->count_comment();
if ($num_comments > 0)
{
$head[$h][1] = $langs->trans("Commentaires ($num_comments)");
}
$h++;
dol_fiche_head($head, $hselected, 'Client : '.$soc->nom);
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td>'.$soc->nom.'</td><td>'.$langs->trans('Code client').'</td><td>'.$soc->code_client.'</td></tr>';
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->adresse)."<br>".$soc->cp." ".$soc->ville." ".$soc->pays."</td></tr>";
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id).'</td>';
print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($soc->fax,$soc->pays_code,0,$soc->id).'</td></tr>';
print '</table><br />';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
//print '<tr><td width="20%">Num<75>ro</td><td>'.dol_print_phone($ligne->numero).'</td>';
//print '<td>Factur<75>e : '.$ligne->facturable.'</td></tr>';
/* Lignes */
$sql = "SELECT s.rowid as socid, f.nom as fournisseur, s.nom";
$sql .= ", ss.nom as agence, ss.ville, ss.code_client";
$sql .= " , l.ligne, l.statut, l.rowid, l.remise";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
$sql .= " , ".MAIN_DB_PREFIX."societe as ss";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_fournisseur as f";
$sql .= " WHERE l.fk_client_comm = s.rowid AND l.fk_fournisseur = f.rowid";
$sql .= " AND l.fk_soc = ss.rowid ";
$sql .= " AND s.rowid = ".$soc->id;
$sql .= " ORDER BY ss.rowid ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ( $num > 0 )
{
$i = 0;
$ligne = new LigneTel($db);
print '<tr class="liste_titre"><td width="15%" valign="center">Ligne';
print '</td><td colspan="3">Agence/Filiale</td>';
print '<td align="center">Remise LMN</td>';
if ($user->rights->telephonie->fournisseur->lire)
print '<td>Fournisseur</td>';
print "</tr>\n";
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<img src="../graph'.$obj->statut.'.png">&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/ligne/fiche.php?id='.$obj->rowid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/ligne/fiche.php?id='.$obj->rowid.'">'.dol_print_phone($obj->ligne,0,0,true)."</a></td>\n";
print '<td>'.$obj->code_client."</td>\n";
print '<td>'.$obj->agence."</td>\n";
print '<td>'.$obj->ville."</td>\n";
print '<td align="center">'.$obj->remise." %</td>\n";
if ($user->rights->telephonie->fournisseur->lire)
print "<td>".$obj->fournisseur."</td>\n";
print "</tr>\n";
$i++;
}
}
$db->free($resql);
}
else
{
print $sql;
}
print "</table>";
}
}
}
else
{
print "Error";
}
print '</div>';
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,133 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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("./pre.inc.php");
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
llxHeader('','Telephonie - Ligne - Liste');
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
if ($sortorder == "") {
$sortorder="ASC";
}
if ($sortfield == "") {
$sortfield="s.nom";
}
/*
* Recherche
*
*/
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*
*/
$sql = "SELECT s.rowid as socid, s.nom, count(l.ligne) as ligne, cs.ca";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_perms as sp ON sp.fk_soc = s.rowid ";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."telephonie_client_stats as cs ON cs.fk_client_comm = s.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."telephonie_societe_ligne as l ON l.fk_client_comm = s.rowid";
$sql .= " WHERE sp.fk_user = ".$user->id." AND sp.pread = 1";
if ($_GET["search_client"])
{
$sel = urldecode($_GET["search_client"]);
$sql .= " AND s.nom LIKE '%".$sel."%'";
}
$sql .= " GROUP BY s.rowid";
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0;
$urladd= "&amp;statut=".$_GET["statut"];
print_barre_liste("Clients", $page, "liste.php", $urladd, $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print_liste_field_titre("Client","liste.php","s.nom","","",' width="50%"');
print '<td width="25%" align="center">Nb Lignes';
print '</td><td width="25%" align="right">CA</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="liste.php" method="GET">';
print '<td><input type="text" name="search_client" value="'. $_GET["search_client"].'" size="12"></td>';
print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td><td>&nbsp;</td>';
print '</form>';
print '</tr>';
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.$obj->nom.'</a></td>';
print '<td align="center">'.$obj->ligne."</td>\n";
print '<td align="right">'.price($obj->ca)." euros HT</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,140 +0,0 @@
<?PHP
/* Copyright (C) 2005-2007 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("./pre.inc.php");
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
llxHeader('','Telephonie - Mes clients');
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
if ($sortorder == "") {
$sortorder="ASC";
}
if ($sortfield == "") {
$sortfield="s.nom";
}
/*
* Recherche
*
*
*/
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*
*/
$sql = "SELECT s.rowid as socid, s.nom, count(l.ligne) as ligne, cs.ca";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."telephonie_societe_ligne AS l ON l.fk_client_comm = s.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."telephonie_client_stats as cs ON cs.fk_client_comm = s.rowid";
$sql .= " WHERE l.fk_commercial_suiv = ".$user->id;
if ($_GET["search_client"])
{
$sel = urldecode($_GET["search_client"]);
$sql .= " AND s.nom LIKE '%".$sel."%'";
}
$sql .= " GROUP BY s.rowid";
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0;
$urladd= "&amp;statut=".$_GET["statut"];
$titre = "Les clients de ".$user->fullname;
print_barre_liste($titre, $page, "my.php", $urladd, $sortfield, $sortorder, '', $num);
//print '<a href="myxls.php">Exporter dans un tableur</a>';
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print_liste_field_titre("Client","my.php","s.nom","","",' width="50%"');
print '<td width="25%" align="center">Nb Lignes';
print '</td><td width="25%" align="right">Chiffre d\'affaire</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="my.php" method="GET">';
print '<td><input type="text" name="search_client" value="'. $_GET["search_client"].'" size="12"></td>';
print '<td><input type="submit" value="Chercher"></td><td>&nbsp;</td>';
print '</form>';
print '</tr>';
$var=True;
$ligne = new LigneTel($db);
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.$obj->nom.'</a></td>';
print '<td align="center">'.$obj->ligne."</td>\n";
print '<td align="right">'.price($obj->ca)." euros HT</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,864 +0,0 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.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.
*/
/**
\file htdocs/telephonie/client/new.php
\ingroup telephonie
\brief Creation d'un nouveau client
\version $Id$
*/
require("pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
require_once(DOL_DOCUMENT_ROOT.'/companybankaccount.class.php');
require_once(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
require_once(DOL_DOCUMENT_ROOT."/telephonie/telephonie.contrat.class.php");
if (!$user->rights->telephonie->ligne->creer) accessforbidden();
$user->getrights('societe');
$langs->load("companies");
$soc = new Societe($db);
$contact = new Contact($db);
$rib = new CompanyBankAccount($db);
/*
* Actions
*/
if ($_POST["action"] == 'add')
{
$error = 0;
$verif = "ok";
$mesg = '';
$contact->name = $_POST["cnom"];
$contact->firstname = $_POST["cprenom"];
$contact->email = strtolower($_POST["cmail"]);
if (strlen(trim($_POST["nom"])) == 0)
{
$mesg = "Nom de société incorrect";
$verif = "nok";
}
if (strlen(trim($_POST["code_client"])) <> 6 && $verif == 'ok')
{
$mesg = "Code client incorrect";
$verif = "nok";
}
if (strlen(trim($_POST["adresse"])) == 0 && $verif == 'ok')
{
$mesg = "Adresse de société manquante";
$verif = "nok";
}
if (strlen(trim($_POST["cp"])) == 0 && $verif == 'ok')
{
$mesg = "Code postal manquant";
$verif = "nok";
}
if (strlen(trim($_POST["ville"])) == 0 && $verif == 'ok')
{
$mesg = "Ville manquante";
$verif = "nok";
}
$rib->code_banque = $_POST["rib_banque"];
$rib->code_guichet = $_POST["rib_guichet"];
$rib->number = $_POST["rib_compte"];
$rib->cle_rib = $_POST["rib_cle"];
$rib->iban_prefix = $_POST["rib_iban"];
$rib->iban = $_POST["rib_iban"];
$rib->proprio = $_POST["titulaire"];
if ((strlen(trim($_POST["rib_banque"])) + strlen(trim($_POST["rib_guichet"])) + strlen(trim($_POST["rib_compte"])) + strlen(trim($_POST["rib_cle"])))<> 0 && $verif == 'ok')
{
if (strlen(trim($_POST["rib_banque"])) <> 5 && $verif == 'ok')
{
$mesg = "Rib code banque incomplet";
$verif = "nok";
}
if (strlen(trim($_POST["rib_guichet"])) <> 5 && $verif == 'ok')
{
$mesg = "Rib code agence incomplet";
$verif = "nok";
}
if (strlen(trim($_POST["titulaire"])) == 0 && $verif == 'ok')
{
$mesg = "Vous devez indiquer le titulaire du compte";
$verif = "nok";
}
if ($rib->verif() <> 1 && $verif == 'ok')
{
$mesg = "Rib incorrect ".$rib->error_message;
$verif = "nok";
}
}
if (strlen(trim($_POST["cmail"])) > 0 && $verif == 'ok')
{
if (strlen(trim($_POST["cnom"])) == 0 && $verif == 'ok')
{
$mesg = "Nom de contact manquant";
$verif = "nok";
}
if (! isValidEmail(trim($contact->email)) && $verif == 'ok')
{
$mesg = "Email invalide";
$verif = "nok";
}
if (! isValidMailDomain(trim($contact->email)) && $verif == 'ok')
{
$mesg = "Email invalide (domaine invalide)";
$verif = "nok";
}
}
if (strlen(trim($_POST["cli"])) <> 9 && $verif == 'ok')
{
$mesg = "Numéro de ligne #1 (0".$_POST["cli"].") incorrect";
$verif = "nok";
}
if (strlen(trim($_POST["cliend"])) > 0 && strlen(trim($_POST["cliend"])) <> 9 && $verif == 'ok')
{
$mesg = "Numéro de ligne dernier SDA (0".$_POST["cliend"].") incorrect";
$verif = "nok";
}
$p = array("1","2","3","4","5");
if (!in_array(substr(trim($_POST["cli"]),0,1), $p) && $verif == 'ok')
{
$mesg = "Numéro de ligne #1 (0".$_POST["cli"].") incorrect";
$verif = "nok";
}
$ligne = new LigneTel($db);
$ligne->fetch("0".trim($_POST["cli"]));
if ($ligne->id > 0 && $verif == 'ok')
{
$mesg = "La ligne #1 : 0".$_POST["cli"]." existe déjà !";
$verif = "nok";
}
/* Ligne #2 */
if (strlen(trim($_POST["cli2"])) > 0 && $verif == 'ok')
{
if (strlen(trim($_POST["cli2"])) <> 9 && $verif == 'ok')
{
$mesg = "Numéro de ligne #2 (0".$_POST["cli2"].") incorrect";
$verif = "nok";
}
if (!in_array(substr(trim($_POST["cli2"]),0,1), $p) && $verif == 'ok')
{
$mesg = "Numéro de ligne #2 (0".$_POST["cli2"].") incorrect";
$verif = "nok";
}
$ligne = new LigneTel($db);
$ligne->fetch("0".trim($_POST["cli2"]));
if ($ligne->id > 0 && $verif == 'ok')
{
$mesg = "La ligne #2 : 0".$_POST["cli2"]." existe déjà !";
$verif = "nok";
}
}
/* Ligne #3 */
if (strlen(trim($_POST["cli3"])) > 0 && $verif == 'ok')
{
if (strlen(trim($_POST["cli3"])) <> 9 && $verif == 'ok')
{
$mesg = "Numéro de ligne #3 (0".$_POST["cli3"].") incorrect";
$verif = "nok";
}
if (!in_array(substr(trim($_POST["cli3"]),0,1), $p) && $verif == 'ok')
{
$mesg = "Numéro de ligne #3 (0".$_POST["cli3"].") incorrect";
$verif = "nok";
}
$ligne = new LigneTel($db);
$ligne->fetch("0".trim($_POST["cli3"]));
if ($ligne->id > 0 && $verif == 'ok')
{
$mesg = "La ligne #3 : 0".$_POST["cli3"]." existe déjà !";
$verif = "nok";
}
}
/* Verif Tarif */
if (strlen(trim($_POST["france"])) > 0 && $verif == "ok")
{
$temporel = ereg_replace(",",".",trim($_POST["france"]));
if(! is_numeric($temporel))
{
$error = 1030;
$verif = "nok";
$mesg .= "Tarif France Invalide";
}
else
{
if ($temporel > 0.04 )
{
$error = 1031;
$verif = "nok";
$mesg .= "Tarif France Invalide : $temporel > 0.04 !";
}
if ($temporel < 0.016 )
{
$error = 1031;
$verif = "nok";
$mesg .= "Tarif France Invalide : $temporel < 0.016 !";
}
}
}
if (strlen(trim($_POST["mobil"])) > 0 && $verif == "ok")
{
$temporel = ereg_replace(",",".",trim($_POST["mobil"]));
if(! is_numeric($temporel))
{
$error++;
$verif = "nok";
$mesg .= "Tarif Mobile Invalide";
}
else
{
if ($temporel > 0.40 )
{
$error = 1033;
$verif = "nok";
$mesg .= "Tarif Mobile Invalide : $temporel > 0.40 !";
}
if ($temporel < 0.14 )
{
$error = 1034;
$verif = "nok";
$mesg .= "Tarif Mobile Invalide : $temporel < 0.14 !";
}
}
}
/* Fin Verif Tarif */
$soc->nom = $_POST["nom"];
$soc->adresse = $_POST["adresse"];
$soc->cp = $_POST["cp"];
$soc->ville = $_POST["ville"];
$soc->pays_id = $_POST["pays_id"];
$soc->tel = $_POST["tel"];
$soc->fax = $_POST["fax"];
$soc->url = ereg_replace( "http://", "", $_POST["url"] );
$soc->code_client = $_POST["code_client"];
$soc->code_fournisseur = $_POST["code_fournisseur"];
$soc->codeclient_modifiable = $_POST["codeclient_modifiable"];
$soc->codefournisseur_modifiable = $_POST["codefournisseur_modifiable"];
$soc->client = 1;
$soc->fournisseur = 0;
if (!$error && $verif == "ok")
{
$soc->code_client = $_POST["code_client"]."00";
$result = $soc->create($user);
if ($result == 0)
{
$soc->AddPerms(1,1,1,1);
$soc->AddPerms(5,1,1,1);
$soc->AddPerms(9,1,1,1);
$soc->AddPerms($user->id,1,1,1);
$soc->AddPerms($_POST["commercial_sign"],1,0,0);
}
else
{
$mesg = nl2br($soc->error) . " (result $result)\n";
$error = 1035;
}
}
if (!$error && $verif == "ok")
{
$contact->socid = $soc->id;
if ( $contact->create($user) > 0)
{
}
else
{
$error = 1024;
}
}
if ((strlen(trim($_POST["rib_banque"])) + strlen(trim($_POST["rib_guichet"])) + strlen(trim($_POST["rib_compte"])) + strlen(trim($_POST["rib_cle"])))<> 0 && $verif == 'ok' && !$error)
{
$rib->socid = $soc->id;
if ( $rib->update($user) > 0)
{
}
else
{
$error = 1025;
}
}
if (!$error && $verif == "ok")
{
$contrat = new TelephonieContrat($db);
$contrat->client_comm = $soc->id;
$contrat->client = $soc->id;
$contrat->client_facture = $soc->id;
$contrat->commercial_sign = $_POST["commercial_sign"];
if ( $contrat->create($user,'oui',$_POST["mode_paiement"]) == 0)
{
$contrat->add_contact_facture($contact->id);
}
else
{
$error = 1026;
}
}
if(!$error && $verif == "ok")
{
$contrat->commercial_sign_id = $_POST["commercial_sign"];
$contrat->addpo($_POST["montantpo"], $user);
}
/* Ligne 1 */
$ligne = new LigneTel($db);
$ligne->contrat = $contrat->id;
$ligne->numero = "0".$_POST["cli"];
$ligne->client_comm = $soc->id;
$ligne->client = $soc->id;
$ligne->client_facture = $soc->id;
$ligne->fournisseur = $_POST["fournisseur"];
$ligne->commercial_sign = $_POST["commercial_sign"];
$ligne->commercial_suiv = $_POST["commercial_sign"];
$ligne->concurrent = $_POST["concurrent"];
$ligne->remise = "0";
$ligne->note = $_POST["note"];
if(!$error && $verif == "ok")
{
if (strlen(trim($_POST["cli"])) == 9)
{
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
{
}
else
{
$error = 1027;
$mesg.= "Impossible de créer la ligne #1 0".$_POST["cli"];
}
}
}
/* SDA */
if(!$error && $verif == "ok")
{
if (strlen(trim($_POST["cli"])) == 9 && strlen(trim($_POST["cliend"])) == 9)
{
$cbegin = trim($_POST["cli"]) + 1;
$cend = trim($_POST["cliend"]);
$cli = $cbegin;
while ($cli <= $cend)
{
$ligne = new LigneTel($db);
$ligne->contrat = $contrat->id;
$ligne->numero = "0".$cli;
$ligne->client_comm = $soc->id;
$ligne->client = $soc->id;
$ligne->client_facture = $soc->id;
$ligne->fournisseur = $_POST["fournisseur"];
$ligne->commercial_sign = $_POST["commercial_sign"];
$ligne->commercial_suiv = $_POST["commercial_sign"];
$ligne->concurrent = $_POST["concurrent"];
$ligne->remise = "0";
$ligne->note = $_POST["note"];
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
{
}
else
{
$error = 1027;
$mesg.= "Impossible de créer la ligne 0$cli";
}
$cli++;
}
}
}
/* Ligne 2 */
$ligne = new LigneTel($db);
$ligne->contrat = $contrat->id;
$ligne->numero = "0".$_POST["cli2"];
$ligne->client_comm = $soc->id;
$ligne->client = $soc->id;
$ligne->client_facture = $soc->id;
$ligne->fournisseur = $_POST["fournisseur"];
$ligne->commercial_sign = $_POST["commercial_sign"];
$ligne->commercial_suiv = $_POST["commercial_sign"];
$ligne->concurrent = $_POST["concurrent"];
$ligne->remise = "0";
$ligne->note = $_POST["note"];
if(!$error && $verif == "ok")
{
if (strlen(trim($_POST["cli2"])) == 9)
{
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
{
}
else
{
//$error++;
$error = 1028;
$mesg.= "Impossible de créer la ligne #2 0".$_POST["cli2"];
}
}
}
/* Ligne 3 */
$ligne = new LigneTel($db);
$ligne->contrat = $contrat->id;
$ligne->numero = "0".$_POST["cli3"];
$ligne->client_comm = $soc->id;
$ligne->client = $soc->id;
$ligne->client_facture = $soc->id;
$ligne->fournisseur = $_POST["fournisseur"];
$ligne->commercial_sign = $_POST["commercial_sign"];
$ligne->commercial_suiv = $_POST["commercial_sign"];
$ligne->concurrent = $_POST["concurrent"];
$ligne->remise = "0";
$ligne->note = $_POST["note"];
if(!$error && $verif == "ok")
{
if (strlen(trim($_POST["cli3"])) == 9)
{
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
{
}
else
{
//$error++;
$error = 1029;
$mesg.= "Impossible de créer la ligne #3 0".$_POST["cli3"];
}
}
}
/* DEBUT TARIFS */
if (strlen(trim($_POST["france"])) > 0 && $verif == "ok")
{
$temporel = ereg_replace(",",".",trim($_POST["france"]));
if (!$error)
{
$db->begin();
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client";
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES ";
$sql .= " (1293,".$soc->id.",'".$temporel."','0',".$user->id.")";
if (! $db->query($sql) )
{
$error++;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log";
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES ";
$sql .= " (1293,".$soc->id.",'".$temporel."','0',".$user->id.",now())";
if (! $db->query($sql) )
{
$error++;
}
if ( $error == 0 )
{
$db->commit();
}
else
{
$db->rollback();
$mesg = "Erreur tarifs !";
}
}
}
/* mobiles */
if (strlen(trim($_POST["mobil"])) > 0 && $verif == "ok")
{
$mobil_ids = array(1289,1290,1291,1292);
foreach ($mobil_ids as $mobil_id)
{
$temporel = ereg_replace(",",".",trim($_POST["mobil"]));
if (!$error)
{
$db->begin();
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client";
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES ";
$sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.")";
if (! $db->query($sql) )
{
$error++;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log";
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES ";
$sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.",now())";
if (! $db->query($sql) )
{
$error++;
}
if ( $error == 0 )
{
$db->commit();
}
else
{
$db->rollback();
$mesg = "Erreur tarifs !";
}
}
}
}
/* FIN TARIFS */
if (!$error && $verif == "ok")
{
Header("Location: ".DOL_URL_ROOT."/telephonie/contrat/fiche.php?id=".$contrat->id);
}
else
{
$mesg .= " (numéro erreur : $error)";
}
}
/**
*
*
*/
llxHeader();
$form = new Form($db);
if ($user->rights->telephonie->ligne->creer)
{
dol_fiche_head($head, $hselected, 'Nouveau client');
/*
*/
if ($mesg)
{
print '<div class="error">';
print $mesg;
print '</div>';
}
else
{
}
$focus = " onfocus=\"this.className='focus';\" onblur=\"this.className='normal';\" ";
print '<FORM NAME="formClient" action="new.php" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="codeclient_modifiable" value="1">';
print '<input type="hidden" name="codefournisseur_modifiable" value="1">';
print '<input type="hidden" name="action" value="add">';
print '<div id="corpForm">';
print '<fieldset id="societe">';
print "<legend>Société</legend>\n";
print '<table class="noborder" width="100%">';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td>';
print '<input type="text" size="30" name="nom" ';
print $focus .' value="'.$soc->nom.'"></td><td>';
print "Attention ce formulaire n'est a utiliser uniquement pour les nouveaux clients.</td></tr>";
// On positionne pays_id, pays_code et libelle du pays choisi
$soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:(defined(MAIN_INFO_SOCIETE_PAYS)?MAIN_INFO_SOCIETE_PAYS:'');
if ($soc->pays_id)
{
$sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id;
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
}
else
{
dol_print_error($db);
}
$soc->pays_code=$obj->code;
$soc->pays=$obj->libelle;
}
print '<tr><td width="20%">'.$langs->trans('CustomerCode').'</td><td colspan="3">';
print '<input size="7" type="text" name="code_client" maxlength="6"';
print " onfocus=\"this.className='focus';\" onblur=\"this.className='normal';\" ";
print ' value="'.$soc->code_client.'">00</td>';
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea '.$focus.' name="adresse" cols="40" rows="2" wrap="soft">';
print $soc->adresse;
print '</textarea></td></tr>';
print '<tr><td>'.$langs->trans('Zip').'</td><td colspan="3">';
print '<input size="7" maxlength="6" type="text" name="cp" ';
print " onfocus=\"this.className='focus';\" onblur=\"this.className='normal';\" ";
print ' value="'.$soc->cp.'">&nbsp;';
print $langs->trans('Town').'&nbsp;<input type="text" '.$focus.' name="ville" value="'.$soc->ville.'"></td></tr>';
print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" size="11" maxlength="10" '.$focus.' name="tel" value="'.$soc->tel.'"></td>';
print '<td>'.$langs->trans('Fax').'</td><td><input type="text" '.$focus.' name="fax" size="11" maxlength="10" value="'.$soc->fax.'"></td></tr>';
print "</table>\n";
print "</fieldset><br />\n";
print '<fieldset id="contact">';
print "<legend>Coordonnées bancaires</legend>\n";
print '<table class="noborder" width="100%">';
print '<tr><td width="20%">Titulaire du compte</td><td><input type="text" size="30" '.$focus.' name="titulaire" value="'.$_POST["titulaire"].'"></td></tr>';
print '<tr><td width="20%">RIB</td><td colspan="3">';
print '<input type="text" size="6" maxlength="5" '.$focus.' name="rib_banque" value="'.$_POST["rib_banque"].'">';
print '<input type="text" size="6" maxlength="5" '.$focus.' name="rib_guichet" value="'.$_POST["rib_guichet"].'">';
print '<input type="text" size="12" maxlength="11" '.$focus.' name="rib_compte" value="'.$_POST["rib_compte"].'">';
print '<input type="text" size="3" maxlength="2" '.$focus.' name="rib_cle" value="'.$_POST["rib_cle"].'">';
print '&nbsp;&nbsp;IBAN&nbsp;&nbsp;';
print '<input type="text" size="4" maxlength="4" '.$focus.' name="rib_iban" value="'.$_POST["rib_iban"].'">';
print '</td></tr>';
print '<tr><td width="20%">Règlement</td><td colspan="3">';
print '<select name="mode_paiement">';
if ($_POST["mode_paiement"] == 'vir')
{
print '<option value="pre">Prélèvement</option>';
print '<option value="vir" SELECTED>Virement</option>';
}
else
{
print '<option value="pre" SELECTED>Prélèvement</option>';
print '<option value="vir">Virement</option>';
}
print '</select>';
print '</td></tr>';
print "</table>\n";
print "</fieldset><br />\n";
print '<fieldset id="contact">';
print "<legend>Contact</legend>\n";
print '<table class="noborder" width="100%">';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td><input type="text" size="30" '.$focus.' name="cnom" value="'.$contact->name.'"></td>';
print '<td width="20%">'.$langs->trans('Firstname').'</td><td><input type="text" size="20" '.$focus.' name="cprenom" value="'.$contact->firstname.'"></td></tr>';
print '<tr><td>'.$langs->trans('Mail').'</td><td><input type="text" size="40" '.$focus.' name="cmail" value="'.$contact->email.'"></td></tr>';
print "</table>\n";
print "</fieldset><br />\n";
print '<fieldset id="contact">';
print "<legend>Commercial</legend>\n";
print '<table class="noborder" width="100%">';
print '<tr><td width="20%">Commercial Signature</td><td >';
$ff = array();
$sql = "SELECT u.rowid, u.firstname, u.name";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " WHERE u.rowid = ug.fk_user";
$sql .= " AND ug.fk_usergroup = '".TELEPHONIE_GROUPE_COMMERCIAUX_ID."'";
$sql .= " ORDER BY name ";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
while ($row = $db->fetch_row($resql))
{
$ff[$row[0]] = $row[1] . " " . $row[2];
}
}
$db->free();
}
$form->select_array("commercial_sign",$ff,$ligne->commercial_sign);
print '</td>';
print '<td width="20%">PO mensuelle</td><td valign="top" colspan="2">';
print '<input '.$focus.' name="montantpo" size="8" value="'.$_POST["montantpo"].'"> euros HT</td></tr>';
print '</td></tr>';
print "</table>\n";
print "</fieldset><br />\n";
print '<fieldset id="ligne">';
print "<legend>Lignes téléphoniques à présélectionner</legend>\n";
print '<table class="noborder" width="100%">';
print '<tr><td width="20%">Ligne téléphonique #1</td><td>0<input type="text" size="10" maxlength="9" '.$focus.' name="cli" value="'.$_POST["cli"].'"></td>';
print '<td>Derniere SDA</td><td>0<input type="text" size="10" maxlength="9" '.$focus.' name="cliend" value="'.$_POST["cliend"].'"></td></tr>';
print '<tr><td width="20%">Ligne téléphonique #2</td><td>0<input type="text" size="10" maxlength="9" '.$focus.' name="cli2" value="'.$_POST["cli2"].'"></td></tr>';
print '<tr><td width="20%">Ligne téléphonique #3</td><td>0<input type="text" size="10" maxlength="9" '.$focus.' name="cli3" value="'.$_POST["cli3"].'"></td></tr>';
print '<tr><td width="20%">Fournisseur</td><td>';
$ff = array();
$sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur WHERE commande_active = 1 ORDER BY nom ";
$resql = $db->query($sql);
if ($resql)
{
while ($row = $db->fetch_row($resql))
{
$ff[$row[0]] = $row[1];
}
$db->free($resql);
}
$def =$ligne->fournisseur?$ligne->fournisseur:TELEPHONIE_FOURNISSEUR_DEFAUT_ID;
$form->select_array("fournisseur",$ff,$def);
print '</td>';
print '<td width="20%">Fournisseur précédent</td><td>';
$ff = array();
$sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_concurrents ORDER BY rowid ";
$resql = $db->query( $sql) ;
if ($resql)
{
$num = $db->num_rows($resql);
if ( $num > 0 )
{
while ($row = $db->fetch_row($resql))
{
$ff[$row[0]] = $row[1];
}
}
$db->free();
}
$form->select_array("concurrent",$ff,$ligne->concurrent);
print '</td></tr>';
print "</table>\n";
print "</fieldset><br />\n";
/* DEBUT TARIFS */
print '<fieldset id="ligne">';
print "<legend>Tarifs</legend>\n";
if ($user->rights->telephonie->tarif->client_modifier)
{
print '<table class="noborder" width="100%">';
print '<tr><td width="20%">France</td><td><input type="text" size="10" maxlength="9" '.$focus.' name="france" value="'.$_POST["france"].'"></td><td>Laissez vide si tarifs par défaut</tr>';
print '<tr><td width="20%">Mobiles</td><td><input type="text" size="10" maxlength="9" '.$focus.' name="mobil" value="'.$_POST["mobil"].'"></td><td>Tous réseaux confondus</td></tr>';
print "</table>\n";
}
else
{
print "Vous n'avez pas les droits pour modifier les tarifs";
}
print "</fieldset><br />\n";
/* FIN TARIFS */
print '<input type="submit" value="'.$langs->trans('Save').'">'."\n";
print '</form>'."\n";
print "</div>\n";
}
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -1,244 +0,0 @@
<?PHP
/* Copyright (C) 2005-2007 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("./pre.inc.php");
$mesg = '';
$soc = new Societe($db);
if ($_GET["id"])
{
$result = $soc->fetch($_GET["id"], $user);
}
if (!$soc->perm_read)
accessforbidden();
if (!$soc->perm_perms)
accessforbidden();
if ($_GET["action"] == 'inv')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_perms";
$sql .= " SET p".$_GET["p"]." = !p".$_GET["p"];
$sql .= " WHERE fk_user=".$_GET["u"]." AND fk_soc=".$_GET["id"];
if ($resql = $db->query($sql))
{
Header("Location: permissions.php?id=$soc->id");
}
}
if ($_POST["action"] == 'add')
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_perms";
$sql .= " (fk_soc,fk_user,pread,pwrite,pperms) VALUES";
$sql .= " (".$_GET["id"].",".$_POST["new_user"].",";
$sql .= $_POST["read"]=='on'?"1,":"0,";
$sql .= $_POST["read"]=='on'?"1,":"0,";
$sql .= $_POST["read"]=='on'?"1);":"0);";
if ($resql = $db->query($sql))
{
Header("Location: permissions.php?id=$soc->id");
}
}
llxHeader("","","Fiche client");
/*
* Affichage
*
*/
if ($soc->id)
{
$h=0;
$form = new Form($db);
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/fiche.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Contrats");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/lignes.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Lignes");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/factures.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Factures");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/ca.php?id=".$soc->id;
$head[$h][1] = $langs->trans("CA");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/tarifs.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Tarifs");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/permissions.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Permissions");
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, 'Client : '.$soc->nom);
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td>'.$soc->nom.'</td><td>'.$langs->trans('Code client').'</td><td>'.$soc->code_client.'</td></tr>';
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->adresse)."<br>".$soc->cp." ".$soc->ville." ".$soc->pays."</td></tr>";
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id).'</td>';
print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($soc->fax,$soc->pays_code,0,$soc->id).'</td></tr>';
print '</table><br />';
print '<form method="POST" action="permissions.php?id='.$soc->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
/* Permissions du user en cours */
$sql = "SELECT p.pread, p.pwrite, p.pperms";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_perms as p";
$sql .= " WHERE p.fk_soc=".$soc->id." AND p.fk_user=".$user->id.";";
if ($resql = $db->query($sql))
{
$num = $db->num_rows($resql);
if ( $num > 0 )
{
$obj = $db->fetch_object($resql);
$read = $obj->pread;
$write = $obj->pwrite;
$perms = $obj->pperms;
}
$db->free($resql);
}
else
{
print $sql;
}
/* Ajout un user */
$uss = array();
$sql = "SELECT u.rowid, u.firstname, u.name";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " WHERE u.rowid = ug.fk_user";
$sql .= " AND ug.fk_usergroup = '".TELEPHONIE_GROUPE_COMMERCIAUX_ID."'";
$sql .= " ORDER BY name ";
if ( $resql = $db->query( $sql) )
{
while ($row = $db->fetch_row($resql))
{
$uss[$row[0]] = $row[1] . " " . $row[2];
}
$db->free($resql);
}
/* Permissions */
$sql = "SELECT u.rowid,u.firstname, u.name, p.pread, p.pwrite, p.pperms";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_perms as p";
$sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE p.fk_user = u.rowid AND p.fk_soc = ".$soc->id;
$sql .= " ORDER BY u.name ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ( $num > 0 )
{
$i = 0;
$ligne = new LigneTel($db);
print '<tr class="liste_titre">';
print '<td>Utilisateur</td>';
print '<td align="center">Lecture</td>';
print '<td align="center">Ecriture</td>';
print '<td align="center">Permissions</td>';
print "<td>&nbsp;</td></tr>\n";
print '<tr class="liste_titre">';
print '<td>';
$form->select_array("new_user",$uss);
print '</td>';
print '<td align="center"><input name="read" type="checkbox"></td>';
print '<td align="center"><input name="write" type="checkbox"></td>';
print '<td align="center"><input name="perm" type="checkbox"></td>';
print '<td align="center"><input type="submit" value="Ajouter"></td>';
print "</tr>\n";
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.$obj->firstname." ".$obj->name."</td>\n";
if ($perms == 1)
{
print '<td align="center"><a href="permissions.php?id='.$soc->id.'&amp;u='.$obj->rowid.'&amp;p=read&amp;action=inv">'.img_allow($obj->pread)."</a></td>\n";
print '<td align="center"><a href="permissions.php?id='.$soc->id.'&amp;u='.$obj->rowid.'&amp;p=write&amp;action=inv">'.img_allow($obj->pwrite)."</td>\n";
print '<td align="center"><a href="permissions.php?id='.$soc->id.'&amp;u='.$obj->rowid.'&amp;p=perms&amp;action=inv">'.img_allow($obj->pperms)."</td>\n";
}
else
{
print '<td align="center">'.img_allow($obj->pread)."</td>\n";
print '<td align="center">'.img_allow($obj->pwrite)."</td>\n";
print '<td align="center">'.img_allow($obj->pperms)."</td>\n";
}
print "<td>&nbsp;</td></tr>\n";
$i++;
}
}
$db->free($resql);
}
else
{
print $sql;
}
print "</table></form>";
}
else
{
print "Error";
}
print '</div>';
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,77 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
require(DOL_DOCUMENT_ROOT."/telephonie/telephonie.client.class.php");
$user->getrights('telephonie');
function llxHeader($head = "", $title="") {
global $user;
/*
*
*
*/
top_menu($head, $title);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/telephonie/index.php", "Telephonie");
if (TELEPHONIE_MODULE_SIMULATION == 1)
$menu->add(DOL_URL_ROOT."/telephonie/simulation/fiche.php", "Simulation");
$menu->add(DOL_URL_ROOT."/telephonie/client/index.php", "Clients");
if ($user->rights->telephonie->ligne->creer)
$menu->add_submenu(DOL_URL_ROOT."/telephonie/client/new.php", "Nouveau client");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/client/my.php", "Mes clients");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/client/liste.php", "Liste");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/client/contacts.php", "Contacts");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/client/remises.php", "Remises à faire");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/client/remisesdone.php", "Remises faites");
//$menu->add_submenu(DOL_URL_ROOT."/telephonie/client/rapports", "Rapports");
$menu->add(DOL_URL_ROOT."/telephonie/contrat/", "Contrats");
$menu->add(DOL_URL_ROOT."/telephonie/ligne/index.php", "Lignes");
if ($user->rights->telephonie->ligne_commander)
$menu->add(DOL_URL_ROOT."/telephonie/ligne/commande/", "Commandes");
if ($user->rights->telephonie->stats->lire)
$menu->add(DOL_URL_ROOT."/telephonie/stats/", "Statistiques");
if ($user->rights->telephonie->facture->lire)
$menu->add(DOL_URL_ROOT."/telephonie/facture/", "Factures");
$menu->add(DOL_URL_ROOT."/telephonie/tarifs/", "Tarifs");
if ($user->rights->telephonie->fournisseur->lire)
$menu->add(DOL_URL_ROOT."/telephonie/fournisseur/", "Fournisseurs");
left_menu($menu->liste);
}
?>

View File

@ -1,133 +0,0 @@
<?PHP
/* Copyright (C) 2004-2006 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("./pre.inc.php");
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
llxHeader('','Telephonie - Clients - Remises à faire');
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
if ($sortorder == "") {
$sortorder="ASC";
}
if ($sortfield == "") {
$sortfield="s.nom";
}
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*
*
*/
$sql = "SELECT s.rowid as socid, s.nom, r.amount";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ",".MAIN_DB_PREFIX."telephonie_client_remise as r";
$sql .= ",".MAIN_DB_PREFIX."societe_perms as sp";
$sql .= " WHERE r.fk_client = s.rowid ";
$sql .= " AND r.fk_facture = 0";
$sql .= " AND s.rowid = sp.fk_soc";
$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1";
if ($_GET["search_client"])
{
$sel = urldecode($_GET["search_client"]);
$sql .= " AND s.nom LIKE '%".$sel."%'";
}
$sql .= " ORDER BY r.fk_facture ASC, $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0;
$urladd= "&amp;statut=".$_GET["statut"];
print_barre_liste("Remises sur prochaines factures", $page, "remises.php", $urladd, $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print_liste_field_titre("Client","remises.php","s.nom","","",' width="50%"');
print '<td width="25%" align="right">Remise';
print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="remises.php" method="GET">';
print '<td><input type="text" name="search_client" value="'. $_GET["search_client"].'" size="12"></td>';
print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td>';
print '</form>';
print '</tr>';
$var=True;
$ligne = new LigneTel($db);
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.$obj->nom.'</a></td>';
print '<td align="right">'.price($obj->amount)." euros HT</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,136 +0,0 @@
<?PHP
/* Copyright (C) 2004-2006 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("./pre.inc.php");
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
llxHeader('','Telephonie - Clients - Remises');
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
if ($sortorder == "") {
$sortorder="DESC";
}
if ($sortfield == "") {
$sortfield="r.fk_facture";
}
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*
*
*/
$sql = "SELECT s.rowid as socid, s.nom, r.amount, f.facnumber, r.fk_facture";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ",".MAIN_DB_PREFIX."telephonie_client_remise as r";
$sql .= ",".MAIN_DB_PREFIX."societe_perms as sp";
$sql .= ",".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE r.fk_client = s.rowid ";
$sql .= " AND r.fk_facture > 0";
$sql .= " AND r.fk_facture = f.rowid";
$sql .= " AND s.rowid = sp.fk_soc";
$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1";
if ($_GET["search_client"])
{
$sel = urldecode($_GET["search_client"]);
$sql .= " AND s.nom LIKE '%".$sel."%'";
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0;
$urladd= "&amp;statut=".$_GET["statut"];
print_barre_liste("Remises commerciales", $page, "remisesdone.php", $urladd, $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print_liste_field_titre("Client","remisesdone.php","s.nom","","",' width="50%"');
print '<td width="25%" align="right">Remise';
print '</td><td width="25%" align="right">Facture</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<form action="remisesdone.php" method="GET">';
print '<td><input type="text" name="search_client" value="'. $_GET["search_client"].'" size="12"></td>';
print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td><td>&nbsp;</td>';
print '</form>';
print '</tr>';
$var=True;
$ligne = new LigneTel($db);
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.$obj->nom.'</a></td>';
print '<td align="right">'.price($obj->amount)." euros HT</td>\n";
print '<td align="right"><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->fk_facture.'">'.$obj->facnumber."</a></td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,197 +0,0 @@
<?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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
$mesg = '';
llxHeader("","Téléphonie - Client");
if ($cancel == $langs->trans("Cancel"))
{
$action = '';
}
/*
* Affichage
*
*/
if ($_GET["id"])
{
$soc = new Societe($db);
$result = $soc->fetch($_GET["id"], $user);
if (!$soc->perm_read)
{
print "Lecture non authorisée";
}
if ( $result == 1 && $soc->perm_read)
{
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/fiche.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Contrats");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/lignes.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Lignes");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/factures.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Factures");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/stats.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Stats");
$hselected = $h;
$h++;
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."telephonie_tarif_client";
$sql .= " WHERE fk_client = '".$soc->id."';";
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$db->free($resql);
}
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/tarifs.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Tarifs (".$row[0].")");
$h++;
dol_fiche_head($head, $hselected, 'Client : '.$soc->nom);
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td>'.$soc->nom.'</td>';
print '<td>'.$soc->code_client.'</td></tr>';
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"2\">".nl2br($soc->adresse)."<br>".$soc->cp." ".$soc->ville." ".$soc->pays."</td></tr>";
print '</table><br />';
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="50%" valign="top" align="center">';
$mesg_no_graph = 'Nous avons pas assez de données à ce jour pour générer ce graphique.';
$img_root = DOL_DATA_ROOT."/graph/".substr($soc->id,-1)."/telephonie/client/";
$file = $img_root.$soc->id."/graphca.png";
if (file_exists($file))
{
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
}
else
{
print $mesg_no_graph;
}
print '</td><td width="50%" valign="top" align="center">';
$file = $img_root.$soc->id."/graphgain.png";
if (file_exists($file) && $user->rights->telephonie->ligne->gain)
{
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
}
else
{
print $mesg_no_graph;
}
print '</td></tr>';
print '<tr><td width="50%" valign="top" align="center">';
$file = $img_root.$soc->id."/nb-minutes-mensuel.png";
if (file_exists($file))
{
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
}
else
{
print $mesg_no_graph;
}
print '</td><td width="50%" valign="top" align="center">';
$file = $img_root.$soc->id."/nb-comm-mensuel.png";
if (file_exists($file))
{
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
}
else
{
print $mesg_no_graph;
}
print '</td></tr>';
print '<tr><td width="50%" valign="top" align="center">';
$file = $img_root.$soc->id."/graphappelsdureemoyenne.png";
if (file_exists($file))
{
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="Duree moyenne">';
}
else
{
print $mesg_no_graph;
}
print '</td><td width="50%" valign="top" align="center">';
$file = $img_root.$soc->id."/nb-comm-menTOTOsuel.png";
if (file_exists($file))
{
//print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
}
else
{
//print $mesg_no_graph;
}
print '</td></tr></table>';
}
}
}
else
{
print "Error";
}
print '</div>';
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,343 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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("./pre.inc.php");
$message_erreur = '';
if ($_POST["action"] == 'addtarif' && $user->rights->telephonie->tarif->client_modifier)
{
$error = 0;
$saisieok = 1;
if (strlen(trim($_POST["temporel"])) == 0 OR strlen(trim($_POST["fixe"])) == 0)
{
$saisieok = 0;
}
else
{
$temporel = ereg_replace(",",".",trim($_POST["temporel"]));
$fixe = ereg_replace(",",".",trim($_POST["fixe"]));
}
if(! is_numeric($temporel))
{
$saisieok = 0;
}
if(! is_numeric($fixe))
{
$saisieok = 0;
}
if ($temporel < 0 OR $fixe < 0)
{
$saisieok = 0;
}
if ($saisieok)
{
$db->begin();
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client";
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES ";
$sql .= " (".$_POST["tarifid"].",".$_GET["id"].",'".$temporel."','".$fixe."',".$user->id.")";
if (! $db->query($sql) )
{
$error++;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log";
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES ";
$sql .= " (".$_POST["tarifid"].",".$_GET["id"].",'".$temporel."','".$fixe."',".$user->id.",now())";
if (! $db->query($sql) )
{
$error++;
}
if ( $error == 0 )
{
$db->commit();
Header("Location: tarifs.php?id=".$_GET["id"]);
}
else
{
$db->rollback();
print $db->error();
}
}
else
{
$message_erreur = " Saisie invalide";
}
}
/*
if ($_GET["special"] == 'done')
{
$sql = "SELECT DISTINCT(fk_tarif), fixe, temporel FROM llx_telephonie_prefix as p, llx_telephonie_tarif_vente as v where p.prefix=v.prefix and fixe= 0.14; ";
if ( $db->query( $sql) )
{
$tt = array();
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row();
$tt[$row[0]] = $row[2];
$i++;
}
}
$db->free();
foreach($tt as $key=>$value)
{
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client";
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES ";
$sql .= " (".$key.",".$_GET["id"].",'".$value."','0.07',".$user->id.")";
}
}
}
*/
if ($_GET["action"] == 'delete' && $user->rights->telephonie->tarif->client_modifier)
{
if (strlen(trim($_GET["tid"])) > 0)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_tarif_client";
$sql .= " WHERE rowid = ".$_GET["tid"];
if ( $db->query($sql) )
{
Header("Location: tarifs.php?id=".$_GET["id"]);
}
else
{
print $db->error();
}
}
}
llxHeader("","T<EFBFBD>l<EFBFBD>phonie - Fiche Tarif client");
if ($cancel == $langs->trans("Cancel"))
{
$action = '';
}
/*
*
*
*/
if ($_GET["id"])
{
$soc = new Societe($db);
$result = $soc->fetch($_GET["id"], $user);
if (!$soc->perm_read)
{
print "Lecture non authoris<69>e";
}
if ( $result == 1 && $soc->perm_read)
{
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/fiche.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Contrats");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/lignes.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Lignes");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/factures.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Factures");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/stats.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Stats");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/client/tarifs.php?id=".$soc->id;
$head[$h][1] = $langs->trans("Tarifs");
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, 'Client : '.$soc->nom);
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="20%">'.$langs->trans('Name').'</td><td>'.$soc->nom.'</td><td>'.$langs->trans('Code client').'</td><td>'.$soc->code_client.'</td></tr>';
print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->adresse)."<br>".$soc->cp." ".$soc->ville." ".$soc->pays."</td></tr>";
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->tel,$soc->pays_code,0,$soc->id).'</td>';
print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($soc->fax,$soc->pays_code,0,$soc->id).'</td></tr>';
print "</table>\n<br />\n";
print '<form action="tarifs.php?id='.$soc->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addtarif">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td width="15%" valign="center">Tarif (co<63>t en euros par minutes)';
print '</td><td align="center">Temporel</td><td align="center">Fixe</td>';
if ($user->rights->telephonie->tarif->client_modifier)
{
print '<td>&nbsp;</td>';
}
print '<td>&nbsp;</td>';
print "</tr>\n";
if($message_erreur)
{
print '<tr class="liste_titre"><td align="center" bgcolor="red" colspan="5">'.$message_erreur.'</td></tr>';
}
if ($user->rights->telephonie->tarif->client_modifier)
{
print "<tr><td>\n";
print '<select name="tarifid">';
$sql = "SELECT t.rowid , t.libelle";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif as t";
$sql .= " ORDER BY t.libelle";
$resql = $db->query($sql) ;
if ($resql)
{
$num = $db->num_rows($resql);
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<option value="'.$obj->rowid.'">'.$obj->libelle;
$i++;
}
}
}
print "</select></td>\n";
print '<td align="center"><input name="temporel" type="text" value="'.$_POST["temporel"].'" "size="5"></td>';
print '<td align="center"><input name="fixe" value="'.$_POST["fixe"].'" type="text" size="5"></td>';
print '<td align="center"><input type="submit" value="'.$langs->trans("Save").'"></td><td>&nbsp;</td>';
print "</tr>\n";
}
/* Tarifs */
$sql = "SELECT t.rowid , t.libelle, tc.temporel, tc.fixe, u.login, tc.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif as t";
$sql .= "," . MAIN_DB_PREFIX."telephonie_tarif_client as tc";
$sql .= "," . MAIN_DB_PREFIX."societe as s";
$sql .= "," . MAIN_DB_PREFIX."user as u";
$sql .= " WHERE t.rowid = tc.fk_tarif AND tc.fk_client = s.rowid";
$sql .= " AND u.rowid = tc.fk_user";
$sql .= " AND s.rowid = ".$soc->id;
$sql .= " ORDER BY t.libelle ASC";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
$ligne = new LigneTel($db);
while ($i < $num)
{
$obj = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>\n";
print $obj->libelle."</td>\n";
print '<td align="center">'.$obj->temporel."</td>\n";
print '<td align="center">'.$obj->fixe."</td>\n";
if ($user->rights->telephonie->tarif->client_modifier)
{
print '<td align="center"><a href="'.DOL_URL_ROOT.'/telephonie/client/tarifs.php?action=delete&amp;tid='.$obj->rowid.'&amp;id='.$soc->id.'">';
print img_delete()."</a></td>\n";
}
print '<td align="center">'.$obj->login."</td>\n";
print '</tr>';
$i++;
}
}
$db->free();
}
else
{
print $sql;
}
print "</table>\n</form>\n";
}
}
}
else
{
print "Error";
}
print '</div>';
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,250 +0,0 @@
<?PHP
/* Copyright (C) 2005-2007 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 CommunicationTelephonique {
var $index;
var $ligne;
var $date;
var $duree;
var $dest;
var $numero;
var $montant;
var $messages;
/**
* Constructeur
*
*/
function CommunicationTelephonique()
{
$this->messages = array();
return 1;
}
/**
* Calcul le cout de la communication
*
*/
function cout($tarif_achat, $tarif_vente, $ligne, $_db)
{
$error = 0;
/*
if (substr($this->numero,0,2) == '00')
{
$nbinter++;
$duree_international += $objp->duree;
$num = $this->numero;
$this->remise = 0;
}
elseif (substr($this->numero,0,2) == '06')
{
$dureemob += $objp->duree;
$nbmob++;
$num = "0033".substr($this->numero,1);
$this->remise = $ligne->remise;
}
*/
/* Tarif Local */
/*
elseif (substr($this->numero,0,4) == substr($objp->client,0,4) )
{
$dureenat += $objp->duree;
$nbnat++;
$num = "0033999".substr($this->numero, 1);
$this->remise = $ligne->remise;
}*/
//else
//{
$dureenat += $objp->duree;
$nbnat++;
$num = "00".$this->numero;
$this->remise = $ligne->remise;
//}
/*
*
*
*/
/* Numeros speciaux */
/*
if (substr($num,4,1) == 8)
{
$this->remise = 0;
$this->cout_temp_vente = 0;
$this->tarif_libelle_vente = "Numeros speciaux";
$this->cout_fixe_vente = ereg_replace(",",".", $this->montant);
}
else
{
*/
/* Fin Numeros speciaux */
if ($tarif_achat->cout($num, $this->cout_temp_achat, $this->cout_fixe_achat, $tarif_libelle_achat) == 0)
{
dol_syslog("CommunicationTelephonique::Cout Tarif achat manquant pour $num");
array_push($this->messages, array('warning',"Tarif achat manquant pour le numero $this->numero"));
//$error++;
}
if ($tarif_vente->cout($num, $this->cout_temp_vente, $this->cout_fixe_vente, $this->tarif_libelle_vente) == 0)
{
dol_syslog("CommunicationTelephonique::Cout Tarif vente manquant pour $num");
array_push($this->messages, array('error',"Tarif vente manquant pour le numero $this->numero"));
$error++;
}
//}
/* Specification VoIP */
if ($ligne->techno == 'voip')
{
if (substr($num,4,1) < 6)
{
$lignedest = new LigneTel($_db);
if ($lignedest->fetch("0".substr($num, -9)) == 1)
{
if ($lignedest->techno == 'voip' && ($ligne->client_comm_id == $lignedest->client_comm_id))
{
$this->remise = 0;
$this->cout_fixe_vente = 0;
$this->cout_temp_vente = 0;
$this->tarif_libelle_vente = "Appel Interne VoIP";
}
}
}
}
/* Fin VoIP */
$this->cout_achat = ( ($this->duree * $this->cout_temp_achat / 60) + $this->cout_fixe_achat);
if ($ligne->facturable == 1)
{
$this->cout_vente = ( ($this->duree * $this->cout_temp_vente / 60));
$this->cout_vente = ( $this->cout_vente * ( 1 - ($this->remise / 100)));
/* Ajouté round le 2/12/05 */
$this->cout_vente = round(($this->cout_vente + $this->cout_fixe_vente), 3);
}
else
{
$this->cout_vente = 0;
}
return $error;
}
/*
* Enregistre la ligne de communications dans
* llx_telephonie_communications_details
*
*/
function logsql($db)
{
$this->cout_achat = ereg_replace(",",".", $this->cout_achat);
$this->cout_vente = ereg_replace(",",".", $this->cout_vente);
$this->remise = ereg_replace(",",".", $this->remise);
$this->montant = ereg_replace(",",".", $this->montant);
$this->dateheure = mktime(substr($this->heure, 0,2),
substr($this->heure, 3,2),
substr($this->heure, 6,2),
substr($this->date, 3,2),
substr($this->date, 0,2),
substr($this->date, 6,4));
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_communications_details";
$sql .= " (fk_ligne,ligne, date, numero, duree";
$sql .= ", tarif_achat_temp, tarif_achat_fixe, tarif_vente_temp, tarif_vente_fixe";
$sql .= ", cout_achat, cout_vente, remise,dest, fourn_montant";
$sql .= " , fichier_cdr, fk_fournisseur, fk_telephonie_facture,ym)";
$sql .= " VALUES (";
$sql .= $this->fk_ligne.",";
$sql .= "'$this->ligne','".$db->idate($this->dateheure)."','$this->numero','$this->duree'";
$sql .= ", '$this->cout_temp_achat','$this->cout_fixe_achat','$this->cout_temp_vente','$this->cout_fixe_vente'";
$sql .= ", '$this->cout_achat','$this->cout_vente', '$this->remise'";
$sql .= ",'".addslashes($this->tarif_libelle_vente)."','$this->montant'";
$sql .= ",'".$this->fichier_cdr."','".$this->fournisseur."'";
$sql .= ",'".$this->facture_id."','".strftime("%y%m",$this->dateheure)."')";
if (! $db->query($sql))
{
dol_syslog("CommunicationTelephonique::logsql Erreur");
dol_syslog("CommunicationTelephonique::logsql ".$db->error());
return 1;
}
else
{
return 0;
}
}
/*
*
*/
function _log( $text)
{
if ($this->file_details)
{
fputs($this->file_details, $text);
}
}
/*
*
*/
function loghtml($file)
{
$this->file_details = $file;
$this->_log( '<tr>');
$this->_log( "<td>$this->index");
$this->_log( "<td>$this->ligne");
$this->_log( "<td>".$this->dest);
$this->_log( "<td>".$this->duree);
$this->_log( "<td>".$this->montant);
$this->_log( "<td>".$cout_calcul);
if (round($cout_calcul,3) <> $objp->montant)
{
_log($file_details, "<td bgcolor=pink>".round($cout_calcul,3));
$err++;
}
else
{
_log($file_details, "<td>".round($cout_calcul,3));
}
_log($file_details, "<td>$err");
}
}
?>

View File

@ -1,104 +0,0 @@
<?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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
\file htdocs/telephonie/config/index.php
\ingroup telephonie
\brief Page configuration telephonie
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
$langs->load("admin");
if (!$user->admin) accessforbidden();
if ($_GET["action"] == "set")
{
dolibarr_set_const($db, 'TELEPHONIE_COMPTE_VENTILATION', $_POST["cg"],'chaine',0,'',$conf->entity);
Header("Location: compta.php");
}
/*
*
*
*
*/
llxHeader('','Telephonie - Configuration');
print_titre("Configuration du module de Telephonie");
print "<br>";
/*
*
*
*/
print_titre("Emails");
print '<form method="post" action="compta.php?action=set">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="3" cellspacing="0" width="100%">';
print '<tr class="liste_titre">';
print '<td>Nom</td>';
print '<td>Valeur</td><td>&nbsp;</td><td>&nbsp;</td>';
print "</tr>\n";
print '<tr class="pair"><td>';
print 'Compte de ventilation</td><td>';
print TELEPHONIE_COMPTE_VENTILATION;
print '</td><td>TELEPHONIE_EMAIL_FACTURATION_EMAIL</td></tr>';
$sql = "SELECT rowid, numero, intitule";
$sql .= " FROM ".MAIN_DB_PREFIX."compta_compte_generaux";
$sql .= " ORDER BY numero ASC";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($result);
$cgs[$row[0]] = '['.$row[0].'] '.$row[1] . ' ' . $row[2];
$i++;
}
}
$html = new Form($db);
print '<tr><td>Compte</td><td>';
print $html->select_array("cg",$cgs);
print '</td><td><input type="submit"></td></tr>';
print '</table>';
print '</form>';
$db->close();
llxFooter();
?>

View File

@ -1,135 +0,0 @@
<?PHP
/* Copyright (C) 2004 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("./pre.inc.php");
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
llxHeader('','Telephonie - Ligne - Liste');
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
if ($sortorder == "") {
$sortorder="ASC";
}
if ($sortfield == "") {
$sortfield="c.nom";
}
/*
* Recherche
*
*
*/
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*
*
*/
$sql = "SELECT c.rowid, c.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_concurrents as c";
$sql .= " WHERE active = 1";
if ($_GET["search_ligne"])
{
$sel =urldecode($_GET["search_ligne"]);
$sel = ereg_replace("\.","",$sel);
$sel = ereg_replace(" ","",$sel);
$sql .= " AND l.ligne LIKE '%".$sel."%'";
}
if ($_GET["search_client"])
{
$sel =urldecode($_GET["search_client"]);
$sql .= " AND s.nom LIKE '%".$sel."%'";
}
if (strlen($_GET["statut"]))
{
$sql .= " AND l.statut = ".$_GET["statut"];
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0;
$urladd= "&amp;statut=".$_GET["statut"];
print_barre_liste("Concurrents", $page, "liste.php", $urladd, $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Nom</td>';
print "</tr>\n";
$var=True;
$ligne = new LigneTel($db);
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>";
print $obj->nom."</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,65 +0,0 @@
<?PHP
/* Copyright (C) 2004 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(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
$user->getrights('telephonie');
function llxHeader($head = "", $title="") {
global $user, $conf;
/*
*
*
*/
top_menu($head, $title);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/telephonie/index.php", "Telephonie");
$menu->add(DOL_URL_ROOT."/telephonie/simulation/fiche.php", "Simulation");
$menu->add(DOL_URL_ROOT."/telephonie/tarifs/liste.php", "Tarifs");
$menu->add(DOL_URL_ROOT."/telephonie/ligne/index.php", "Lignes");
$menu->add(DOL_URL_ROOT."/telephonie/ligne/commande/", "Commande");
$menu->add(DOL_URL_ROOT."/telephonie/facture/liste.php", "Factures");
$menu->add(DOL_URL_ROOT."/telephonie/fournisseurs.php", "Fournisseurs");
$menu->add(DOL_URL_ROOT."/telephonie/config/", "Configuration");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/config/compta.php", "Compta");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/config/mail.php", "Mails");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/config/concurrents/liste.php", "Concurrents");
if ($user->rights->telephonie->adsl->lire && TELEPHONIE_MODULE_ADSL == 1)
$menu->add_submenu(DOL_URL_ROOT."/telephonie/config/xdsl.php", "Liens xDSL");
left_menu($menu->liste);
}
?>

View File

@ -1,239 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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/telephonie/config/index.php
\ingroup telephonie
\brief Page configuration telephonie
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
$langs->load("admin");
if (!$user->admin) accessforbidden();
if ($_GET["action"] == "set")
{
for ($i = 1 ; $i < 5 ; $i++)
{
dolibarr_set_const($db, $_POST["nom$i"], $_POST["value$i"],'chaine',0,'',$conf->entity);
}
Header("Location: index.php");
}
if ($_GET["action"] == "switch")
{
dolibarr_set_const($db, $_GET["name"], $_GET["value"],'chaine',0,'',$conf->entity);
Header("Location: index.php");
}
/*
*
*
*
*/
llxHeader('','Telephonie - Configuration');
print_titre("Configuration du module de Telephonie");
print "<br>";
/*
*
*
*/
print_titre("Emails");
print '<form method="post" action="index.php?action=set">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="3" cellspacing="0" width="100%">';
print '<tr class="liste_titre">';
print '<td>Nom</td>';
print '<td>Valeur</td><td>&nbsp;</td><td>Constante</td>';
print "</tr>\n";
print '<tr class="pair"><td>';
print 'Marge minimale</td><td>';
print '<input type="hidden" name="nom1" value="TELEPHONIE_MARGE_MINI">';
print '<input type="text" name="value1" value="'.TELEPHONIE_MARGE_MINI.'" size="3" >%';
print '</td><td><input type="submit" value="'.$langs->trans('Update').'"></td><td>TELEPHONIE_MARGE_MINI</td></tr>';
print '<tr class="pair"><td>';
print 'Compte de ventilation</td><td align="center">';
print TELEPHONIE_COMPTE_VENTILATION;
print '</td><td>-</td><td>TELEPHONIE_COMPTE_VENTILATION</td></tr>';
print '<tr class="pair"><td>';
print 'Email facturation FROM</td><td align="center">';
print TELEPHONIE_EMAIL_FACTURATION_EMAIL;
print '</td><td>-</td><td>TELEPHONIE_EMAIL_FACTURATION_EMAIL</td></tr>';
print '<tr class="impair"><td>';
print 'Email facturation BCC</td><td align="center">';
print TELEPHONIE_LIGNE_COMMANDE_EMAIL_BCC;
print '</td><td>-</td><td>TELEPHONIE_LIGNE_COMMANDE_EMAIL_BCC</td></tr>';
$form = new Form($db);
/* ***************************************** */
print '<tr class="pair"><td>Groupes des commerciaux</td>';
print '<td align="left">';
$ff = array();
$ff[0] = "Aucun groupe defini";
$sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."usergroup ORDER BY nom ASC;";
$resql = $db->query($sql);
if ($resql)
{
while ($row = $db->fetch_row($resql))
{
$ff[$row[0]] = $row[1];
}
$db->free($resql);
}
$form->select_array("value4",$ff,TELEPHONIE_GROUPE_COMMERCIAUX_ID);
print '</td><td><input type="submit" value="'.$langs->trans('Update').'">';
print '</td><td>TELEPHONIE_GROUPE_COMMERCIAUX_ID</td></tr>';
print '<input type="hidden" name="nom4" value="TELEPHONIE_GROUPE_COMMERCIAUX_ID">';
/* ***************************************** */
print '<tr class="pair"><td>Fournisseur par d<>faut</td><td>';
$ff = array();
$sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur WHERE commande_active = 1 ORDER BY nom ";
$resql = $db->query($sql);
if ($resql)
{
while ($row = $db->fetch_row($resql))
{
$ff[$row[0]] = $row[1];
}
$db->free($resql);
}
$form->select_array("value2",$ff,TELEPHONIE_FOURNISSEUR_DEFAUT_ID);
print '</td><td><input type="submit" value="'.$langs->trans('Update').'">';
print '</td><td>TELEPHONIE_FOURNISSEUR_DEFAUT_ID</td></tr>';
print '<input type="hidden" name="nom2" value="TELEPHONIE_FOURNISSEUR_DEFAUT_ID">';
print '<tr class="pair"><td>Grille vente par d<>faut</td>';
$gg = array();
$gg[0] = "Aucune grille definie";
$sql = "SELECT d.rowid,d.libelle";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_tarif_grille as d";
$sql .= " WHERE d.type_tarif='vente'";
$sql .= " ORDER BY d.libelle";
$resql = $db->query($sql);
if ($resql)
{
while ($row = $db->fetch_row($resql))
{
$gg[$row[0]] = $row[1];
}
$db->free($resql);
}
print '<td>';
$form->select_array("value3",$gg,TELEPHONIE_GRILLE_VENTE_DEFAUT_ID);
print '</td><td><input type="submit" value="'.$langs->trans('Update').'"></td>';
print '<td>TELEPHONIE_GRILLE_VENTE_DEFAUT_ID</td></tr>';
print '<input type="hidden" name="nom3" value="TELEPHONIE_GRILLE_VENTE_DEFAUT_ID"></td></tr>';
print '<tr class="liste_titre">';
print '<td>Nom</td>';
print '<td>Valeur</td><td>&nbsp;</td><td>Constante</td>';
print "</tr>\n";
print '<tr class="pair"><td>Module ADSL</td>';
print '<td>';
if (TELEPHONIE_MODULE_ADSL == 1)
{
print 'oui</td><td><a href="index.php?action=switch&amp;name=TELEPHONIE_MODULE_ADSL&amp;value=0">Changer</a>';
}
else
{
print 'non</td><td><a href="index.php?action=switch&amp;name=TELEPHONIE_MODULE_ADSL&amp;value=1">Changer</a>';
}
print '</td><td>TELEPHONIE_MODULE_ADSL</td></tr>';
print '<tr class="pair"><td>Module SIMULATION</td>';
print '<td>';
if (TELEPHONIE_MODULE_SIMULATION == 1)
{
print 'oui</td><td><a href="index.php?action=switch&amp;name=TELEPHONIE_MODULE_SIMULATION&amp;value=0">Changer</a>';
}
else
{
print 'non</td><td><a href="index.php?action=switch&amp;name=TELEPHONIE_MODULE_SIMULATION&amp;value=1">Changer</a>';
}
print '</td><td>TELEPHONIE_MODULE_SIMULATION</td></tr>';
print '<tr class="pair"><td>Module GROUPES</td>';
print '<td>';
if (TELEPHONIE_MODULE_GROUPES == 1)
{
print 'oui</td><td><a href="index.php?action=switch&amp;name=TELEPHONIE_MODULE_GROUPES&amp;value=0">Changer</a>';
}
else
{
print 'non</td><td><a href="index.php?action=switch&amp;name=TELEPHONIE_MODULE_GROUPES&amp;value=1">Changer</a>';
}
print '</td><td>TELEPHONIE_MODULE_GROUPES</td></tr>';
/* ***************************************** */
print '<tr class="pair"><td>Module NUMDATA</td>';
print '<td>';
if (TELEPHONIE_MODULE_NUMDATA == 1)
{
print 'oui</td><td><a href="index.php?action=switch&amp;name=TELEPHONIE_MODULE_NUMDATA&amp;value=0">Changer</a>';
}
else
{
print 'non</td><td><a href="index.php?action=switch&amp;name=TELEPHONIE_MODULE_NUMDATA&amp;value=1">Changer</a>';
}
print '</td><td>TELEPHONIE_MODULE_NUMDATA</td></tr>';
print '</table>';
print '</form>';
$db->close();
llxFooter();
?>

View File

@ -1,96 +0,0 @@
<?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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
\file htdocs/telephonie/config/index.php
\ingroup telephonie
\brief Page configuration telephonie
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
$langs->load("admin");
if (!$user->admin) accessforbidden();
if ($_GET["action"] == "set")
{
dolibarr_set_const($db, 'TELEPHONIE_MAIL_FACTURATION_SUJET', $_POST["sujet"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, 'TELEPHONIE_MAIL_FACTURATION_SIGNATURE', $_POST["signature"],'chaine',0,'',$conf->entity);
Header("Location: mail.php");
}
/*
*
*
*
*/
llxHeader('','Telephonie - Configuration');
print_titre("Configuration du module de Telephonie");
print "<br>";
/*
*
*
*/
print_titre("Emails");
print '<form method="post" action="mail.php?action=set">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="3" cellspacing="0" width="100%">';
print '<tr class="liste_titre">';
print '<td>Nom</td>';
print '<td>Valeur</td><td>&nbsp;</td><td>&nbsp;</td>';
print "</tr>\n";
print '<tr class="pair"><td>';
print 'Compte de ventilation</td><td>';
print TELEPHONIE_MAIL_FACTURATION_SUJET;
print '</td><td>TELEPHONIE_MAIL_FACTURATION_SUJET</td></tr>';
print '<tr class="impair"><td>';
print 'Compte de ventilation</td><td>';
print nl2br(TELEPHONIE_MAIL_FACTURATION_SIGNATURE);
print '</td><td>TELEPHONIE_MAIL_FACTURATION_SIGNATURE</td></tr>';
$html = new Form($db);
print '<tr><td>Sujet</td><td>';
print '<input type="text" name="sujet" size="30" value="'.TELEPHONIE_MAIL_FACTURATION_SUJET.'"></td></tr>';
print '<tr><td>Signature</td><td>';
print '<textarea name="signature" cols="40" rows="10">'.TELEPHONIE_MAIL_FACTURATION_SIGNATURE.'</textarea></td></tr>';
print '<tr><td colspan="3" align="center"><input type="submit"></td></tr>';
print '</table>';
print '</form>';
$db->close();
llxFooter();
?>

View File

@ -1,119 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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/telephonie/config/xdsl.php
\ingroup telephonie
\brief Page configuration telephonie
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.class.php');
require_once(DOL_DOCUMENT_ROOT.'/telephonie/adsl/fournisseurxdsl.class.php');
$langs->load("admin");
$langs->load("suppliers");
$langs->load("products");
if (!$user->admin) accessforbidden();
if ($_GET["action"] == "all")
{
$sql_d = "DELETE FROM ".MAIN_DB_PREFIX."societe_perms;";
if ($resql_d = $db->query( $sql_d) )
{
$socs = array();
$sql_s = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe;";
if ( $resql_s = $db->query( $sql_s) )
{
while ($row_s = $db->fetch_row($resql_s))
{
array_push($socs, $row_s[0]);
}
$db->free($resql);
}
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user;";
if ( $resql = $db->query( $sql) )
{
while ($row = $db->fetch_row($resql))
{
foreach ($socs as $soc)
{
$sql_i = "INSERT INTO ".MAIN_DB_PREFIX."societe_perms ";
$sql_i.= " (fk_soc,fk_user,pread,pwrite,pperms) ";
$sql_i.= " VALUES ($soc,$row[0],1,1,1) ";
$resql_i = $db->query( $sql_i );
}
}
$db->free($resql);
}
}
Header("Location: perms.php");
}
/*
*
*
*
*/
llxHeader('','Téléphonie - Configuration - Permissions');
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/config/perms.php";
$head[$h][1] = $langs->trans("Specials");
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, "Definitions des permissions");
print_titre("Actions speciales");
print '<table class="noborder" cellpadding="3" cellspacing="0" width="100%">';
print '<tr class="liste_titre">';
print '<td>Actions</td>';
print '<td align="center">-</td>';
print "</tr>\n";
$var=!$var;
print "<tr $bc[$var]><td>Toutes les permissions a tout le monde</td>";
print '<td align="center"><a href="perms.php?action=all">Appliquer</a>';
print '</tr>';
print '</table>';
print '</div>';
$db->close();
llxFooter();
?>

View File

@ -1,71 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
$user->getrights('telephonie');
function llxHeader($head = "", $title="") {
global $user, $conf;
/*
*
*
*/
top_menu($head, $title);
$menu = new Menu();
if ($user->rights->telephonie->adsl->lire && TELEPHONIE_MODULE_ADSL == 1)
$menu->add(DOL_URL_ROOT."/telephonie/adsl/", "Liens xDSL");
$menu->add(DOL_URL_ROOT."/telephonie/index.php", "Telephonie");
if (TELEPHONIE_MODULE_SIMULATION == 1)
$menu->add(DOL_URL_ROOT."/telephonie/simulation/fiche.php", "Simulation");
$menu->add(DOL_URL_ROOT."/telephonie/tarifs/", "Tarifs");
$menu->add(DOL_URL_ROOT."/telephonie/ligne/index.php", "Lignes");
$menu->add(DOL_URL_ROOT."/telephonie/ligne/commande/", "Commande");
$menu->add(DOL_URL_ROOT."/telephonie/facture/liste.php", "Factures");
$menu->add(DOL_URL_ROOT."/telephonie/fournisseur/", "Fournisseurs");
$menu->add(DOL_URL_ROOT."/telephonie/config/", "Configuration");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/config/compta.php", "Compta");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/config/mail.php", "Mails");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/config/concurrents/liste.php", "Concurrents");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/config/perms.php", "Permissions");
if ($user->rights->telephonie->adsl->lire && TELEPHONIE_MODULE_ADSL == 1)
$menu->add_submenu(DOL_URL_ROOT."/telephonie/config/xdsl.php", "Liens xDSL");
left_menu($menu->liste);
}
?>

View File

@ -1,123 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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/telephonie/config/xdsl.php
\ingroup telephonie
\brief Page configuration telephonie
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.class.php');
require_once(DOL_DOCUMENT_ROOT.'/telephonie/adsl/fournisseurxdsl.class.php');
$langs->load("admin");
$langs->load("suppliers");
$langs->load("products");
if (!$user->admin) accessforbidden();
if ($_GET["action"] == "addfourn")
{
$fourn = new FournisseurXdsl($db);
$fourn->socid = $_POST["fourn"];
$fourn->create($user);
Header("Location: xdsl.php");
}
if ($_GET["action"] == "switch")
{
$fourn = new FournisseurXdsl($db);
$fourn->SwitchCommandeActive($_GET['id']);
Header("Location: xdsl.php");
}
/*
*
*
*
*/
llxHeader('','Téléphonie - Configuration - Liens xDSL');
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/config/xdsl.php";
$head[$h][1] = $langs->trans("Suppliers");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/config/xdsl_product.php";
$head[$h][1] = $langs->trans("Products");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/config/xdsl_wkf.php";
$head[$h][1] = $langs->trans("Workflow");
$h++;
dol_fiche_head($head, $hselected, "Configuration des liens xDSL");
print_titre("Fournisseurs");
print '<form method="post" action="xdsl.php?action=addfourn">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="3" cellspacing="0" width="100%">';
$form = new Form($db);
$fourn = new Fournisseur($db,0,$user);
$fourns = $fourn->ListArray();
$xfourn = new FournisseurXdsl($db,0,$user);
$xfourns = $xfourn->ListArray();
/* ***************************************** */
print '<tr class="pair"><td>Ajouter un fournisseur</td>';
print '<td align="left">';
$form->select_array("fourn",$fourns);
print '</td><td><input type="submit" value="'.$langs->trans('Add').'">';
print '</td></tr>';
print '<tr class="liste_titre">';
print '<td>Nom</td>';
print '<td align="center">Commande possible</td><td>&nbsp;</td>';
print "</tr>\n";
foreach ($xfourns as $id => $name)
{
$var=!$var;
print "<tr $bc[$var]><td>".$name['name'].'</td>';
print '<td align="center">'.$langs->trans($yesno[$name['commande_active']]).'</td>';
print '<td><a href="xdsl.php?action=switch&amp;id='.$id.'">Changer</a>';
print '</tr>';
}
print '</table>';
print '</form></div>';
$db->close();
llxFooter();
?>

View File

@ -1,136 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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/telephonie/config/xdsl.php
\ingroup telephonie
\brief Page configuration telephonie
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.class.php');
require_once(DOL_DOCUMENT_ROOT.'/telephonie/adsl/productxdsl.class.php');
$langs->load("admin");
$langs->load("suppliers");
$langs->load("products");
if (!$user->admin) accessforbidden();
if ($_GET["action"] == "addproduct")
{
$fourn = new ProductXdsl($db);
$fourn->prodid = $_POST["prod"];
$fourn->intitule = $_POST["intitule"];
$fourn->create($user);
Header("Location: xdsl_product.php");
}
if ($_GET["action"] == "switch")
{
$fourn = new ProductXdsl($db);
$fourn->SwitchCommandeActive($_GET['id']);
Header("Location: xdsl_product.php");
}
/*
*
*
*
*/
llxHeader('','Téléphonie - Configuration - Liens xDSL');
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/config/xdsl.php";
$head[$h][1] = $langs->trans("Suppliers");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/config/xdsl_product.php";
$head[$h][1] = $langs->trans("Products");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/config/xdsl_wkf.php";
$head[$h][1] = $langs->trans("Workflow");
$h++;
dol_fiche_head($head, $hselected, "Configuration des liens xDSL");
$form = new Form($db);
print_titre($langs->trans("Products"));
print '<form method="post" action="xdsl_product.php?action=addproduct">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="3" cellspacing="0" width="100%">';
$prods = array();
$sql = "SELECT rowid, label";
$sql.= " FROM ".MAIN_DB_PREFIX."product as p";
$sql.= " WHERE p.fk_product_type = 1";
$resql=$db->query($sql);
if ($resql)
{
while ($obj=$db->fetch_object($resql))
{
$prods[$obj->rowid]=stripslashes($obj->label);
}
}
$db->free($resql);
$xfourn = new ProductXdsl($db,0,$user);
$xfourns = $xfourn->ListArray();
/* ***************************************** */
print '<tr class="pair"><td>Ajouter un liens depuis les services</td>';
print '<td align="left">';
print '</td><td><input name="intitule"></td><td>';
$form->select_array("prod",$prods);
print '<input type="submit" value="'.$langs->trans('Add').'">';
print '</td></tr>';
print '<tr class="liste_titre">';
print '<td>Nom</td>';
print '<td align="center">Commande possible</td><td>&nbsp;</td><td>&nbsp;</td>';
print "</tr>\n";
foreach ($xfourns as $id => $name)
{
$var=!$var;
print "<tr $bc[$var]><td>".$name['intitule'].'</td>';
print '<td align="center">'.$langs->trans($yesno[$name['commande_active']]).'</td>';
print '<td><a href="xdsl_product.php?action=switch&amp;id='.$id.'">Changer</a>';
print '<td>&nbsp;</td></tr>';
}
print '</table>';
print '</form></div>';
$db->close();
llxFooter();
?>

View File

@ -1,154 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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/telephonie/config/xdsl.php
\ingroup telephonie
\brief Page configuration telephonie
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/fourn/fournisseur.class.php');
require_once(DOL_DOCUMENT_ROOT.'/telephonie/adsl/ligneadsl.class.php');
require_once(DOL_DOCUMENT_ROOT.'/telephonie/adsl/fournisseurxdsl.class.php');
require_once(DOL_DOCUMENT_ROOT.'/telephonie/workflowtel.class.php');
$langs->load("admin");
$langs->load("suppliers");
$langs->load("products");
if (!$user->admin) accessforbidden();
$ligne = new LigneAdsl($db);
if ($_GET["action"] == "add")
{
$wkf = new WorkflowTelephonie($db);
$wkf->create("xdsl",$_POST["wkf_user"],$_POST["wkf_statut"]);
Header("Location: xdsl_wkf.php");
}
if ($_GET["action"] == "delete")
{
$wkf = new WorkflowTelephonie($db);
$wkf->delete("xdsl",$_GET["wkf_user"],$_GET["wkf_statut"]);
Header("Location: xdsl_wkf.php");
}
/*
*
*
*
*/
llxHeader('','Téléphonie - Configuration - Liens xDSL - Workflow');
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/config/xdsl.php";
$head[$h][1] = $langs->trans("Suppliers");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/config/xdsl_product.php";
$head[$h][1] = $langs->trans("Products");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/config/xdsl_wkf.php";
$head[$h][1] = $langs->trans("Workflow");
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, "Configuration des liens xDSL");
print_titre("Workflow");
print '<form method="post" action="xdsl_wkf.php?action=add">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder" cellpadding="3" cellspacing="0" width="100%">';
$form = new Form($db);
$fourn = new Fournisseur($db,0,$user);
$fourns = $fourn->ListArray();
$xfourn = new FournisseurXdsl($db,0,$user);
$xfourns = $xfourn->ListArray();
$uss = array();
$sql = "SELECT u.rowid, u.firstname, u.name";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " WHERE u.rowid = ug.fk_user";
$sql .= " AND ug.fk_usergroup = '".TELEPHONIE_GROUPE_COMMERCIAUX_ID."'";
$sql .= " ORDER BY name ";
if ( $resql = $db->query( $sql) )
{
while ($row = $db->fetch_row($resql))
{
$uss[$row[0]] = $row[1] . " " . $row[2];
}
$db->free($resql);
}
/* ***************************************** */
print '<tr class="pair"><td>Ajouter une alerte pour l\'utilisateur</td>';
print '<td align="left">';
$form->select_array("wkf_user",$uss);
print ' sur l\'action ';
$form->select_array("wkf_statut",$ligne->statuts);
print '</td><td><input type="submit" value="'.$langs->trans('Add').'">';
print '</td></tr>';
print '<tr class="liste_titre">';
print '<td>Utilisateur</td><td>Email</td>';
print '<td>Statut notifie</td><td>&nbsp;</td>';
print "</tr>\n";
$sql = "SELECT u.rowid, u.firstname, u.name, u.email, w.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."telephonie_workflow as w";
$sql .= " WHERE u.rowid = w.fk_user AND w.module = 'xdsl'";
$sql .= " ORDER BY u.name, u.firstname ";
if ( $resql = $db->query( $sql) )
{
while ($row = $db->fetch_row($resql))
{
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.$row[1].' '.$row[2].'</td>';
print '<td>'.$row[3].'</td>';
print '<td>'.$ligne->statuts[$row[4]].'</td>';
print '<td><a href="xdsl_wkf.php?action=delete&amp;wkf_user='.$row[0].'&amp;wkf_statut='.$row[4].'">';
print img_delete();
print '</a></td></tr>';
}
$db->free($resql);
}
print '</table>';
print '</form></div>';
$db->close();
llxFooter();
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,226 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
if (!$user->rights->telephonie->lire)
accessforbidden();
llxHeader('','Telephonie - Contrats');
/*
* Sécurité accés client
*/
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
/*
* Mode Liste
*
*
*
*/
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="30%" valign="top">';
print '<form method="GET" action="'.DOL_URL_ROOT.'/telephonie/contrat/liste.php">';
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Recherche contrat</td>';
print "</tr>\n";
print "<tr $bc[1]>";
print '<td>Numéro <input name="search_contrat" size="12"></td></tr>';
print '</table></form>';
print '<br />';
/* Consultations */
$sql = "SELECT s.rowid as socid, s.nom, max(sc.datec) as dam, c.ref, c.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ",".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= ",".MAIN_DB_PREFIX."telephonie_contrat_consult as sc";
$sql .= " WHERE s.rowid = c.fk_soc";
$sql .= " AND c.rowid = sc.fk_contrat";
$sql .= " AND sc.fk_user = ".$user->id;
$sql .= " GROUP BY c.rowid";
$sql .= " ORDER BY dam DESC LIMIT 10";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td colspan="2">'.min(10,$num).' dernières fiche contrat consultées</td></tr>';
$var=True;
while ($obj = $db->fetch_object($resql))
{
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
$nom = $obj->nom;
if (strlen($obj->nom) > 33)
$nom = substr($obj->nom,0,30)."...";
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.stripslashes($nom).'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/contrat/fiche.php?id='.$obj->rowid.'">'.$obj->ref.'</a></td>';
print "</tr>\n";
$var=!$var;
}
print "</table>";
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
/* ===== */
print '<br />';
$sql = "SELECT distinct statut, count(*) as cc";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat as l";
$sql .= ",".MAIN_DB_PREFIX."societe_perms as sp";
$sql .= " WHERE l.fk_client_comm = sp.fk_soc";
$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1";
$sql .= " GROUP BY statut";
if ($db->query($sql))
{
$num = $db->num_rows();
$i = 0;
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Contrats</td><td align="center">Nb</td><td>&nbsp;</td>';
print "</tr>\n";
$var=True;
$contrat = new TelephonieContrat($db);
while ($i < $num)
{
$obj = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
print "<td>".$contrat->statuts[$obj->statut]."</td>\n";
print '<td align="center">'.$obj->cc."</td>\n";
print '<td><a href="liste.php?statut='.$obj->statut.'">';
print '<img border="0" src="statut'.$obj->statut.'.png"></a></td>';
print "</tr>\n";
$values[$obj->statut] = $obj->cc;
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td><td valign="top" width="70%">';
$sql = "SELECT c.ref, c.rowid, c.statut";
$sql .= " ,s.rowid as socid, sf.rowid as sfidp, sf.nom as nom_facture,s.nom";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."societe as sf";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= " , ".MAIN_DB_PREFIX."societe_perms as sp";
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.fk_soc_facture = sf.rowid";
$sql .= " AND s.rowid = sp.fk_soc";
$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1";
$sql .= " ORDER BY date_creat DESC LIMIT 10;";
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0;
print"\n<!-- debut table -->\n";
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td>Référence</td>';
print '<td>Client (Agence/Filiale)</td>';
print '<td>Client facturé</td>';
print "</tr>\n";
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<img src="statut'.$obj->statut.'.png">&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/ligne/fiche.php?id='.$obj->rowid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="fiche.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.stripslashes($obj->nom).'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$obj->sfidp.'">'.stripslashes($obj->nom_facture).'</a></td>';
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td></tr>';
print '</table>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,208 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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 "./pre.inc.php";
require_once DOL_DOCUMENT_ROOT."/telephonie/dolibarrmail.class.php";
$mesg = '';
llxHeader("","","Fiche Contrat");
if ($_GET["id"])
{
$client_comm = new Societe($db);
$contrat = new TelephonieContrat($db);
if ($contrat->fetch($_GET["id"]) == 0)
{
$result = 1;
$client_comm->fetch($contrat->client_comm_id, $user);
}
else
{
print "Erreur";
}
if (!$client_comm->perm_read)
{
print "Lecture non authorisée";
}
if ( $result && $client_comm->perm_read)
{
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/fiche.php?id=".$contrat->id;
$head[$h][1] = $langs->trans("Contrat");
$h++;
$nser = $contrat->count_associated_services();
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/services.php?id=".$contrat->id;
if ($nser > 0)
{
$head[$h][1] = $langs->trans("Services")." (".$nser.")";
}
else
{
$head[$h][1] = $langs->trans("Services");
}
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/stats.php?id=".$contrat->id;
$head[$h][1] = $langs->trans("Stats");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/info.php?id=".$contrat->id;
$head[$h][1] = $langs->trans("Infos");
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, 'Contrat : '.$contrat->ref);
print_fiche_titre('Fiche Contrat', $mesg);
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
$client_comm = new Societe($db, $contrat->client_comm_id);
$client_comm->fetch($contrat->client_comm_id);
print '<tr><td width="20%">Référence</td><td>'.$contrat->ref.'</td>';
print '<td>Facturé : '.$contrat->facturable.'</td></tr>';
print '<tr><td width="20%">Client</td><td>';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$client_comm->id.'">';
print $client_comm->nom.'</a></td><td>'.$client_comm->code_client;
print '</td></tr>';
$commercial = new User($db, $contrat->commercial_sign_id);
$commercial->fetch();
print '<tr><td width="20%">Commercial Signature</td>';
print '<td colspan="2">'.$commercial->fullname.'</td></tr>';
$commercial_suiv = new User($db, $contrat->commercial_suiv_id);
$commercial_suiv->fetch();
print '<tr><td width="20%">Commercial Suivi</td>';
print '<td colspan="2">'.$commercial_suiv->fullname.'</td></tr>';
$cuser_suiv = new User($db, $contrat->user_creat);
$cuser_suiv->fetch();
print '<tr><td width="20%">Créé par</td>';
print '<td colspan="2">'.$cuser_suiv->fullname;
print '</td></tr>';
print '<tr><td width="20%">Créé le</td>';
print '<td colspan="2">'.strftime("%e %B %Y",$contrat->date_creat);
print '</td></tr>';
print "</table><br />";
$sql = "SELECT s.rowid as socid, s.nom, p.fk_contrat, p.montant, p.avance_duree, p.avance_pourcent";
$sql .= ", p.rem_pour_prev, p.rem_pour_autr, p.mode_paiement";
$sql .= ", u.name, u.firstname, u.login";
$sql .= " , ".$db->pdate("p.datepo") . " as datepo";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_priseordre as p";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE p.fk_commercial =u.rowid";
$sql .= " AND p.fk_user =u.rowid";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND p.fk_contrat = c.rowid";
$sql .= " AND c.rowid =".$_GET["id"];
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print_barre_liste("Prises d'ordre", $page, "commercialpo.php","&amp;commid=".$_GET["commid"], $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Affecté à</td>';
print '<td align="center">Date</td>';
print '<td align="right">Montant</td>';
print '<td align="center">MdP</td>';
print '<td align="center">Saisi par</td>';
print "</tr>\n";
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.$obj->firstname.' '.$obj->name."</td>\n";
print '<td align="center">'.strftime("%e %b %Y",$obj->datepo)."</td>\n";
print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n";
if ($obj->mode_paiement == 'pre')
{
print '<td align="center">Prelev</td>';
}
else
{
print '<td align="center">Autre</td>';
}
print '<td align="center">'.$obj->login.'</td>';
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
}
}
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,159 +0,0 @@
<?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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
llxHeader('','Telephonie - Contrats - Liste');
/*
*
*
*/
if ($page == -1) { $page = 0 ; }
if ($sortorder == "") $sortorder="ASC";
if ($sortfield == "") $sortfield="c.statut";
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*
*
*/
$sql = "SELECT c.rowid, c.ref, s.rowid as socid, c.statut, s.nom ";
$sql .= ", sf.rowid as sfidp, sf.nom as sfnom";
$sql .= ", sa.rowid as saidp, sa.nom as sanom";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."societe as sf";
$sql .= " , ".MAIN_DB_PREFIX."societe as sa";
$sql .= " , ".MAIN_DB_PREFIX."societe_perms as sp";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= " WHERE c.fk_client_comm = s.rowid";
$sql .= " AND c.fk_soc = sa.rowid";
$sql .= " AND c.fk_soc_facture = sf.rowid";
$sql .= " AND c.fk_client_comm = sp.fk_soc";
$sql .= " AND sp.fk_user = ".$user->id." AND sp.pread = 1";
if ($_GET["search_contrat"])
{
$sel = urldecode($_GET["search_contrat"]);
$sql .= " AND c.ref LIKE '%".$sel."%'";
}
if ($_GET["search_client"])
{
$sel = urldecode($_GET["search_client"]);
$sql .= " AND s.nom LIKE '%".$sel."%'";
}
if ($_GET["search_client_facture"])
{
$sel =urldecode($_GET["search_client_facture"]);
$sql .= " AND sf.nom LIKE '%".$sel."%'";
}
if (strlen($_GET["statut"]))
{
$sql .= " AND c.statut = ".$_GET["statut"];
}
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
$i = 0;
$urladd= "&amp;statut=".$_GET["statut"];
print_barre_liste("Contrats", $page, "liste.php", $urladd, $sortfield, $sortorder, '', $num);
print"\n<!-- debut table -->\n";
print '<form action="liste.php" method="GET">'."\n";
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print_liste_field_titre("Ref","liste.php","c.ref");
print_liste_field_titre("Client","liste.php","s.nom");
print_liste_field_titre("Client (Agence/Filiale)","liste.php","sa.nom");
print '<td>Client facturé</td>';
print '<td align="center">-</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td><input type="text" name="search_contrat" value="'. $_GET["search_contrat"].'" size="10"></td>';
print '<td><input type="text" name="search_client" value="'. $_GET["search_client"].'" size="10"></td>';
print '<td><input type="text" name="search_client_agence" value="'. $_GET["search_client_agence"].'" size="10"></td>';
print '<td><input type="text" name="search_client_facture" value="'. $_GET["search_client_facture"].'" size="10"></td>';
print '<td><input type="submit" class="button" value="'.$langs->trans("Search").'""></td>';
print '</tr>';
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]><td>";
print '<img src="statut'.$obj->statut.'.png">&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/contrat/fiche.php?id='.$obj->rowid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="fiche.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.stripslashes($obj->nom).'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.stripslashes($obj->sanom).'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/soc.php?socid='.$obj->sfidp.'">'.stripslashes($obj->sfnom).'</a></td>';
print '<td align="center">-</td>';
print "</tr>\n";
$i++;
}
print "</table>";
print '</form>';
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,77 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("../../main.inc.php");
require(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
require(DOL_DOCUMENT_ROOT."/telephonie/telephonie.contrat.class.php");
require(DOL_DOCUMENT_ROOT."/telephonie/telephonie.client.class.php");
$user->getrights('telephonie');
function llxHeader($head = "", $title="") {
global $user;
/*
*
*
*/
top_menu($head, $title);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/telephonie/index.php", "Telephonie");
if (TELEPHONIE_MODULE_SIMULATION == 1)
$menu->add(DOL_URL_ROOT."/telephonie/simulation/fiche.php", "Simulation");
$menu->add(DOL_URL_ROOT."/telephonie/client/index.php", "Clients");
if ($user->rights->telephonie->ligne->creer)
$menu->add_submenu(DOL_URL_ROOT."/telephonie/client/new.php", "Nouveau client");
$menu->add(DOL_URL_ROOT."/telephonie/contrat/", "Contrats");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/contrat/liste.php", "Liste");
if ($user->rights->telephonie->ligne->creer)
$menu->add_submenu(DOL_URL_ROOT."/telephonie/contrat/fiche.php?action=create", "Nouveau contrat");
$menu->add(DOL_URL_ROOT."/telephonie/ligne/index.php", "Lignes");
if ($user->rights->telephonie->ligne_commander)
$menu->add(DOL_URL_ROOT."/telephonie/ligne/commande/", "Commandes");
if ($user->rights->telephonie->stats->lire)
$menu->add(DOL_URL_ROOT."/telephonie/stats/", "Statistiques");
if ($user->rights->telephonie->facture->lire)
$menu->add(DOL_URL_ROOT."/telephonie/facture/", "Factures");
$menu->add(DOL_URL_ROOT."/telephonie/tarifs/", "Tarifs");
$menu->add(DOL_URL_ROOT."/telephonie/distributeurs/", "Distributeurs");
if ($user->rights->telephonie->ca->lire)
$menu->add(DOL_URL_ROOT."/telephonie/ca/", "Chiffre d'affaire");
left_menu($menu->liste);
}
?>

View File

@ -1,334 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require "./pre.inc.php";
$mesg = '';
if ($_POST["action"] == 'addservice' && $user->rights->telephonie->service->affecter)
{
$contrat = new TelephonieContrat($db);
$contrat->id= $_GET["id"];
if ( $contrat->add_service($user, $_POST["service_id"]) == 0)
{
Header("Location: services.php?id=".$contrat->id);
}
}
if ($_GET["action"] == 'rmservice' && $user->rights->telephonie->service->affecter)
{
$contrat = new TelephonieContrat($db);
$contrat->id= $_GET["id"];
if ( $contrat->remove_service($user, $_GET["service_id"]) == 0)
{
Header("Location: services.php?id=".$contrat->id);
}
}
llxHeader("","","Fiche Contrat - Services");
if ($_GET["id"])
{
$client_comm = new Societe($db);
$contrat = new TelephonieContrat($db);
if ($contrat->fetch($_GET["id"]) == 0)
{
$result = 1;
$client_comm->fetch($contrat->client_comm_id, $user);
}
else
{
print "Erreur";
}
if (!$client_comm->perm_read)
{
print "Lecture non authorisée";
}
if ( $result && $client_comm->perm_read)
{
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/fiche.php?id=".$contrat->id;
$head[$h][1] = $langs->trans("Contrat");
$h++;
$nser = $contrat->count_associated_services();
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/services.php?id=".$contrat->id;
if ($nser > 0)
{
$head[$h][1] = $langs->trans("Services")." (".$nser.")";
}
else
{
$head[$h][1] = $langs->trans("Services");
}
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/stats.php?id=".$contrat->id;
$head[$h][1] = $langs->trans("Stats");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/info.php?id=".$contrat->id;
$head[$h][1] = $langs->trans("Infos");
$h++;
dol_fiche_head($head, $hselected, 'Contrat : '.$contrat->ref);
print_fiche_titre('Fiche Contrat', $mesg);
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="20%">Référence</td><td>'.$contrat->ref.'</td>';
print '<td>Facturé : '.$contrat->facturable.'</td></tr>';
print '<tr><td width="20%">Client</td><td>';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$client_comm->id.'">';
print $client_comm->nom.'</a></td><td>'.$client_comm->code_client;
print '</td></tr>';
if ($contrat->client_comm_id <> $contrat->client_id)
{
$client = new Societe($db, $contrat->client_id);
$client->fetch($contrat->client_id);
print '<tr><td width="20%">Client (Agence/Filiale)</td><td colspan="2">';
print $client->nom.'<br />';
print $client->cp . " " .$client->ville;
print '</td></tr>';
}
$commercial = new User($db, $contrat->commercial_sign_id);
$commercial->fetch();
print '<tr><td width="20%">Commercial Signature</td>';
print '<td colspan="2">'.$commercial->fullname.'</td></tr>';
$commercial_suiv = new User($db, $contrat->commercial_suiv_id);
$commercial_suiv->fetch();
print '<tr><td width="20%">Commercial Suivi</td>';
print '<td colspan="2">'.$commercial_suiv->fullname.'</td></tr>';
/* Contacts */
print '<tr><td valign="top" width="20%">Contact facture</td>';
print '<td valign="top" colspan="2">';
$sql = "SELECT c.rowid, c.name, c.firstname, c.email ";
$sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c";
$sql .= ",".MAIN_DB_PREFIX."telephonie_contrat_contact_facture as cf";
$sql .= " WHERE c.rowid = cf.fk_contact AND cf.fk_contrat = ".$contrat->id." ORDER BY name ";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
print $row[1] . " " . $row[2] . " &lt;".$row[3]."&gt;<br />";
$i++;
}
}
$db->free();
}
else
{
print $sql;
}
print '</td></tr>';
/* Fin Contacts */
print "</table><br />";
/* Services */
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
$sql = "SELECT s.libelle, s.statut";
$sql .= " , cs.rowid as serid, s.montant, cs.montant as montant_fac";
$sql .= " , ".$db->pdate("cs.date_creat") . " as date_creat";
$sql .= " , u.name, u.firstname";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_service as cs";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_service as s";
$sql .= " , ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE cs.fk_service = s.rowid";
$sql .= " AND cs.fk_user_creat = u.rowid";
$sql .= " AND cs.fk_contrat = ".$contrat->id;
if ( $db->query( $sql) )
{
$numlignes = $db->num_rows();
if ( $numlignes > 0 )
{
$i = 0;
$ligne = new LigneTel($db);
print '<tr class="liste_titre"><td>Service</td>';
print '<td align="right">Montant Facturé</td>';
print '<td align="right">Montant du service</td>';
if ($user->rights->telephonie->service->affecter)
print "<td>&nbsp;</td>\n";
print '<td align="center">Ajouté par</td>';
print '<td align="center">Ajouté le</td></tr>';
while ($i < $numlignes)
{
$obj = $db->fetch_object($i);
$var=!$var;
print "<tr $bc[$var]><td>";
print '<img src="../graph'.$obj->statut.'.png">&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/service/fiche.php?id='.$obj->serid.'">'.$obj->libelle."</a></td>\n";
print '<td align="right">'.price($obj->montant_fac)." euros HT</td>\n";
print '<td align="right">'.price($obj->montant)." euros HT</td>\n";
if ($user->rights->telephonie->service->affecter)
{
print '<td align="center"><a href="services.php?id='.$contrat->id.'&amp;action=rmservice&amp;service_id='.$obj->serid.'">';
print img_delete();
print "</a></td>";
}
print '<td align="center">'.$obj->firstname.' '.$obj->name.'</td>';
print '<td align="center">'.strftime("%d/%m/%y",$obj->date_creat).'</td>';
print "</tr>\n";
$i++;
}
}
$db->free();
}
else
{
print $db->error();
print $sql;
}
print "</table>";
}
/*
* Service
*
*
*/
if ($user->rights->telephonie->service->affecter)
{
print_fiche_titre('Ajouter un service', $mesg);
print '<form action="services.php?id='.$contrat->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addservice">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td valign="top" width="20%">Service</td><td valign="top" colspan="2">';
$sql = "SELECT rowid, libelle ";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_service ";
$sql .= " WHERE statut = 1";
if ( $db->query( $sql) )
{
print '<select name="service_id">';
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
print '<option value="'.$row[0] .'"';
print '>'.$row[1];
$i++;
}
}
$db->free();
print '</select>';
}
else
{
print $sql;
}
print '</td></tr>';
print '<tr><td colspan="3" align="center">';
if ($num > 0)
{
print '<input type="submit" value="Ajouter">';
}
print '</td></tr>';
print '</table>';
print '</form>';
}
/*
*
*
*
*/
print '</div>';
}
}
else
{
print "Error";
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<br>\n<div class=\"tabsAction\">\n";
if ($_GET["action"] == '')
{
}
print "</div>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,199 +0,0 @@
<?PHP
/* Copyright (C) 2004-2007 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("./pre.inc.php");
llxHeader("","Téléphonie - Contrat");
/* Affichage */
if ($_GET["id"])
{
$client_comm = new Societe($db);
$contrat = new TelephonieContrat($db);
if ($contrat->fetch($_GET["id"]) == 0)
{
$result = 1;
}
$client_comm->fetch($contrat->client_comm_id, $user);
if (!$client_comm->perm_read)
{
print "Lecture non authorisée";
}
if ( $result && $client_comm->perm_read)
{
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{
$h=0;
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/fiche.php?id=".$contrat->id;
$head[$h][1] = $langs->trans("Contrat");
$h++;
$nser = $contrat->count_associated_services();
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/services.php?id=".$contrat->id;
if ($nser > 0)
{
$head[$h][1] = $langs->trans("Services")." (".$nser.")";
}
else
{
$head[$h][1] = $langs->trans("Services");
}
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/stats.php?id=".$contrat->id;
$head[$h][1] = $langs->trans("Stats");
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/contrat/info.php?id=".$contrat->id;
$head[$h][1] = $langs->trans("Infos");
$h++;
dol_fiche_head($head, $hselected, 'Contrat : '.$contrat->ref);
print_fiche_titre('Fiche Contrat', $mesg);
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
$client_comm = new Societe($db, $contrat->client_comm_id);
$client_comm->fetch($contrat->client_comm_id);
print '<tr><td width="20%">Référence</td><td>'.$contrat->ref.'</td>';
print '<td colspan="2">Facturé : '.$contrat->facturable.'</td></tr>';
print '<tr><td width="20%">Client</td><td>';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$client_comm->id.'">';
print $client_comm->nom.'</a></td><td colspan="2">'.$client_comm->code_client;
print '</td></tr>';
$commercial = new User($db, $contrat->commercial_sign_id);
$commercial->fetch();
$commercial_suiv = new User($db, $contrat->commercial_suiv_id);
$commercial_suiv->fetch();
print '<tr><td width="20%">Commercial Suivi/Signature</td>';
print '<td colspan="3">'.$commercial_suiv->fullname.'/'.$commercial->fullname.'</td></tr>';
print "</table><br />";
print '<table class="border" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="50%" valign="top" align="center">';
$mesg_no_graph = 'Nous avons pas assez de données à ce jour pour générer ce graphique.';
$img_root = DOL_DATA_ROOT."/graph/".substr($contrat->id,-1)."/telephonie/contrat/";
$file = $img_root.$contrat->id."/graphca.png";
if (file_exists($file))
{
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
//print '<img src="'.DOL_URL_ROOT.'/viewimage.php?graph='.$file.'" alt="CA Mensuel">';
}
else
{
print $mesg_no_graph;
}
print '</td><td width="50%" valign="top" align="center">';
$file = $img_root.$contrat->id."/graphgain.png";
if (file_exists($file) && $user->rights->telephonie->ligne->gain)
{
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
}
else
{
print $mesg_no_graph;
}
print '</td></tr>';
print '<tr><td width="50%" valign="top" align="center">';
$file = $img_root.$contrat->id."/graphappelsdureemoyenne.png";
if (file_exists($file))
{
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="dureemoyenne">';
}
else
{
print $mesg_no_graph;
}
print '</td><td width="50%" valign="top" align="center">';
print "&nbsp;";
print '</td></tr>';
print '<tr><td width="50%" valign="top" align="center">';
$file = $img_root.$contrat->id."/nb-comm-mensuel.png";
if (file_exists($file))
{
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
}
else
{
print $mesg_no_graph;
}
print '</td><td width="50%" valign="top" align="center">';
$file = $img_root.$contrat->id."/nb-minutes-mensuel.png";
if (file_exists($file))
{
print '<img src="'.DOL_URL_ROOT.'/telephonie/showgraph.php?graph='.$file.'" alt="CA Mensuel">';
}
else
{
print $mesg_no_graph;
}
print '</td></tr></table>';
}
}
}
else
{
print "Erreur";
}
print '</div>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

View File

@ -1,100 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if (!$user->rights->telephonie->lire) accessforbidden();
if ($user->distributeur_id && $user->responsable_distributeur_id == 0)
{
$_GET["id"] = $user->id;
}
if ($user->responsable_distributeur_id > 0)
{
if (!in_array($_GET["id"], $user->responsable_distributeur_commerciaux))
{
accessforbidden();
}
}
$year = strftime("%Y",time());
llxHeader('','Telephonie - Distributeur - Commercial');
/*
*
*/
$h = 0;
$year = strftime("%Y",time());
if (strftime("%m",time()) == 1)
{
$year = $year -1;
}
if ($_GET["year"] > 0)
{
$year = $_GET["year"];
}
if ($_GET["id"] && $_GET["did"])
{
$commercial = new User($db, $_GET["id"]);
$commercial->fetch();
$distri = new DistributeurTelephonie($db);
$distri->fetch($_GET["did"]);
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
$head[$h][1] = $distri->nom;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/comm/commercial.php?id='.$_GET["id"].'&amp;did='.$_GET["did"];
$head[$h][1] = $commercial->prenom ." ". $commercial->nom;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/comm/ca.php?id='.$commercial->id.'&amp;did='.$_GET["did"];
$head[$h][1] = "Chiffre d'affaire";
$hselected = $h;
$h++;
/*
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
$head[$h][1] = "Statistiques";
$h++;
*/
dol_fiche_head($head, $hselected, "Distributeur");
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="50%" valign="top">';
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=telephoniegraph&file=commercials/'.$commercial->id.'/ca.mensuel.'.$year.'.png" alt="CA" title="CA"><br /><br />'."\n";
print '</td><td width="50%" valign="top"><br />';
print '</td></tr>';
print '</table></div>';
$db->close();
}
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,146 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if (!$user->rights->telephonie->lire) accessforbidden();
if ($user->distributeur_id && $user->responsable_distributeur_id == 0)
{
$_GET["id"] = $user->id;
}
if ($user->responsable_distributeur_id > 0)
{
if (!in_array($_GET["id"], $user->responsable_distributeur_commerciaux))
{
accessforbidden();
}
}
llxHeader('','Telephonie - Distributeur - Commercial');
/*
*
*/
$h = 0;
$year = strftime("%Y",time());
if ($_GET["id"] && $_GET["did"])
{
$commercial = new User($db, $_GET["id"]);
$commercial->fetch();
$distri = new DistributeurTelephonie($db);
$distri->fetch($_GET["did"]);
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
$head[$h][1] = $distri->nom;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/comm/commercial.php?id='.$_GET["id"].'&amp;did='.$_GET["did"];
$head[$h][1] = $commercial->prenom ." ". $commercial->nom;
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/comm/ca.php?id='.$commercial->id.'&amp;did='.$_GET["did"];
$head[$h][1] = "Chiffre d'affaire";
$h++;
/*
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
$head[$h][1] = "Statistiques";
$h++;
*/
dol_fiche_head($head, $hselected, "Distributeur");
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="50%" valign="top">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td>Date</td><td align="right">'."Prise d'ordre mensuelle</td></tr>";
$sql = "SELECT ".$db->pdate("p.datepo") . " as datepo, sum(p.montant)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_priseordre as p";
$sql .= " WHERE p.fk_commercial =".$commercial->id;
$sql .= " GROUP BY date_format(datepo,'%Y%m') DESC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.strftime("%m/%Y",$row[0]).'</td>';
print '<td align="right">'.price($row[1]).' HT</td>';
$i++;
}
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
print '</table><br />';
print '</td><td width="50%" valign="top">';
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=telephoniegraph&file=commercials/'.$commercial->id.'/po.'.$year.'.mensuel.png" alt="Nouveaux clients (moy)" title="Nouveaux clients (moy)"><br /><br />'."\n";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=telephoniegraph&file=commercials/'.$commercial->id.'/clients.hebdomadaire.png" alt="Nouveaux clients" title="Nouveaux clients"><br /><br />'."\n";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=telephoniegraph&file=commercials/'.$commercial->id.'/clientsmoyenne.hebdomadaire.png" alt="Nouveaux clients (moy)" title="Nouveaux clients (moy)"><br /><br />'."\n";
print '</td></tr>';
print '</table></div>';
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n";
if ($_GET["action"] == '' && $user->admin)
{
print "<a class=\"butAction\" href=\"fiche.php?action=create_commercial&amp;distri=".$distri->id."\">".$langs->trans("Nouveau commercial")."</a>";
}
print "</div><br>";
$db->close();
}
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,152 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("../../../main.inc.php");
$user->getrights('telephonie');
$user->distributeur_id = 0;
$user->responsable_distributeur_id = 0;
$user->responsable_distributeur_commerciaux = array();
require DOL_DOCUMENT_ROOT.'/telephonie/distributeurtel.class.php';
require DOL_DOCUMENT_ROOT.'/telephonie/telephonie.commercial.class.php';
$sql = "SELECT fk_distributeur";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur_commerciaux";
$sql .= " WHERE fk_user=".$user->id;
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$user->distributeur_id = $row[0];
}
$sql = "SELECT fk_distributeur";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur_responsable";
$sql .= " WHERE fk_user=".$user->id;
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$user->responsable_distributeur_id = $row[0];
}
if ($user->responsable_distributeur_id > 0)
{
$sql = "SELECT fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur_commerciaux";
$sql .= " WHERE fk_distributeur=".$user->responsable_distributeur_id;
$resql = $db->query($sql);
if ($resql)
{
while ($row = $db->fetch_row($resql))
{
array_push($user->responsable_distributeur_commerciaux, $row[0]);
}
}
}
function llxHeader($head = "", $title="") {
global $user, $conf, $db;
/*
*
*
*/
top_menu($head, $title);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/telephonie/index.php", "Telephonie");
$menu->add(DOL_URL_ROOT."/telephonie/client/index.php", "Clients");
$menu->add(DOL_URL_ROOT."/telephonie/contrat/", "Contrats");
$menu->add(DOL_URL_ROOT."/telephonie/ligne/index.php", "Lignes");
if ($user->rights->telephonie->ligne_commander)
$menu->add(DOL_URL_ROOT."/telephonie/ligne/commande/", "Commandes");
if ($user->rights->telephonie->facture->lire)
$menu->add(DOL_URL_ROOT."/telephonie/facture/", "Factures");
if ($user->rights->telephonie->stats->lire)
{
$menu->add(DOL_URL_ROOT."/telephonie/stats/", "Statistiques");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/stats/distributeurs/", "Distributeurs");
}
$menu->add(DOL_URL_ROOT."/telephonie/tarifs/", "Tarifs");
$menu->add(DOL_URL_ROOT."/telephonie/distributeurs/", "Distributeurs");
$sql = "SELECT d.nom, d.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur as d";
if ($user->distributeur_id)
{
$sql .= " WHERE d.rowid = ".$user->distributeur_id;
}
$sql .= " ORDER BY d.nom ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows();
$i = 0;
$total = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$texte = $row[0];
if (strlen($texte) > 15)
{
$texte = substr($texte,0,12)."...";
}
$menu->add_submenu(DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$row[1], $texte);
$i++;
}
}
if ($user->rights->telephonie->fournisseur->lire)
$menu->add(DOL_URL_ROOT."/telephonie/fournisseur/index.php", "Fournisseurs");
if ($user->rights->telephonie->service->lire)
$menu->add(DOL_URL_ROOT."/telephonie/service/", "Services");
if ($user->rights->telephonie->ca->lire)
$menu->add(DOL_URL_ROOT."/telephonie/ca/", "Chiffre d'affaire");
left_menu($menu->liste);
}
?>

View File

@ -1,195 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if (!$user->rights->telephonie->lire) accessforbidden();
llxHeader('','Telephonie - Statistiques - Distributeur');
/*
*
*/
$h = 0;
if ($user->distributeur_id)
{
$_GET["id"] = $user->distributeur_id;
}
if ($_GET["id"])
{
$distri = new DistributeurTelephonie($db);
$distri->fetch($_GET["id"]);
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
$head[$h][1] = $distri->nom;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id;
$head[$h][1] = "Contrat";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/commissions.php?id='.$distri->id;
$head[$h][1] = "Rémunérations";
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remav.php?id='.$distri->id;
$head[$h][1] = "Rém. avance";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remconso.php?id='.$distri->id;
$head[$h][1] = "Rém. conso";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id;
$head[$h][1] = "Prises d'ordre";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
$head[$h][1] = "Statistiques";
$h++;
dol_fiche_head($head, $hselected, "Distributeur");
/* Conso */
$conso_total = 0;
$consos = array();
$sql = "SELECT c.date, sum(c.montant)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as c";
$sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
$sql .= " AND c.annul = 0";
$sql .= " GROUP BY c.date DESC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$consos[$row[0]] = $row[1];
$conso_total += $row[1];
$i++;
}
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
/* Commission */
$comm_total = 0;
$commissions = array();
$sql = "SELECT c.date, c.montant";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as c";
$sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
$sql .= " ORDER BY c.date DESC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($row = $db->fetch_row($resql))
{
$commissions[$row[0]] = $row[1];
$comm_total += $row[1];
}
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="50%" valign="top">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td>Date</td><td align="right">Rémunération</td>';
print '</tr>';
$var=1;
print '<tr class="liste_titre">';
print '<td>Total</td><td align="right">'.price($comm_total).' HT</td></tr>';
$sql = "SELECT c.date, c.montant";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as c";
$sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
$sql .= " ORDER BY c.date DESC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.substr($row[0], -2).'/'.substr($row[0],0,4).'</td>';
print '<td align="right">'.price($row[1]).' HT</td>';
/*
print '<td align="right">'.price($consos[$row[0]]).' HT</td>';
print '<td align="right">'.price($consos[$row[0]] - $row[1]).' HT</td>';
*/
$i++;
}
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
print '</table><br />';
print '</td><td valign="top" width="50%">';
print '</td></tr>';
print '</table>';
$db->close();
}
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,127 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if (!$user->rights->telephonie->lire) accessforbidden();
if ($user->distributeur_id && $user->responsable_distributeur_id == 0)
{
accessforbidden();
}
llxHeader('','Telephonie - Statistiques - Distributeurs');
/*
*
*
*
*/
$did = $_GET["id"];
if ($user->distributeur_id)
{
$did = $user->distributeur_id;
}
$h = 0;
$distri = new DistributeurTelephonie($db);
$distri->fetch($did);
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
$head[$h][1] = $distri->nom;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id;
$head[$h][1] = "Contrat";
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remuneration.php?id='.$distri->id;
$head[$h][1] = "Rémunérations";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id;
$head[$h][1] = "Prises d'ordre";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
$head[$h][1] = "Statistiques";
$h++;
dol_fiche_head($head, $hselected, "Distributeurs");
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="50%" valign="top">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td>Distributeur</td><td>Durée avan.</td><td>% Avance</td><td>% Prélèv</td><td>% Autre</td></tr>';
$sql = "SELECT d.nom, d.rowid, d.avance_pourcent, d.rem_pour_prev, d.rem_pour_autr, d.avance_duree";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur as d";
$sql .= " WHERE d.rowid = ".$did;
$sql .= " ORDER BY d.rowid ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows();
$i = 0;
$total = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="distributeur.php?id='.$row[1].'">'.$row[0].'</a></td>';
print '<td>'.$row[5].'</td>';
print '<td>'.$row[2].'</td>';
print '<td>'.$row[3].'</td>';
print '<td>'.$row[4].'</td>';
print '</tr>';
$i++;
}
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</table><br />';
print '</td><td width="50%" valign="top">&nbsp;</td></tr>';
print '</table></div>';
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,288 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if (!$user->rights->telephonie->lire) accessforbidden();
llxHeader('','Telephonie - Statistiques - Distributeur');
/*
*
*/
$h = 0;
if ($user->distributeur_id)
{
$_GET["id"] = $user->distributeur_id;
}
if ($_GET["id"])
{
$distri = new DistributeurTelephonie($db);
$distri->fetch($_GET["id"]);
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
$head[$h][1] = $distri->nom;
$hselected = $h;
$h++;
if ($user->distributeur_id == 0 || $user->responsable_distributeur_id > 0)
{
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id;
$head[$h][1] = "Contrat";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remuneration.php?id='.$distri->id;
$head[$h][1] = "Rémunérations";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id;
$head[$h][1] = "Prises d'ordre";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
$head[$h][1] = "Statistiques";
$h++;
}
dol_fiche_head($head, $hselected, "Distributeur");
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="40%" valign="top">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Responsables</td></tr>';
$sql = "SELECT u.rowid, u.firstname, u.name";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_distributeur_responsable as dc";
$sql .= " WHERE u.rowid = dc.fk_user ";
$sql .= " AND dc.fk_distributeur = '".$_GET["id"]."'";
$sql .= " ORDER BY u.name ASC;";
$resql = $db->query($sql);
if ($resql)
{
while ($row = $db->fetch_row($resql))
{
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.$row[1].' '.$row[2].'</td>';
}
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
print '</table><br />';
$sql = "SELECT u.rowid, u.firstname, u.name, u.email";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_distributeur_commerciaux as dc";
$sql .= " WHERE u.rowid = dc.fk_user ";
$sql .= " AND dc.fk_distributeur = '".$_GET["id"]."'";
$sql .= " ORDER BY u.name ASC;";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num > 0 )
{
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Commerciaux</td></tr>';
while ($row = $db->fetch_row($resql))
{
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="./comm/commercial.php?id='.$row[0].'&amp;did='.$_GET["id"].'">';;
print $row[1].' '.$row[2].'</a>';
if ($row[3] && $user->distributeur_id == 0)
{
print " &lt;".$row[3]."&gt;";
}
print '</td>';
}
print '</table><br />';
}
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
if ($user->distributeur_id == 0 || $user->responsable_distributeur_id > 0)
{
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td colspan="2">Total commission</td></tr>';
$sql = "SELECT sum(c.montant)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as c";
$sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
$var = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>Total</td>';
print '<td align="right">'.price($row[0]).' HT</td>';
$i++;
}
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
print '</table><br />';
}
if ($user->distributeur_id == 0 || $user->responsable_distributeur_id > 0)
{
print '</td><td valign="top" width="30%">';
/* comm */
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td>Date</td><td align="right">Rémunérations</td></tr>';
$sql = "SELECT c.date, c.montant";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as c";
$sql .= " WHERE c.fk_distributeur = ".$_GET["id"];
$sql .= " ORDER BY c.date DESC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.substr($row[0], -2).'/'.substr($row[0],0,4).'</td>';
print '<td align="right">'.price($row[1]).' HT</td>';
$i++;
}
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
print '</table><br />';
print '</td><td valign="top" width="30%">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td>Date</td><td align="right">'."Prise d'ordre mensuelle</td></tr>";
$sql = "SELECT ".$db->pdate("p.datepo") . " as datepo, sum(p.montant)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_priseordre as p";
$sql .= " WHERE p.fk_distributeur =".$distri->id;
$sql .= " GROUP BY date_format(datepo,'%Y%m') DESC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.strftime("%m/%Y",$row[0]).'</td>';
print '<td align="right">'.price($row[1]).' HT</td>';
$i++;
}
$db->free($resql);
}
else
{
print $db->error() . ' ' . $sql;
}
print '</table><br />';
}
print '</td></tr>';
print '</table></div>';
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n";
if ($_GET["action"] == '' && $user->admin)
{
print "<a class=\"butAction\" href=\"fiche.php?action=create_commercial&amp;distri=".$distri->id."\">".$langs->trans("Nouveau commercial")."</a>";
}
print "</div><br>";
$db->close();
}
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,161 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if (!$user->rights->telephonie->lire) accessforbidden();
$distri = new DistributeurTelephonie($db);
$commercial = new CommercialTelephonie($db);
if($_POST["action"] == 'add')
{
$distri->nom = $_POST["nom"];
$distri->avance = $_POST["avance"];
$distri->duree = $_POST["duree"];
$distri->prelev = $_POST["prelev"];
$distri->autre = $_POST["autre"];
if ($distri->create() <> 0)
{
$_GET["action"] = "create";
}
else
{
Header("Location: index.php");
}
}
if($_POST["action"] == 'add_commercial' && $user->admin)
{
$commercial->nom = $_POST["nom"];
$commercial->prenom = $_POST["prenom"];
$commercial->distri = $_GET["distri"];
$commercial->email = $_POST["email"];
if ($commercial->create() <> 0)
{
$_GET["action"] = "create_commercial";
}
else
{
Header("Location: distributeur.php?id=".$_GET["distri"]);
}
}
llxHeader('','Telephonie - Statistiques - Distributeurs');
/*
*
*
*
*/
$h = 0;
if ($_GET["action"] == 'create_commercial')
{
$distri = new DistributeurTelephonie($db);
$distri->fetch($_GET["distri"]);
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/fiche.php?action=create';
$head[$h][1] = "Nouveau commercial";
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, $distri->nom);
print '<form method="POST" action="fiche.php?distri='.$_GET["distri"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add_commercial"></td></tr>';
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="20%">Prénom</td>';
print '<td><input type="text" size="20" maxlength="20" name="prenom" value="'.$commercial->prenom.'"></td>';
print '<td>'.$commercial->error_string["prenom"].'</td></tr>';
print '<tr><td width="20%">Nom</td>';
print '<td><input type="text" size="30" maxlength="30" name="nom" value="'.$commercial->nom.'"></td>';
print '<td>'.$commercial->error_string["nom"].'</td></tr>';
print '<tr><td width="20%">Email</td>';
print '<td><input type="text" size="50" maxlength="70" name="email" value="'.$commercial->email.'"></td>';
print '<td>'.$commercial->error_string["email"].'</td></tr>';
print '<tr><td colspan="2"><input type="submit"></td></tr>';
print '</table><br />';
print "</form>";
}
if ($_GET["action"] == 'create')
{
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/fiche.php?action=create';
$head[$h][1] = "Nouveau distributeur";
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, "Distributeurs");
print '<form method="POST" action="fiche.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add"></td></tr>';
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="20%">Nom</td>';
print '<td><input type="text" size="30" name="nom" value="'.$distri->nom.'"></td>';
print '<td>'.$distri->error_string["nom"].'</td></tr>';
print '<tr><td width="20%">% avance</td>';
print '<td><input type="text" size="3" maxlength="2" name="avance" value="'.$distri->avance.'"> %</td>';
print '<td>'.$distri->error_string["avance"].'</td></tr>';
print '<tr><td width="20%">Durée de l\'avance</td>';
print '<td><input type="text" size="3" maxlength="2" name="duree" value="'.$distri->duree.'"> mois</td>';
print '<td>'.$distri->error_string["duree"].'</td></tr>';
print '<tr><td width="20%">% prélèvement</td>';
print '<td><input type="text" size="3" maxlength="2" name="prelev" value="'.$distri->prelev.'"> %</td>';
print '<td>'.$distri->error_string["prelev"].'</td></tr>';
print '<tr><td width="20%">% autre</td>';
print '<td width="25%"><input type="text" size="3" maxlength="2" name="autre" value="'.$distri->autre.'"> %</td>';
print '<td>'.$distri->error_string["autre"].'</td></tr>';
print '<tr><td colspan="2"><input type="submit"></td></tr>';
print '</table><br />';
print "</form>";
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,111 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if (!$user->rights->telephonie->lire) accessforbidden();
llxHeader('','Telephonie - Statistiques - Distributeurs');
/*
*
*
*
*/
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/index.php';
$head[$h][1] = "Liste";
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, "Distributeurs");
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="50%" valign="top">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td>Distributeur</td>';
$sql = "SELECT d.nom, d.rowid, d.avance_pourcent, d.rem_pour_prev, d.rem_pour_autr, d.avance_duree";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur as d";
if ($user->distributeur_id)
{
$sql .= " WHERE d.rowid = ".$user->distributeur_id;
}
$sql .= " ORDER BY d.rowid ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows();
$i = 0;
$total = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="distributeur.php?id='.$row[1].'">'.$row[0].'</a></td>';
print '</tr>';
$i++;
}
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</table><br />';
print '</td><td width="50%" valign="top">&nbsp;</td></tr>';
print '</table></div>';
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n";
if ($_GET["action"] == '' && $user->admin)
{
print "<a class=\"butAction\" href=\"fiche.php?action=create\">".$langs->trans("Nouveau")."</a>";
}
print "</div><br>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,166 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if ($user->distributeur_id && $user->responsable_distributeur_id == 0)
{
accessforbidden();
}
if ($user->distributeur_id)
{
$_GET["id"] = $user->distributeur_id;
}
llxHeader();
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
if ($sortorder == "") $sortorder="DESC";
if ($sortfield == "") $sortfield="p.datepo";
/*
*
*
*/
if ($_GET["id"])
{
$h = 0;
$distri = new DistributeurTelephonie($db);
$distri->fetch($_GET["id"]);
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
$head[$h][1] = $distri->nom;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id;
$head[$h][1] = "Contrat";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remuneration.php?id='.$distri->id;
$head[$h][1] = "Rémunérations";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id;
$head[$h][1] = "Prises d'ordre";
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
$head[$h][1] = "Statistiques";
$h++;
dol_fiche_head($head, $hselected, "Distributeur");
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*/
$sql = "SELECT s.rowid as socid, s.nom, p.fk_contrat, p.montant, p.avance_duree, p.avance_pourcent";
$sql .= ", p.rem_pour_prev, p.rem_pour_autr, p.mode_paiement";
$sql .= " , ".$db->pdate("p.datepo") . " as datepo";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_priseordre as p";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE p.fk_distributeur =".$distri->id;
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND p.fk_contrat = c.rowid";
$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;
$url_opt = "&amp;id=".$_GET["id"];
print_barre_liste("Prises d'ordre", $page, "po.php", $url_opt, $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print_liste_field_titre("Client","po.php","s.nom","","&amp;id=".$_GET["id"]);
print_liste_field_titre("Contrat","po.php","p.fk_contrat","","&amp;id=".$_GET["id"]);
print '<td align="center">Date</td>';
print '<td align="right">Montant</td>';
print '<td align="center">Avance Durée</td><td align="center">Avance %</td>';
print '<td align="center">Rem %</td><td align="center">MdP</td>';
print "</tr>\n";
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.$obj->nom."</a></td>\n";
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/contrat/fiche.php?id='.$obj->fk_contrat.'">'.$obj->fk_contrat."</a></td>\n";
print '<td align="center">'.strftime("%e %b %Y",$obj->datepo)."</td>\n";
print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n";
print '<td align="center">'.$obj->avance_duree."</td>\n";
print '<td align="center">'.$obj->avance_pourcent." %</td>\n";
if ($obj->mode_paiement == 'pre')
{
print '<td align="center">'.$obj->rem_pour_prev." %</td>\n";
print '<td align="center">Prelev</td>';
}
else
{
print '<td align="center">'.$obj->rem_pour_autr." %</td>\n";
print '<td align="center">Autre</td>';
}
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,134 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("../../main.inc.php");
$user->getrights('telephonie');
$user->distributeur_id = 0;
require DOL_DOCUMENT_ROOT.'/telephonie/distributeurtel.class.php';
require DOL_DOCUMENT_ROOT.'/telephonie/telephonie.commercial.class.php';
$sql = "SELECT fk_distributeur";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur_commerciaux";
$sql .= " WHERE fk_user=".$user->id;
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$user->distributeur_id = $row[0];
}
$sql = "SELECT fk_distributeur";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur_responsable";
$sql .= " WHERE fk_user=".$user->id;
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
$user->responsable_distributeur_id = $row[0];
}
function llxHeader($head = "", $title="") {
global $user, $conf, $db;
/*
*
*
*/
top_menu($head, $title);
$menu = new Menu();
$menu->add(DOL_URL_ROOT."/telephonie/index.php", "Telephonie");
$menu->add(DOL_URL_ROOT."/telephonie/client/index.php", "Clients");
$menu->add(DOL_URL_ROOT."/telephonie/contrat/", "Contrats");
$menu->add(DOL_URL_ROOT."/telephonie/ligne/index.php", "Lignes");
if ($user->rights->telephonie->ligne_commander)
$menu->add(DOL_URL_ROOT."/telephonie/ligne/commande/", "Commandes");
if ($user->rights->telephonie->facture->lire)
$menu->add(DOL_URL_ROOT."/telephonie/facture/", "Factures");
if ($user->rights->telephonie->stats->lire)
{
$menu->add(DOL_URL_ROOT."/telephonie/stats/", "Statistiques");
$menu->add_submenu(DOL_URL_ROOT."/telephonie/stats/distributeurs/", "Distributeurs");
}
$menu->add(DOL_URL_ROOT."/telephonie/tarifs/", "Tarifs");
$menu->add(DOL_URL_ROOT."/telephonie/distributeurs/", "Distributeurs");
$sql = "SELECT d.nom, d.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur as d";
if ($user->distributeur_id)
{
$sql .= " WHERE d.rowid = ".$user->distributeur_id;
}
$sql .= " ORDER BY d.nom ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows();
$i = 0;
$total = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$texte = $row[0];
if (strlen($texte) > 15)
{
$texte = substr($texte,0,12)."...";
}
$menu->add_submenu(DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$row[1], $texte);
$i++;
}
}
if ($user->rights->telephonie->fournisseur->lire)
$menu->add(DOL_URL_ROOT."/telephonie/fournisseur/index.php", "Fournisseurs");
if ($user->rights->telephonie->service->lire)
$menu->add(DOL_URL_ROOT."/telephonie/service/", "Services");
if ($user->rights->telephonie->ca->lire)
$menu->add(DOL_URL_ROOT."/telephonie/ca/", "Chiffre d'affaire");
left_menu($menu->liste);
}
?>

View File

@ -1,201 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if ($user->distributeur_id)
{
$_GET["id"] = $user->distributeur_id;
}
llxHeader();
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
if ($sortorder == "") $sortorder="DESC";
if ($sortfield == "") $sortfield="p.datepo";
/*
*
*
*/
if ($_GET["id"])
{
$h = 0;
$distri = new DistributeurTelephonie($db);
$distri->fetch($_GET["id"]);
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
$head[$h][1] = $distri->nom;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id;
$head[$h][1] = "Contrat";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/commissions.php?id='.$distri->id;
$head[$h][1] = "Rémunérations";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remav.php?id='.$distri->id;
$head[$h][1] = "Rém. avance";
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remconso.php?id='.$distri->id;
$head[$h][1] = "Rém. conso";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id;
$head[$h][1] = "Prises d'ordre";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
$head[$h][1] = "Statistiques";
$h++;
dol_fiche_head($head, $hselected, "Distributeur");
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="70%" valign="top">';
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*/
if ($_GET["month"] > 0)
{
$datetime = mktime(12,12,12,substr($_GET["month"], -2), 1 , substr($_GET["month"],0,4));
}
else
{
$datetime = time();
}
$month = substr("00".strftime("%m", $datetime), -2);
$year = strftime("%Y", $datetime);
$mois = strftime("%B %Y", $datetime);
$sql = "SELECT s.rowid as socid, s.nom, a.fk_contrat, sum(a.montant) as montant";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_avance as a";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE a.fk_distributeur =".$distri->id;
$sql .= " AND a.fk_contrat = c.rowid";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND a.date ='".$year.$month."'";
$sql .= " GROUP BY s.rowid";
$sql .= " ORDER BY s.nom ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print_barre_liste("Rémunération sur avance pour $mois", $page, "po.php", "", $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Client</td>';
print '<td align="right">Montant</td>';
print "</tr>\n";
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.$obj->nom."</a></td>\n";
print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td><td width="30%" valign="top">';
$sql = "SELECT distinct(a.date)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_avance as a";
$sql .= " ORDER BY a.date DESC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Mois</td>';
print "</tr>\n";
$var=True;
while ( $obj = $db->fetch_object($resql))
{
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/distributeurs/remav.php?id='.$_GET["id"];
print '&amp;month='.$obj->date.'">'.$obj->date."</a></td>\n";
print "</tr>\n";
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td></tr></table>';
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,203 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if ($user->distributeur_id)
{
$_GET["id"] = $user->distributeur_id;
}
llxHeader();
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
if ($sortorder == "") $sortorder="DESC";
if ($sortfield == "") $sortfield="p.datepo";
/*
*
*
*/
if ($_GET["id"])
{
$h = 0;
$distri = new DistributeurTelephonie($db);
$distri->fetch($_GET["id"]);
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
$head[$h][1] = $distri->nom;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id;
$head[$h][1] = "Contrat";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/commissions.php?id='.$distri->id;
$head[$h][1] = "Rémunérations";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remav.php?id='.$distri->id;
$head[$h][1] = "Rém. avance";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remconso.php?id='.$distri->id;
$head[$h][1] = "Rém. conso";
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id;
$head[$h][1] = "Prises d'ordre";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
$head[$h][1] = "Statistiques";
$h++;
dol_fiche_head($head, $hselected, "Distributeur");
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="70%" valign="top">';
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*/
if ($_GET["month"] > 0)
{
$datetime = mktime(12,12,12,substr($_GET["month"], -2), 1 , substr($_GET["month"],0,4));
}
else
{
$datetime = time();
}
$month = substr("00".strftime("%m", $datetime), -2);
$year = strftime("%Y", $datetime);
$mois = strftime("%B %Y", $datetime);
$sql = "SELECT s.rowid as socid, s.nom, a.fk_contrat, sum(a.montant) as montant";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as a";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE a.fk_distributeur =".$distri->id;
$sql .= " AND a.fk_contrat = c.rowid";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND a.date ='".$year.$month."'";
$sql .= " AND a.avance = 0";
$sql .= " GROUP BY s.rowid";
$sql .= " ORDER BY s.nom ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print_barre_liste("Rémunération sur consommations pour $mois", $page, "po.php", "", $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Client</td>';
print '<td align="right">Montant</td>';
print "</tr>\n";
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.$obj->nom."</a></td>\n";
print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td><td width="30%" valign="top">';
$sql = "SELECT distinct(a.date)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as a";
$sql .= " WHERE a.avance = 0";
$sql .= " ORDER BY a.date DESC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Mois</td>';
print "</tr>\n";
$var=True;
while ( $obj = $db->fetch_object($resql))
{
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/distributeurs/remconso.php?id='.$_GET["id"];
print '&amp;month='.$obj->date.'">'.$obj->date."</a></td>\n";
print "</tr>\n";
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td></tr></table>';
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,308 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if ($user->distributeur_id && $user->responsable_distributeur_id == 0)
{
accessforbidden();
}
if ($user->distributeur_id)
{
$_GET["id"] = $user->distributeur_id;
}
llxHeader();
$page = $_GET["page"];
$sortorder = $_GET["sortorder"];
$sortfield = $_GET["sortfield"];
if ($sortorder == "") $sortorder="DESC";
if ($sortfield == "") $sortfield="p.datepo";
/*
*
*
*/
if ($_GET["id"])
{
$h = 0;
$distri = new DistributeurTelephonie($db);
$distri->fetch($_GET["id"]);
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
$head[$h][1] = $distri->nom;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id;
$head[$h][1] = "Contrat";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remuneration.php?id='.$distri->id;
$head[$h][1] = "Rémunérations";
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id;
$head[$h][1] = "Prises d'ordre";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
$head[$h][1] = "Statistiques";
$h++;
dol_fiche_head($head, $hselected, "Distributeur");
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="40%" valign="top">';
if ($page == -1) { $page = 0 ; }
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
/*
* Mode Liste
*
*/
if ($_GET["month"] > 0)
{
$datetime = mktime(12,12,12,substr($_GET["month"], -2), 1 , substr($_GET["month"],0,4));
$month = substr("00".strftime("%m", $datetime), -2);
$year = strftime("%Y", $datetime);
$monthprev = $month;
$yearprev = $year;
}
else
{
$datetime = time();
$month = substr("00".strftime("%m", $datetime), -2);
$year = strftime("%Y", $datetime);
if ($month == 1)
{
$monthprev = "12";
$yearprev = $year - 1;
}
else
{
$monthprev = substr("00".($month - 1), -2) ;
$yearprev = $year;
}
}
$mois = strftime("%B %Y", mktime(12,0,0,$monthprev,1,$yearprev));
$sql = "SELECT s.rowid as socid, s.nom, a.fk_contrat, c.statut, sum(a.montant) as montant";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_avance as a";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE a.fk_distributeur =".$distri->id;
$sql .= " AND a.fk_contrat = c.rowid";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND a.date ='".$yearprev.$monthprev."'";
$sql .= " GROUP BY s.rowid";
$sql .= " ORDER BY s.nom ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print_barre_liste("Rémunération sur prise d'ordre pour $mois", $page, "po.php", "", $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Client</td>';
print '<td align="right">Montant</td>';
print "</tr>\n";
$total = 0;
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<img src="../contrat/statut'.$obj->statut.'.png">&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.$obj->nom."</a></td>\n";
print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n";
print "</tr>\n";
$total += $obj->montant;
$i++;
$var=!$var;
}
print "<tr $bc[$var]>\n";
print '<td>Total</td>';
print '<td align="right">'.sprintf("%01.2f",$total)."</td>\n";
print "</tr>\n</table>\n";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td><td width="40%" valign="top">';
print_barre_liste("Rémunération sur CA pour $mois", $page, "po.php", "", $sortfield, $sortorder, '', $num);
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Client</td>';
print '<td align="right">Montant</td>';
print "</tr>\n";
$total = 0;
$sql = "SELECT s.rowid as socid, s.nom, a.fk_contrat,c.statut,sum(a.montant) as montant";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_regul as a";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE a.fk_distributeur =".$distri->id;
$sql .= " AND a.fk_contrat = c.rowid";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND a.date ='".$yearprev.$monthprev."'";
$sql .= " GROUP BY s.rowid";
$sql .= " ORDER BY s.nom ASC";
$resql = $db->query($sql);
if ($resql)
{
while ($obj = $db->fetch_object($resql))
{
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<img src="../contrat/statut'.$obj->statut.'.png">&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.$obj->nom."</a></td>\n";
print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n";
print "</tr>\n";
$var=!$var;
$total += $obj->montant;
}
}
$sql = "SELECT s.rowid as socid, s.nom, a.fk_contrat, sum(a.montant) as montant, c.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission_conso as a";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_contrat as c";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE a.fk_distributeur =".$distri->id;
$sql .= " AND a.fk_contrat = c.rowid";
$sql .= " AND c.fk_soc = s.rowid";
$sql .= " AND a.date ='".$yearprev.$monthprev."'";
$sql .= " AND a.avance = 0";
$sql .= " GROUP BY s.rowid";
$sql .= " ORDER BY s.nom ASC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">';
print img_file();
print '</a>&nbsp;';
print '<img src="../contrat/statut'.$obj->statut.'.png">&nbsp;';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$obj->socid.'">'.$obj->nom."</a></td>\n";
print '<td align="right">'.sprintf("%01.2f",$obj->montant)."</td>\n";
print "</tr>\n";
$total += $obj->montant;
$var=!$var;
$i++;
}
print "<tr $bc[$var]>\n";
print '<td>Total</td>';
print '<td align="right">'.sprintf("%01.2f",$total)."</td>\n";
print "</tr>\n";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print "</table>\n";
print '</td><td width="20%" valign="top">';
print_barre_liste("Curseur", $page, "po.php", "", $sortfield, $sortorder, '', $num);
$sql = "SELECT distinct(a.date)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commission as a";
$sql .= " WHERE a.fk_distributeur =".$distri->id;
$sql .= " ORDER BY a.date DESC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Mois</td>';
print "</tr>\n";
$var=True;
while ( $obj = $db->fetch_object($resql))
{
$var=!$var;
print "<tr $bc[$var]><td>";
print '<a href="'.DOL_URL_ROOT.'/telephonie/distributeurs/remuneration.php?id='.$_GET["id"];
print '&amp;month='.$obj->date.'">'.$obj->date."</a></td>\n";
print "</tr>\n";
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</td></tr></table>';
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,131 +0,0 @@
<?PHP
/* Copyright (C) 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
if ($user->distributeur_id && $user->responsable_distributeur_id == 0)
{
accessforbidden();
}
if (!$user->rights->telephonie->lire) accessforbidden();
llxHeader('','Telephonie - Statistiques - Distributeur');
if ($user->distributeur_id)
{
$_GET["id"] = $user->distributeur_id;
}
/*
*
*
*
*/
if ($_GET["id"])
{
$distri = new DistributeurTelephonie($db);
$distri->fetch($_GET["id"]);
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/distributeur.php?id='.$distri->id;
$head[$h][1] = $distri->nom;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/contrat.php?id='.$distri->id;
$head[$h][1] = "Contrat";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/remuneration.php?id='.$distri->id;
$head[$h][1] = "Rémunérations";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/po.php?id='.$distri->id;
$head[$h][1] = "Prises d'ordre";
$h++;
$head[$h][0] = DOL_URL_ROOT.'/telephonie/distributeurs/stats.php?id='.$distri->id;
$head[$h][1] = "Statistiques";
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, "Distributeur");
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="30%" valign="top">';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td>Mois</td><td align="right">Prise d\'ordre</td></tr>';
$sql = "SELECT sum(p.montant), date_format(datepo, '%m-%Y')";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_priseordre as p";
$sql .= " WHERE p.fk_distributeur = ".$_GET["id"];
$sql .= " GROUP BY date_format(p.datepo, '%Y%m') DESC";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows();
$i = 0;
$total = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.$row[1].'</td>';
print '<td align="right">'.price($row[0]).'</td></tr>';
$i++;
}
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
print '</table><br />';
print '</td><td valign="top" width="70%">';
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=telephoniegraph&file=distributeurs/'.$_GET["id"].'/po.month.png" alt="Prise d\'ordre" title="Prise d\'ordre"><br /><br />'."\n";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=telephoniegraph&file=distributeurs/'.$_GET["id"].'/clients.hebdomadaire.png" alt="Nouveaux clients" title="Nouveaux clients"><br /><br />'."\n";
print '</td></tr>';
print '</table>';
$db->close();
}
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -1,193 +0,0 @@
<?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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
class DistributeurTelephonie {
var $db;
var $id;
/**
* Créateur
*
*
*/
function DistributeurTelephonie($DB, $id=0)
{
$this->db = $DB;
$this->id = $id;
return 0;
}
/**
*
*
*/
function create()
{
$error = 0;
if (strlen(trim($this->nom)) == 0)
{
$this->error_string["nom"] = "Valeur manquante";
$error++;
}
if (strlen(trim($this->avance)) == 0)
{
$this->error_string["avance"] = "Valeur manquante";
$error++;
}
if ($this->avance > 100 or $this->avance < 0)
{
$this->error_string["avance"] = "Valeur incohérente";
$error++;
}
if (!is_numeric($this->duree))
{
$this->error_string["duree"] = "Mauvais format";
$error++;
}
if ($this->duree > 12 or $this->duree < 0)
{
$this->error_string["duree"] = "Valeur incohérente";
$error++;
}
if (strlen(trim($this->duree)) == 0)
{
$this->error_string["duree"] = "Valeur manquante";
$error++;
}
if ($this->prelev > 100 or $this->prelev < 0)
{
$this->error_string["prelev"] = "Valeur incohérente";
$error++;
}
if (!is_numeric($this->prelev))
{
$this->error_string["prelev"] = "Mauvais format";
$error++;
}
if (strlen(trim($this->prelev)) == 0)
{
$this->error_string["prelev"] = "Valeur manquante";
$error++;
}
if ($this->autre > 100 or $this->autre < 0)
{
$this->error_string["autre"] = "Valeur incohérente";
$error++;
}
if (!is_numeric($this->autre))
{
$this->error_string["autre"] = "Mauvais format";
$error++;
}
if (strlen(trim($this->autre)) == 0)
{
$this->error_string["autre"] = "Valeur manquante";
$error++;
}
if ($error == 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_distributeur ";
$sql .= " (grille_tarif, nom, avance_pourcent, avance_duree, rem_pour_prev, rem_pour_autr)";
$sql .= " VALUES (2,'".trim($this->nom)."'";
$sql .= " ,".$this->avance;
$sql .= " ,".$this->duree;
$sql .= " ,".$this->prelev;
$sql .= " ,".$this->autre.")";
if ($this->db->query($sql))
{
}
else
{
dol_syslog("DistributeurTelephonie::Create");
$this->error_string["prelev"] = "Erreur SQL : $sql";
$this->error_string["autre"] = $this->db->error();
$error++;
}
}
else
{
}
return $error;
}
/**
*
*
*/
function fetch($id)
{
$this->id = $id;
$sql = "SELECT d.rowid, d.nom";
$sql .= " , d.avance_pourcent";
$sql .= " , d.rem_pour_prev, d.rem_pour_autr";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur as d";
$sql .= " WHERE d.rowid = ".$this->id;
if ($this->db->query($sql))
{
if ($this->db->num_rows())
{
$obj = $this->db->fetch_object(0);
$this->nom = stripslashes($obj->nom);
$this->remun_avance = $obj->remun_avance;
$this->remun_pourcent_prev = $obj->remun_pourcent_prev;
$this->remun_pourcent_autr = $obj->remun_pourcent_autr;
return 0;
}
else
{
dol_syslog("DistributeurTelephonie::Fetch Erreur id=".$this->id);
return -1;
}
}
else
{
dol_syslog("DistributeurTelephonie::Fetch Erreur SQL id=".$this->id);
return -2;
}
}
}
?>

View File

@ -1,292 +0,0 @@
<?php
/* Copyright (C) 2000-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/
*
* $Id$
* $Source$
*
* Lots of code inspired from Dan Potter's CMailFile class
*/
/**
\file htdocs/telephonie/dolibarrmail.class.php
\brief Classe permettant d'envoyer des mail avec attachements, reecriture de CMailFile
\author Dan Potter.
\author Eric Seigne
\author Rodolphe Quiedeville
\author Laurent Destailleur.
\version $Revision$
*/
/**
\class DolibarrMail
\brief Classe permettant d'envoyer des attachements par mail
\deprecated Utiliser CMailFile a la place car plus fiable et plus performant
*/
class DolibarrMail
{
var $subject;
var $addr_to;
var $addr_cc;
var $addr_bcc;
var $text_body;
var $text_encoded;
var $mime_headers;
var $boundary;
var $smtp_headers;
/**
\brief DolibarrMail
\param subject
\param to
\param from
\param msg
*/
function DolibarrMail($subject, $to, $from, $msg)
{
$this->subject = $subject;
$this->addr_to = $to;
$this->from = $from;
$this->message = wordwrap($msg, 78);
$this->errors_to = $from;
$this->boundary = md5( uniqid("dolibarr") );
$this->addr_bcc = "";
$this->addr_cc = "";
$this->reply_to = "";
$this->filename_list = array();
}
/**
\brief PrepareFile
\param filename_list
\param mimetype_list
\param mimefilename_list
*/
function PrepareFile($filename_list, $mimetype_list, $mimefilename_list)
{
$this->filename_list = $filename_list;
$this->mime_headers="";
if (count($filename_list))
{
$this->mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list);
$this->text_encoded = $this->attach_file($filename_list,
$mimetype_list,
$mimefilename_list);
}
}
/**
\brief permet d'attacher un fichier
\param filename_list
\param mimetype_list
\param mimefilename_list
*/
function attach_file($filename_list,$mimetype_list,$mimefilename_list)
{
for ($i = 0; $i < count($filename_list); $i++)
{
$encoded = $this->encode_file($filename_list[$i]);
if ($mimefilename_list[$i])
{
$filename_list[$i] = $mimefilename_list[$i];
}
$out = $out . "--".$this->boundary . "\n";
if (! $mimetype_list[$i])
{
$mimetype_list[$i] = "application/octet-stream";
}
$out .= "Content-Type: " . $mimetype_list[$i]."\n";
$out .= ' name="'.$filename_list[$i].'"'."\n";
$out .= "Content-Transfer-Encoding: base64\n";
$out .= "Content-Disposition: inline;\n";
$out .= " filename=\"".$filename_list[$i]."\"\n\n";
$out .= $encoded . "\n";
}
$out = $out . "--".$this->boundary . "\n";
return $out;
// added -- to notify email client attachment is done
}
/**
\brief Permet d'encoder un fichier
\param sourcefile
*/
function encode_file($sourcefile)
{
if (is_readable($sourcefile))
{
$fd = fopen($sourcefile, "r");
$contents = fread($fd, filesize($sourcefile));
$encoded = chunk_split(base64_encode($contents));
fclose($fd);
}
else
{
dol_syslog("DolibarrMail::encode_file Erreur");
}
return $encoded;
}
/**
\brief Envoi le mail
\return boolean vrai si mail envoyé, faux sinon
*/
function sendfile()
{
$this->smtp_headers = $this->write_smtpheaders();
$this->text_body = $this->write_body();
$headers = $this->smtp_headers . $this->mime_headers;
$message_comp = $this->text_body . $this->text_encoded;
if ($this->errors_to)
{
//dol_syslog("DolibarrMail::sendfile with errorsto : ".$this->errors_to);
$res = mail($this->addr_to,$this->subject,stripslashes($message_comp),$headers,"-f".$this->errors_to);
}
else
{
//dol_syslog("DolibarrMail::sendfile without errorsto");
$res = mail($this->addr_to,$this->subject,stripslashes($message_comp),$headers);
}
$this->write_to_file();
return $res;
}
/**
* \brief Ecrit le mail dans un fichier
* Utilisation pour le debuggage
*/
function write_to_file()
{
$this->smtp_headers = $this->write_smtpheaders();
$this->text_body = $this->write_body();
$headers = $this->smtp_headers . $this->mime_headers;
$message_comp = $this->text_body . $this->text_encoded;
$fp = fopen("/tmp/mail","w");
fputs($fp, $headers);
fputs($fp, $message_comp);
fclose($fp);
}
/**
\brief Permet d'ecrire le corps du message
*/
function write_body()
{
$out = "\n";
if (count($this->filename_list))
{
$out = $out . "--".$this->boundary . "\n";
$out = $out . 'Content-Type: text/plain; charset="iso-8859-15"'."\n";
$out .= "Content-Transfer-Encoding: 8bit\n\n";
}
else
{
//dol_syslog("DolibarrMail::write_body");
}
$out = $out . $this->message . "\n\n";
return $out;
}
/**
\brief création des headers mime
\param filename_list
\param mimefilename_list
*/
function write_mimeheaders($filename_list, $mimefilename_list)
{
$out = "MIME-Version: 1.0\n";
$out = $out . 'Content-type: multipart/mixed; '."\n";
$out = $out . ' boundary="'.$this->boundary.'"'."\n";
// $out = $out . "Content-transfer-encoding: 8BIT\n";
for($i = 0; $i < count($filename_list); $i++)
{
if ($mimefilename_list[$i])
{
$filename_list[$i] = $mimefilename_list[$i];
}
//$out = $out . "X-attachments: $filename_list[$i];\n\n";
}
return $out;
}
/**
\brief création des headers smtp
*/
function write_smtpheaders()
{
$out = "From: $this->from\n";
if($this->addr_cc != "")
$out = $out . "Cc: ".$this->addr_cc."\n";
if($this->addr_bcc != "")
$out = $out . "BCc: ".$this->addr_bcc."\n";
if($this->reply_to != "")
$out = $out . "Reply-To: ".$this->reply_to."\n";
// if($this->errors_to != "")
//$out = $out . "Errors-to: ".$this->errors_to."\n";
$out = $out . "X-Mailer: Dolibarr version " . DOL_VERSION ."\n";
$out = $out . "X-Sender: $this->from\n";
return $out;
}
}
?>

View File

@ -1,550 +0,0 @@
<?PHP
/* Copyright (C) 2005-2007 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$
*
*
* Script de calcul de la facturation
* - Lit les entrees dans la table import_cdr
* - Verifie que tous les tarifs sont dispos
* - Importe les lignes dans llx_communications_details
* - Calcul la facture telephonique par ligne
*/
/**
\file htdocs/telephonie/script/facturation-calcul.php
\ingroup telephonie
\brief Calcul des factures
\version $Revision$
*/
require_once (DOL_DOCUMENT_ROOT."/societe.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/communication.class.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/telephonie.tarif.class.php");
class FacturationCalcul {
function FacturationCalcul($dbh)
{
$this->db = $dbh;
$this->messages = array();
$this->message_bad_file_format = array();
}
function Calcul()
{
$error = 0;
$nbcommit = 0;
$datetime = time();
$date = strftime("%d%h%Y%Hh%Mm%S",$datetime);
/*
* On facture les communications du mois precedent
*/
$month = strftime("%m", $datetime);
$year = strftime("%Y", $datetime);
if ($month == 1)
{
$month = "12";
$year = $year - 1;
}
else
{
$month = substr("00".($month - 1), -2) ;
}
/********************************************************
*
* Affiche le nombre de comunications a traiter
*
*********************************************************/
$sql = "SELECT count(*)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_import_cdr";;
$resql = $this->db->query($sql);
if ( $resql )
{
$num = $this->db->num_rows($resql);
$row = $this->db->fetch_row($resql);
dol_syslog("FacturationCalcul::Calcul Communications a traiter ".$row[0],LOG_INFO);
$this->db->free($resql);
}
else
{
$error = 1;
dol_syslog("FacturationCalcul Erreur ".$error);
}
/**********************************************************
*
*
*
***********************************************************/
$sql = "SELECT MAX(rowid) FROM ".MAIN_DB_PREFIX."telephonie_facture";
$resql = $this->db->query($sql);
if ( $resql )
{
$row = $this->db->fetch_row($resql);
dol_syslog("FacturationCalcul Max rowid avant facture ".$row[0]);
$this->db->free($resql);
}
else
{
$error = 2;
dol_syslog("FacturationCalcul Erreur ".$error);
}
/**
*
* Lectures des differentes lignes dans la table d'import
*
*/
if (!$error)
{
$user = new user($this->db,1);
$sql = "SELECT distinct(t.fk_ligne)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_import_cdr as t";
$sql .= " ORDER BY fk_ligne ASC";
$lines_keys = array();
$resql = $this->db->query($sql);
if ( $resql )
{
$i=0;
while ($row = $this->db->fetch_row($resql))
{
$lines_keys[$i] = $row[0];
$i++;
}
$this->db->free($resql);
dol_syslog(sizeof($lines_keys)." lignes trouvees");
}
else
{
$error = 3;
dol_syslog("FacturationCalcul Erreur ".$error);
}
}
/**********************************************************
*
* Creation d'un batch de facturation
*
***********************************************************/
if (sizeof($lines_keys) > 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_facturation_batch";
$sql .= " (date_batch) VALUES (now())";
$resql = $this->db->query($sql);
if ( $resql )
{
$batch_id = $this->db->last_insert_id(MAIN_DB_PREFIX."telephonie_facturation_batch");
dol_syslog("FacturationCalcul Batch ID ".$batch_id);
}
else
{
$error = 20;
dol_syslog("FacturationCalcul Erreur ".$error);
}
}
/* ***************************************************** */
/* */
/* Traitements */
/* */
/* */
/* ***************************************************** */
if (!$error)
{
foreach ($lines_keys as $line_key)
{
$error = 0;
$ligne = new LigneTel($this->db);
if ( $this->db->query("BEGIN") )
{
if ($ligne->fetch_by_id($line_key) > 0 )
{
if ($ligne->socid == 0)
{
$error = 4;
dol_syslog("FacturationCalcul Error ($error)");
}
}
else
{
$error = 5;
dol_syslog("FacturationCalcul Error ($error): Aucune societe rattachee a la ligne : $line_key");
}
/*
* Recuperation des infos sur la societes
*
*/
if (!$error )
{
$soc = new Societe($this->db);
if ( $soc->fetch($ligne->socid) )
{
}
else
{
$error = 6;
dol_syslog("FacturationCalcul FacturationCalcul Error ($error)");
}
}
/*
*
* Creation d'une facture de telephonie si la ligne est facturable
*
*/
if (!$error)
{
if ($ligne->facturable == 1)
{
$facturable = 'oui';
}
else
{
$facturable = 'non';
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_facture";
$sql .= " (fk_ligne, ligne, date, isfacturable, fk_batch, fk_contrat)";
$sql .= " VALUES (".$ligne->id.",";
$sql .= " '$ligne->numero','".$year."-".$month."-01'";
$sql .= ", '$facturable',".$batch_id;
$sql .= ", ".$ligne->contrat.")";
if ($this->db->query($sql))
{
$facid = $this->db->last_insert_id(MAIN_DB_PREFIX."telephonie_facture");
}
else
{
$error++;
dol_syslog("FacturationCalcul Erreur d'insertion dans llx_telephonie_facture");
dol_syslog($this->db->error());
dol_syslog($sql);
}
}
/*
*
* Calcul de la facture
*
*/
if (!$error)
{
$total_achat = 0;
$total_vente = 0;
$total_fourn = 0;
if ($this->CalculateBill($this->db, $ligne, $facid, $total_achat, $total_vente, $total_fourn) <> 0)
{
$error++;
dol_syslog("FacturationCalcul Erreur de calcul de la facture pour la ligne $line_key $ligne->numero");
array_push($this->messages, array('error',"Erreur de calcul de la facture pour la ligne $ligne->numero (id=$line_key)"));
}
}
/*
*
* Insertion des donnees dans la base
*
*/
if (!$error)
{
$total_vente_remise = $total_vente;
$total_vente_remise = ereg_replace(",",".", $total_vente_remise);
$gain = ($total_vente_remise - $total_fourn);
$total_achat = ereg_replace(",",".", $total_achat);
$total_vente = ereg_replace(",",".", $total_vente);
$total_fourn = ereg_replace(",",".", $total_fourn);
$gain = ereg_replace(",",".", $gain);
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_facture";
$sql .= " SET ";
$sql .= " fourn_montant = $total_fourn";
$sql .= " , cout_achat = $total_achat";
$sql .= " , cout_vente = $total_vente";
$sql .= " , remise = $ligne->remise";
$sql .= " , cout_vente_remise = $total_vente_remise";
$sql .= " , gain = $gain";
$sql .= " WHERE rowid =".$facid;
if ($this->db->query($sql))
{
}
else
{
$error++;
dol_syslog("FacturationCalcul Erreur de mise a jour dans llx_telephonie_facture");
dol_syslog($this->db->error());
dol_syslog($sql);
}
}
/*
* Suppression des donnees de la table d'import
*
*/
if (!$error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_import_cdr";
$sql .= " WHERE fk_ligne = $line_key ";
if (! $this->db->query($sql))
{
$error++;
dol_syslog("FacturationCalcul Erreur de suppression dans llx_telephonie_import_cdr");
}
}
/*
* Commit / Rollback SQL
*
*/
if (!$error)
{
$this->db->query("COMMIT");
$nbcommit++;
dol_syslog("FacturationCalcul Ligne $ligne->numero - COMMIT");
array_push($this->messages, "Facturation ligne ".$ligne->numero." reussie");
}
else
{
$this->db->query("ROLLBACK");
dol_syslog("FacturationCalcul Ligne $ligne->numero - ROLLBACK de la transaction");
}
}
else
{
dol_syslog("FacturationCalcul Erreur ouverture Transaction SQL");
}
} /* fin de la boucle */
/*
*
*
*/
}
/**********************************************************
*
*
*
***********************************************************/
$sql = "SELECT MAX(rowid) FROM ".MAIN_DB_PREFIX."telephonie_facture";
$resql = $this->db->query($sql);
if ( $resql )
{
$row = $this->db->fetch_row($resql);
dol_syslog("FacturationCalcul Max rowid après facture ".$row[0]);
$this->db->free($resql);
}
else
{
$error++;
}
/**********************************************************
*
*
*
***********************************************************/
dol_syslog($nbcommit." facture emises");
/**********************************************************
*
*
*
***********************************************************/
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."telephonie_import_cdr";
$resql = $this->db->query($sql);
if ( $resql )
{
$row = $this->db->fetch_row($resql);
dol_syslog($row[0]. " communications restantes dans la table d'import");
$this->db->free($resql);
}
else
{
$error++;
}
dol_syslog("FacturationCalcul Fin Batch ID ".$batch_id);
}
/******************************************************************************
*
* Fonction de calcul de la facture
*
******************************************************************************/
function CalculateBill($db, $ligne, $facture_id, &$total_cout_achat, &$total_cout_vente, &$total_cout_fourn)
{
$error = 0;
$total = 0;
$nbinter = 0;
$nbmob = 0;
$nbnat = 0;
$duree = 0;
$tarif_spec = TELEPHONIE_GRILLE_VENTE_DEFAUT_ID ;
$sql = "SELECT d.grille_tarif";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_distributeur as d";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_distributeur_commerciaux as dc";
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
$sql .= " WHERE l.rowid = ".$ligne->id;
$sql .= " AND d.rowid = dc.fk_distributeur";
$sql .= " AND l.fk_commercial_sign = dc.fk_user";
$resql = $db->query($sql);
if ( $resql )
{
$num_sql = $db->num_rows($resql);
if ($num_sql > 0)
{
$row = $db->fetch_row($resql);
$tarif_spec = $row[0];
}
$db->free($resql);
}
$fournisseur_id = $ligne->fournisseur_id;
dol_syslog("FacturationCalcul::CalculateBill Utilisation du tarif ".$tarif_spec." pour la ligne ".$ligne->id);
$tarif_achat = new TelephonieTarif($db, $tarif_spec, "achat", $fournisseur_id);
$tarif_vente = new TelephonieTarif($db, $tarif_spec, "vente", $tarif_spec, $ligne->client_comm_id);
$comms = array();
$sql = "SELECT t.idx, t.fk_ligne, t.ligne, t.montant, t.duree, t.num, t.date, t.heure, t.dest";
$sql .= " , t.fichier, t.fk_fournisseur";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_import_cdr as t";
$sql .= " WHERE t.fk_ligne = ".$ligne->id;
$resql = $db->query($sql);
if ($resql)
{
$num_sql = $db->num_rows($resql);
$i = 0;
while ($i < $num_sql && $error == 0)
{
$objp = $db->fetch_object($resql);
$comm = new CommunicationTelephonique();
$comm->index = $objp->idx;
$comm->fk_ligne = $objp->fk_ligne;
$comm->ligne = $objp->ligne;
$comm->date = $objp->date;
$comm->heure = $objp->heure;
$comm->duree = $objp->duree;
$comm->dest = $objp->dest;
$comm->numero = $objp->num;
$comm->montant = $objp->montant;
$comm->fichier_cdr = $objp->fichier;
$comm->fournisseur = $objp->fk_fournisseur;
$comm->facture_id = $facture_id;
$comms[$i] = $comm;
$i++;
}
$db->free($resql);
}
else
{
$error++;
dol_syslog("FacturationCalcul::CalculateBill Erreur dans Calcul() Probleme SQL");
}
for ($ii = 0 ; $ii < $num_sql ; $ii++)
{
$comm = $comms[$ii];
$error = $error + $comm->cout($tarif_achat, $tarif_vente, $ligne, $db);
$total_cout_fourn = $total_cout_fourn + $comm->montant;
$total_cout_achat = $total_cout_achat + $comm->cout_achat;
$total_cout_vente = $total_cout_vente + $comm->cout_vente;
$error = $error + $comm->logsql($db);
foreach ($comm->messages as $message)
{
array_push($this->messages, $message);
}
}
dol_syslog("FacturationCalcul::CalculateBill return $error", LOG_DEBUG);
return $error;
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,330 +0,0 @@
<?PHP
/* Copyright (C) 2005-2007 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$
*
* Script d'import des CDR
*/
require_once(DOL_DOCUMENT_ROOT."/telephonie/fournisseurtel.class.php");
class FacturationImportCdr {
function FacturationImportCdr($dbh)
{
$this->db = $dbh;
$this->messages = array();
$this->message_bad_file_format = array();
}
function CountDataImport()
{
$nb = 0;
$sql = "SELECT count(*)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_import_cdr";
if ($this->db->query($sql))
{
while ($row = $this->db->fetch_row($resql))
{
$nb = $row[0];
}
$this->db->free($resql);
}
return $nb;
}
function Import($id_fourn)
{
$dir = DOL_DATA_ROOT."/telephonie/cdr/atraiter/".$id_fourn."/";
/*
* Traitement
*/
$files = array();
$unknown_lines = array();
if (is_dir($dir))
{
$handle=opendir($dir);
if ($handle)
{
$i = 0 ;
$var=True;
while (($xfile = readdir($handle))!==false)
{
if (is_file($dir.$xfile) && substr($xfile, -4) == ".csv")
{
$files[$i] = $dir.$xfile;
dol_syslog("FacturationImportCdr::Import ".$xfile." ajoute");
$i++;
}
else
{
dol_syslog("FacturationImportCdr::Import ".$xfile." ignore");
}
}
closedir($handle);
}
else
{
dol_syslog("FacturationImportCdr::Import Impossible de lire $dir");
exit ;
}
}
else
{
dol_syslog("FacturationImportCdr::Import Impossible de lire $file");
exit ;
}
/*
* Verification du fournisseur
*
*/
$fourn = new FournisseurTelephonie($this->db);
if ($fourn->fetch($id_fourn) <> 0)
{
dol_syslog("FacturationImportCdr::Import Erreur recherche fournisseur", LOG_ERR);
}
/*
* Verification des fichiers charges
*
*/
$fichiers = array();
$sql = "SELECT distinct(fichier)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_import_cdr";
if ($this->db->query($sql))
{
while ($row = $this->db->fetch_row($resql))
{
array_push($fichiers, $row[0]);
}
$this->db->free($resql);
}
else
{
dol_syslog("FacturationImportCdr::Import Erreur recherche si fichiers deja charges");
}
/*
* Verification des fichiers traites
*
*/
$sql = "SELECT distinct(fichier_cdr)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details";
if ($this->db->query($sql))
{
while ($row = $this->db->fetch_row($resql))
{
array_push($fichiers, $row[0]);
}
$this->db->free($resql);
}
else
{
dol_syslog("FacturationImportCdr::Import Erreur recherche si fichiers deja traites");
}
/*
* Charge les ID de lignes
*
*/
$sql = "SELECT ligne, rowid ";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne";
$resql = $this->db->query($sql);
if ($resql)
{
$i = 0;
$ligneids = array();
while ($row = $this->db->fetch_row($resql))
{
$ligneids[$row[0]] = $row[1];
$i++;
}
}
else
{
dol_syslog("FacturationImportCdr::Import Erreur chargement des lignes", LOG_DEBUG);
exit ;
}
if (strlen($fourn->cdrformat))
{
if (@require_once(DOL_DOCUMENT_ROOT."/telephonie/fournisseur/cdrformat/cdrformat.".$fourn->cdrformat.".class.php"))
{
$format = "CdrFormat".ucfirst($fourn->cdrformat);
$cdrformat = new $format();
}
}
foreach ($files as $xfile)
{
if (is_readable($xfile))
{
if ( $this->_verif($this->db, $xfile, $fichiers) == 0)
{
$error = 0;
dol_syslog("FacturationImportCdr::Import Lecture du fichier $xfile", LOG_DEBUG);
array_push($this->messages,array('info',"Fichier ".basename($xfile)." : utilisation format ".$cdrformat->nom));
$error = $cdrformat->ReadFile($xfile);
$this->messages=array_merge($this->messages, $cdrformat->messages);
$line = 0;
$line_inserted = 0;
$hf = fopen ($xfile, "r");
$line = 0;
if ($this->db->query("BEGIN") && $error == 0)
{
foreach ($cdrformat->datas as $data)
{
$ligne = $data['ligne'];
$duree_secondes = $data['duree'];
if ($ligneids[$ligne] > 0)
{
if ($duree_secondes > 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_import_cdr";
$sql .= "(idx,fk_ligne,ligne,date,heure,num,dest,dureetext,tarif,montant,duree";
$sql .= ", fichier, fk_fournisseur)";
$sql .= " VALUES (";
$sql .= $data['index'];
$sql .= ",'".$ligneids[$ligne]."'";
$sql .= ",'".$ligne."'";
$sql .= ",'".$data['date']."'";
$sql .= ",'".$data['heure']."'";
$sql .= ",'".$data['numero']."'";
$sql .= ",'".addslashes(ereg_replace('"','',$data['tarif']))."'";
$sql .= ",'".ereg_replace('"','',$duree_text)."'";
$sql .= ",'".ereg_replace('"','',$tarif_fourn)."'";
$sql .= ",".ereg_replace(',','.',$data['montant']);
$sql .= ",".$duree_secondes;
$sql .= ",'".basename($xfile)."'";
$sql .= " ,".$id_fourn;
$sql .= ")";
if(ereg("^[0-9]+$", $duree_secondes))
{
if ($this->db->query($sql))
{
$line_inserted++;
}
else
{
dol_syslog("FacturationImportCdr::Import Erreur de traitement de ligne $index", LOG_ERR);
dol_syslog("FacturationImportCdr::Import $sql", LOG_DEBUG);
$error++;
}
}
else
{
dol_syslog("FacturationImportCdr::Import Ligne : $cont ignoree", LOG_INFO);
$error++;
}
}
else
{
dol_syslog("FacturationImportCdr::Import Duree nulle Ligne : $cont ignoree", LOG_INFO);
}
}
else
{
if (!in_array($ligne, $unknown_lines))
{
dol_syslog("FacturationImportCdr::Import Ligne $ligne inconnue Ligne : $cont ignoree", LOG_INFO);
array_push($this->messages,array('warning',"Ligne $ligne inconnue"));
}
array_push($unknown_lines, $ligne);
}
$line++;
}
dol_syslog("FacturationImportCdr::Import $line lignes traitees dans le fichier", LOG_INFO);
$level = ($line > 0) ? 'info':'warning';
array_push($this->messages,array($level,"$line lignes traitees dans le fichier"));
dol_syslog("FacturationImportCdr::Import $line_inserted insert effectues", LOG_INFO);
$level = ($line_inserted > 0) ? 'info':'warning';
array_push($this->messages,array($level,"$line_inserted ajout dans la table des CDR a traiter"));
if (sizeof($this->message_bad_file_format))
{
foreach ($this->message_bad_file_format as $key => $value)
{
array_push($this->messages,array('warning',"$value ligne(s) au mauvais format dans $key"));
}
}
if ($error == 0)
{
$this->db->query("COMMIT");
array_push($this->messages, array('info',"Fichier ".basename($xfile)." : importation reussie"));
}
else
{
$this->db->query("ROLLBACK");
dol_syslog("ROLLBACK");
array_push($this->messages, array('error',"Fichier ".basename($xfile)." : echec de l'importation"));
}
}
else
{
array_push($this->messages, array('error',"Fichier ".basename($xfile)." : echec de l'importation"));
}
}
}
else
{
print "Erreur lecture : $xfile";
dol_syslog($xfile . " not readable");
array_push($this->messages, "Fichier ".basename($xfile)." not readable");
}
}
return $error;
}
/**
\brief Verifie que le fichier n'a pas deja ete charge/traite
*/
function _verif($db, $file, $fichiers)
{
$result = 0;
if (in_array (basename($file), $fichiers))
{
dol_syslog ("Fichier ".basename($file)." deja charge/traite");
array_push($this->messages, array('warning',"Fichier ".basename($file)." deja charge/traite"));
$result = -1;
}
return $result;
}
}

Some files were not shown because too many files have changed in this diff Show More