From 5a658d82b390eb42c7d0ecc453fd59347024ae18 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Fri, 3 Dec 2004 09:43:53 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/telephonie/graph-1.png | Bin 0 -> 198 bytes htdocs/telephonie/graph1.png | Bin 0 -> 197 bytes htdocs/telephonie/graph2.png | Bin 0 -> 191 bytes htdocs/telephonie/graph3.png | Bin 0 -> 193 bytes htdocs/telephonie/graph4.png | Bin 0 -> 198 bytes htdocs/telephonie/graph5.png | Bin 0 -> 198 bytes htdocs/telephonie/graph6.png | Bin 0 -> 193 bytes htdocs/telephonie/graph7.png | Bin 0 -> 209 bytes htdocs/telephonie/index.php | 205 +++++++++++ htdocs/telephonie/lignetel.class.php | 494 +++++++++++++++++++++++++++ htdocs/telephonie/pre.inc.php | 64 ++++ 11 files changed, 763 insertions(+) create mode 100644 htdocs/telephonie/graph-1.png create mode 100644 htdocs/telephonie/graph1.png create mode 100644 htdocs/telephonie/graph2.png create mode 100644 htdocs/telephonie/graph3.png create mode 100644 htdocs/telephonie/graph4.png create mode 100644 htdocs/telephonie/graph5.png create mode 100644 htdocs/telephonie/graph6.png create mode 100644 htdocs/telephonie/graph7.png create mode 100644 htdocs/telephonie/index.php create mode 100644 htdocs/telephonie/lignetel.class.php create mode 100644 htdocs/telephonie/pre.inc.php diff --git a/htdocs/telephonie/graph-1.png b/htdocs/telephonie/graph-1.png new file mode 100644 index 0000000000000000000000000000000000000000..7a8fb19836863bc7b7f7eee1f809db6adf2fc626 GIT binary patch literal 198 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kwj^(N7l!`~4GjPP3v~Pgif|Tq zL>2>eTxVe5JHn{gn6eot$X?><>&kwGi=9VV&|ki)3@9X9;u=xnoS&PUnpeW$T$Gwv zlA5AWo>`Ki5R#Fq;O^-g@IFN~52#Sf)5S5Q;#P7>Lc)*p4onG&2|&jG`4+Z4Jv}@= lJSt6ryv@$c$}2sY87}9risv)*uLbI2@O1TaS?83{1OPk+H@pA< literal 0 HcmV?d00001 diff --git a/htdocs/telephonie/graph1.png b/htdocs/telephonie/graph1.png new file mode 100644 index 0000000000000000000000000000000000000000..134f1b74b305154a2e4ab14812c4ffa37f6c9035 GIT binary patch literal 197 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kwj^(N7l!{JxM1({$v_d#0*}aI zppNSd417lz6&q7F0|nVjJbhi+uW+$)vg%Z1?^gy2$(FcAlsM<-=BDPAFgO>bCYGe8 zD3oWGWGIAWq$;?3`UbpDQOyG?)bw<545_%4oRX06bCYGe8 zD3oWGWGIAWq$;?3`UbpDQOyG?RP}Um45_%4oRX06bCYGe8 zD3oWGWGIAWq$;?3`UbpDQOyG?)bez345_%4oRX06gTe~DWM4f+%-8K literal 0 HcmV?d00001 diff --git a/htdocs/telephonie/graph6.png b/htdocs/telephonie/graph6.png new file mode 100644 index 0000000000000000000000000000000000000000..4d8f59be1c226e76c2ddc5a89f5bde2f7de5da8e GIT binary patch literal 193 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kwj^(N7l!{JxM1({$v_d#0*}aI zppNSd417lz6&q7F0|nVjJbhi+uW+&RC~7F_O!xy7k}YwKC~?lu%}vcKVQ?-=O)N=G zQ7F$W$xsN%NL6t6^bL5QqM8R(sOstB7*cU7IVBZOB%3JUOAoFUl*+*Fxn1%h!w7D+FqJxR0yKO#>Rh;OXk;vd$@?2>{d!Kmh;% literal 0 HcmV?d00001 diff --git a/htdocs/telephonie/index.php b/htdocs/telephonie/index.php new file mode 100644 index 00000000000..a501ca51614 --- /dev/null +++ b/htdocs/telephonie/index.php @@ -0,0 +1,205 @@ + + * + * 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'); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + +/* + * Mode Liste + * + * + * + */ + +print ''; + +print ''; + + + + +print '
'; + +print '
'; +print ''; +print ''; +print "\n"; +print ""; +print ''; +print '
Recherche ligne
Numéro
'; + +print '
'; + + +$sql = "SELECT distinct statut, count(*) as cc"; +$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; +$sql .= " GROUP BY statut"; + +if ($db->query($sql)) +{ + $num = $db->num_rows(); + $i = 0; + $ligne = new LigneTel($db); + + print ''; + print ''; + print "\n"; + $var=True; + + while ($i < min($num,$conf->liste_limit)) + { + $obj = $db->fetch_object($i); + $var=!$var; + + print ""; + print "\n"; + print "\n"; + print "\n"; + $i++; + } + print "
Lignes StatutsNb
".$ligne->statuts[$obj->statut]."".$obj->cc."
"; + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; +} + +print '
'; + +/* + * + * + */ + +$sql = "SELECT distinct f.nom as fournisseur, count(*) as cc"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; +$sql .= " , ".MAIN_DB_PREFIX."telephonie_fournisseur as f"; +$sql .= " WHERE l.fk_soc = s.idp AND l.fk_fournisseur = f.rowid"; +$sql .= " GROUP BY f.nom"; + +if ($db->query($sql)) +{ + $num = $db->num_rows(); + $i = 0; + + print ''; + print ''; + print "\n"; + $var=True; + + while ($i < min($num,$conf->liste_limit)) + { + $obj = $db->fetch_object($i); + $var=!$var; + + print ""; + print "\n"; + print '\n"; + print "\n"; + $i++; + } + print "
FournisseurNb lignes
".$obj->fournisseur."'.$obj->cc."
"; + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; +} + +print '
'; + +$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, f.total_ttc, sum(pf.amount) as am"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f "; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; +$sql .= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; +$sql .= " GROUP BY f.facnumber,f.rowid,s.nom, s.idp, f.total_ttc"; + +if ( $db->query($sql) ) +{ + $num = $db->num_rows(); + $i = 0; + + if ($num) + { + print ''; + print ''; + $var = True; + $total = $totalam = 0; + while ($i < $num ) + { + $obj = $db->fetch_object( $i); + if ($obj->total_ttc <> $obj->am) + { + $var=!$var; + print ''; + print ''; + print ''; + print ''; + $total += $obj->total_ttc; + $totalam += $obj->am; + } + $i++; + } + $var=!$var; + print ''; + print "
Factures clients impayées ('.$num.')Montant TTCReçu
'.img_file().''; + print ' '.$obj->facnumber.''.$obj->nom.''.price($obj->total_ttc).''.price($obj->am).'
Reste à encaisser : '.price($total-$totalam).''.price($total).''.price($totalam).'

"; + } + $db->free(); +} +else +{ + print $sql; +} + + + + + + + + + +print '
'; + + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/telephonie/lignetel.class.php b/htdocs/telephonie/lignetel.class.php new file mode 100644 index 00000000000..a4630146d3a --- /dev/null +++ b/htdocs/telephonie/lignetel.class.php @@ -0,0 +1,494 @@ + + * + * 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 LigneTel { + var $db; + + var $id; + var $ligne; + + function LigneTel($DB, $id=0) + { + global $config; + + $this->db = $DB; + + $this->statuts[-1] = "En attente"; + $this->statuts[1] = "A commander"; + $this->statuts[2] = "Commandée chez le fournisseur"; + $this->statuts[3] = "Activée"; + $this->statuts[4] = "A résilier"; + $this->statuts[5] = "Résiliation demandée"; + $this->statuts[6] = "Résiliée"; + $this->statuts[7] = "Rejetée"; + + 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; + } + } + /* + * Infos complémentaires + * + */ + function update_infoc($user) + { + + $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_societe_ligne"; + $sql .= " SET "; + $sql .= " code_analytique = '".$this->code_analytique."' "; + + $sql .= " WHERE rowid = ".$this->id; + + if ( $this->db->query($sql) ) + { + return 1; + } + else + { + print $this->db->error(); + print $sql ; + return 0; + } + } + /* + * + * + */ + function create($user) + { + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_societe_ligne"; + $sql .= " (fk_soc, fk_client_comm, ligne, fk_soc_facture, fk_fournisseur, note, remise, fk_commercial, statut, fk_user_creat, fk_concurrent)"; + $sql .= " VALUES ("; + $sql .= " $this->client,$this->client_comm,'$this->numero',$this->client_facture,$this->fournisseur, '$this->note','$this->remise',$this->commercial, -1,$user->id, $this->concurrent)"; + + if ( $this->db->query($sql) ) + { + $this->id = $this->db->last_insert_id(); + return 1; + } + else + { + print $this->db->error(); + return 0; + } + } + /* + * + * + */ + function fetch_by_id($id) + { + return $this->fetch(0, $id); + } + + + function fetch($ligne, $id = 0) + { + $sql = "SELECT rowid, fk_client_comm, fk_soc, fk_soc_facture, fk_fournisseur, ligne, remise, note, statut, fk_commercial, isfacturable, mode_paiement, fk_concurrent, code_analytique"; + $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as tl"; + + if ($id > 0) + { + $sql .= " WHERE tl.rowid = ".$id; + } + else + { + $sql .= " WHERE tl.ligne = ".$ligne; + } + + if ($this->db->query($sql)) + { + if ($this->db->num_rows()) + { + $obj = $this->db->fetch_object(0); + + $this->id = $obj->rowid; + $this->socid = $obj->fk_soc; + $this->numero = $obj->ligne; + $this->remise = $obj->remise; + $this->client_comm_id = $obj->fk_client_comm; + $this->client_id = $obj->fk_soc; + $this->client_facture_id = $obj->fk_soc_facture; + $this->fournisseur_id = $obj->fk_fournisseur; + $this->commercial_id = $obj->fk_commercial; + $this->concurrent_id = $obj->fk_concurrent; + $this->statut = $obj->statut; + $this->mode_paiement = $obj->mode_paiement; + $this->code_analytique = $obj->code_analytique; + + if ($obj->isfacturable == 'oui') + { + $this->facturable = 1; + } + else + { + $this->facturable = 0; + } + + $result = 1; + } + else + { + $result = -2; + } + + $this->db->free(); + } + else + { + /* Erreur select SQL */ + print $this->db->error(); + $result = -1; + } + + return $result; + } + + /** + * + * + * + */ + function print_concurrent_nom() + { + $sql = "SELECT nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_concurrents"; + $sql .= " WHERE rowid=".$this->concurrent_id; + + + if ($this->db->query($sql)) + { + if ($this->db->num_rows()) + { + $row = $this->db->fetch_row(0); + + return $row[0]; + } + } + } + + + /** + * Change le statut de la ligne + * + */ + function set_statut($user, $statut, $datea='', $commentaire='') + { + $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_societe_ligne"; + $sql .= " SET statut = ".$statut ; + + if ($statut == 2) + { + $sql .= ", date_commande = now()"; + $sql .= ",fk_user_commande=".$user->id; + } + + $sql .= " WHERE rowid =".$this->id; + + $this->db->query($sql); + + if ($datea) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_societe_ligne_statut"; + $sql .= " (tms,fk_ligne, fk_user, statut, comment) "; + $sql .= " VALUES ($datea,$this->id, $user->id, $statut, '$commentaire' )"; + + $this->db->query($sql); + /* + * Mise à jour des logs + * + */ + $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_ligne_statistique"; + $sql .= " SET nb = nb - 1"; + $sql .= " WHERE statut = ".$this->statut; + $sql .= " AND dates >= '".$datea ."'"; + + $this->db->query($sql); + + $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_ligne_statistique"; + $sql .= " SET nb = nb + 1"; + $sql .= " WHERE statut = ".$statut; + $sql .= " AND dates >= '".$datea ."'"; + + $this->db->query($sql); + + } + else + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_societe_ligne_statut"; + $sql .= " (tms, fk_ligne, fk_user, statut, comment) "; + $sql .= " VALUES (now(), $this->id, $user->id, $statut, '$commentaire' )"; + + $this->db->query($sql); + } + + + + $sql = "SELECT distinct statut, count(*) FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne GROUP BY statut"; + + if ($this->db->query($sql)) + { + $num = $this->db->num_rows(); + $i = 0; + $sl = array(); + while ($i < $num) + { + $row = $this->db->fetch_row($i); + $sl[$i] = $row; + $i++; + } + + $i = 0; + + /* Nettoyage des logs */ + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_ligne_statistique"; + $sql .= " WHERE dates = now()"; + if (!$this->db->query($sql)) + { + print $sql; + } + + /* Insertion des nouveaux logs */ + + while ($i < $num) + { + $row = $sl[$i]; + + $sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_ligne_statistique"; + $sql .= " VALUES (now(),".$row[0].",".$row[1].")"; + if (!$this->db->query($sql)) + { + print $sql; + } + $i++; + } + } + else + { + print $sql; + } + + $this->log_clients(); + + return 0; + } + /* + * + * + */ + function log_clients() + { + $sql = "SELECT distinct s.idp "; + $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; + $sql .= " , ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE l.statut = 3 AND s.idp = l.fk_soc "; + + if ($this->db->query($sql)) + { + $num = $this->db->num_rows(); + $nbclients = $num; + $i = 0; + + /* Insertion des nouveaux logs */ + + $sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_client_statistique"; + $sql .= " VALUES (now(),'nbclient',".$num.")"; + if (!$this->db->query($sql)) + { + print $sql; + } + } + else + { + print $sql; + } + /* + * nbligne active / client + * + */ + + $sql = "SELECT count(*) "; + $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; + $sql .= " WHERE l.statut = 3"; + + if ($this->db->query($sql)) + { + $num = $this->db->num_rows(); + + $row = $this->db->fetch_row(0); + + /* Insertion des nouveaux logs */ + + if ($nbclients > 0) + { + $nblapc = ereg_replace(",",".",round($row[0]/$nbclients,3)); + } + + $sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_client_statistique"; + $sql .= " VALUES (now(),'nblapc','".$nblapc."')"; + if (!$this->db->query($sql)) + { + print $sql; + } + } + else + { + print $sql; + } + + + return 0; + + } + /* + * + * + */ + function add_contact($cid) + { + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_contact_facture"; + $sql .= " (fk_ligne, fk_contact) "; + $sql .= " VALUES ($this->id, $cid )"; + + $this->db->query($sql); + } + /* + * + * + */ + function del_contact($cid) + { + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_contact_facture"; + $sql .= " WHERE fk_ligne=$this->id AND fk_contact=$cid ;"; + + return $this->db->query($sql); + } + /* + * + */ + function get_contact_facture() + { + $this->contact_facture_id = array(); + $res = array(); + $resid = array(); + + + $sql = "SELECT c.idp, c.name, c.firstname, c.email "; + $sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c"; + $sql .= ",".MAIN_DB_PREFIX."telephonie_contact_facture as cf"; + $sql .= " WHERE c.idp = cf.fk_contact AND cf.fk_ligne = ".$this->id." ORDER BY name "; + + if ( $this->db->query( $sql) ) + { + $num = $this->db->num_rows(); + if ( $num > 0 ) + { + $i = 0; + while ($i < $num) + { + $row = $this->db->fetch_row($i); + + array_push($res, $row[1] . " " . $row[2] . " <".$row[3].">"); + array_push($resid, $row[0]); + $i++; + } + + $this->db->free(); + } + + } + $this->contact_facture_id = $resid; + return $res; + } + /** + * Recupére le numéro d'une ligne depuis une facture comptable + * + */ + + function fetch_by_facture_number($facnumber) + { + $sql = "SELECT fk_ligne, fk_facture "; + $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture"; + $sql .= " WHERE fk_facture = ".$facnumber; + + + if ($this->db->query($sql)) + { + if ($this->db->num_rows()) + { + $row = $this->db->fetch_row(0); + + $this->id = $row[0]; + + return 0; + } + else + { + return -1; + } + } + else + { + return -2; + } + } + /* + * + * + */ + +} + +?> diff --git a/htdocs/telephonie/pre.inc.php b/htdocs/telephonie/pre.inc.php new file mode 100644 index 00000000000..1b050009713 --- /dev/null +++ b/htdocs/telephonie/pre.inc.php @@ -0,0 +1,64 @@ + + * + * 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_submenu(DOL_URL_ROOT."/telephonie/simulation/fiche.php?action=create", "Nouvelle"); + + $menu->add(DOL_URL_ROOT."/telephonie/tarifs/", "Tarifs"); + + $menu->add(DOL_URL_ROOT."/telephonie/client/index.php", "Clients"); + + $menu->add(DOL_URL_ROOT."/telephonie/ligne/index.php", "Lignes"); + + $menu->add(DOL_URL_ROOT."/telephonie/ligne/commande/", "Commandes"); + + $menu->add(DOL_URL_ROOT."/telephonie/facture/", "Factures"); + + $menu->add(DOL_URL_ROOT."/telephonie/stats/", "Statistiques"); + + $menu->add(DOL_URL_ROOT."/telephonie/fournisseurs.php", "Fournisseurs"); + + $menu->add(DOL_URL_ROOT."/telephonie/statca/", "Chiffre d'affaire"); + + if ($user->admin) + $menu->add(DOL_URL_ROOT."/telephonie/config/", "Configuration"); + + left_menu($menu->liste); +} + +?>