diff --git a/htdocs/telephonie/ligne/commande/fiche.php b/htdocs/telephonie/ligne/commande/fiche.php new file mode 100644 index 00000000000..7a70d1f17ac --- /dev/null +++ b/htdocs/telephonie/ligne/commande/fiche.php @@ -0,0 +1,168 @@ + + * + * 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_erreur = ""; + +$page = $_GET["page"]; +$sortorder = $_GET["sortorder"]; +$sortfield = $_GET["sortfield"]; + +if ($_GET["action"] == "create") +{ + + $fourntel = new FournisseurTelephonie($db,1); + if ( $fourntel->fetch() == 0) + { + $ct = new CommandeTableur($db, $user, $fourntel); + + $result = $ct->create(); + + if ($result == 0) + { + Header("Location: archives.php"); + } + elseif ($result == -3) + { + /* Erreur */ + $mesg_erreur = "Email fournisseur non définit"; + } + } +} + + +llxHeader("","Telephonie - Ligne - Commande"); + +print $mesg_erreur; + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + +if ($sortorder == "") { + $sortorder="ASC"; +} +if ($sortfield == "") { + $sortfield="s.nom"; +} + +/* + * Recherche + * + * + */ +if ($mode == 'search') { + if ($mode-search == 'soc') { + $sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s "; + $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'"; + } + + if ( $db->query($sql) ) { + if ( $db->num_rows() == 1) { + $obj = $db->fetch_object(0); + $socid = $obj->idp; + } + $db->free(); + } +} + +if ($page == -1) { $page = 0 ; } + +$offset = $conf->liste_limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + +/* + * Mode Liste + * + * + * + */ + +$sql = "SELECT sf.idp as sfidp, sf.nom as sfnom, s.idp as socidp, s.nom, l.ligne, f.nom as fournisseur, l.statut, l.rowid"; +$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 .= " , ".MAIN_DB_PREFIX."societe as sf"; +$sql .= " WHERE l.fk_soc = s.idp AND l.fk_fournisseur = f.rowid AND l.statut IN (1,4) "; +$sql .= " AND l.fk_soc_facture = sf.idp"; +$sql .= " ORDER BY $sortfield $sortorder "; + +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows(); + $i = 0; + + print_barre_liste("Commande", $page, "liste.php", "", $sortfield, $sortorder, '', $num); + + print ''; + print ''; + print "\n"; + + $var=True; + + $ligne = new LigneTel($db); + + while ($i < $num) + { + $obj = $db->fetch_object($i); + $var=!$var; + + $socf = new Societe($db); + $socf->fetch($obj->sfidp); + + print ""; + print '\n"; + print '\n"; + print ''; + print ''; + print ''; + print "\n"; + print "\n"; + $i++; + } + print "
Ligne'; + print 'StatutClient'; + print 'Client FacturéRib OKFournisseur
'.dolibarr_print_phone($obj->ligne)."'.$ligne->statuts[$obj->statut]."'.$obj->nom.''.$obj->sfnom.''.$socf->verif_rib().'".$obj->fournisseur."
"; + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; +} + +if ($num > 0) +{ + print "
\n
\n"; + print 'Créer la commande'; + print '
'; +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/telephonie/ligne/communications.php b/htdocs/telephonie/ligne/communications.php new file mode 100644 index 00000000000..6a5bb89751c --- /dev/null +++ b/htdocs/telephonie/ligne/communications.php @@ -0,0 +1,154 @@ + + * + * 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"]; + +llxHeader(); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + +if ($sortorder == "") { + $sortorder="DESC"; +} +if ($sortfield == "") { + $sortfield="l.date"; +} + +if ($page == -1) { $page = 0 ; } + +$offset = $conf->liste_limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + +/* + * Mode Liste + * + * + * + */ + +$sql = "SELECT ligne, numero, date, fourn_cout, fourn_montant, duree, tarif_achat_temp, tarif_achat_fixe, tarif_vente_temp, tarif_vente_fixe, cout_achat, cout_vente, remise"; + +$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as l"; + +if ($_GET["ligne"]) +{ + $sql .= " WHERE ligne like '%".$_GET["ligne"]."%'"; + + if ($_GET["numero"]) + { + $sql .= " AND numero like '%".$_GET["numero"]."%'"; + + } +} + +//$sql .= " WHERE fourn_montant > cout_vente AND cout_vente > 0"; + + +$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); + +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows(); + $i = 0; + + print_barre_liste("Communications", $page, "communications.php", '&ligne='.$_GET["ligne"], $sortfield, $sortorder, '', $num); + + print ''; + print ''; + print_liste_field_titre("Ligne","communications.php","l.ligne"); + print '"; + print ''; + + print ''; + print ''; + print ''; + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + + + + print ''; + print ''; + + print ''; + print ''; + + + $var=True; + + while ($i < min($num,$conf->liste_limit)) + { + $obj = $db->fetch_object($i); + $var=!$var; + + print ""; + print "\n"; + print '\n"; + print '\n"; + print '\n"; + + print '\n"; + print '\n"; + + print '\n"; + print '\n"; + + print '\n"; + print '\n"; + + print '\n"; + + print "\n"; + $i++; + } + print "
DateNuméro'; + print "DuréePrix VenteCout AchatVente /secVente FixeAchat /secAchat FixeRemise
  Tarifs
".$obj->ligne."'.$obj->date."'.$obj->numero."'.$obj->duree."'.sprintf("%01.4f",$obj->cout_vente)."'.sprintf("%01.4f",$obj->cout_achat)."'.sprintf("%01.4f",$obj->tarif_vente_temp)."'.sprintf("%01.4f",$obj->tarif_vente_fixe)."'.sprintf("%01.4f",$obj->tarif_achat_temp)."'.sprintf("%01.4f",$obj->tarif_achat_fixe)."'.$obj->remise." %
"; + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/telephonie/ligne/groupe.php b/htdocs/telephonie/ligne/groupe.php new file mode 100644 index 00000000000..8b24f1c488d --- /dev/null +++ b/htdocs/telephonie/ligne/groupe.php @@ -0,0 +1,190 @@ + + * + * 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 = ''; + $socidp = $user->societe_id; +} + +if ($sortorder == "") { + $sortorder="ASC"; +} +if ($sortfield == "") { + $sortfield="l.statut"; +} + +/* + * Recherche + * + * + */ + +if ($page == -1) { $page = 0 ; } + +$offset = $conf->liste_limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + +/* + * Mode Liste + * + * + * + */ + +$sql = "SELECT g.nom as gnom, s.idp as socidp, sf.idp as sfidp, sf.nom as nom_facture,s.nom, 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 sf"; + + +$sql .= " , ".MAIN_DB_PREFIX."telephonie_groupeligne as g"; +$sql .= " , ".MAIN_DB_PREFIX."telephonie_groupe_ligne as gl"; + + +$sql .= " WHERE l.fk_soc = s.idp "; + +$sql .= " AND g.rowid = gl.fk_groupe"; +$sql .= " AND gl.fk_ligne = l.rowid"; + + +$sql .= " AND l.fk_soc_facture = sf.idp"; + +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 ($_GET["search_client_facture"]) +{ + $sel =urldecode($_GET["search_client_facture"]); + $sql .= " AND sf.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= "&statut=".$_GET["statut"]; + + print_barre_liste("Lignes", $page, "groupe.php", $urladd, $sortfield, $sortorder, '', $num); + print"\n\n"; + print ''; + print ''; + + print_liste_field_titre("Ligne","groupe.php","l.ligne"); + print_liste_field_titre("Client","groupe.php","s.nom"); + + print ''; + print ''; + + print_liste_field_titre("Remise LMN","groupe.php","l.remise","","",' align="center"'); + + print "\n"; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + + + + print ''; + + print ''; + print ''; + + + $var=True; + + $ligne = new LigneTel($db); + + while ($i < min($num,$conf->liste_limit)) + { + $obj = $db->fetch_object($i); + $var=!$var; + + print ""; + + print "\n"; + + print ''; + print ''; + + print '\n"; + + print '\n"; + + print "\n"; + $i++; + } + print "
GroupeClient facturéStatut
  
".$obj->gnom."\n"; + + print ' '; + + print ''; + print img_file(); + print ' '; + + print ''.dolibarr_print_phone($obj->ligne)."'.$obj->nom.''.$obj->nom_facture.''.$ligne->statuts[$obj->statut]."'.$obj->remise." %
"; + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/telephonie/ligne/numdata.php b/htdocs/telephonie/ligne/numdata.php new file mode 100644 index 00000000000..af4b6f0fc20 --- /dev/null +++ b/htdocs/telephonie/ligne/numdata.php @@ -0,0 +1,204 @@ + + * + * 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"]; + +if ($_POST["action"] == 'addnum') +{ + + if (strlen(trim($_POST["numero"])) > 0) + { + $sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_numdata"; + $sql .= " (fk_groupe, numero,fk_user) VALUES "; + $sql .= " (".$_POST["groupeid"].",'".$_POST["numero"]."',".$user->id.")"; + + if ( $db->query($sql) ) + { + //Header("Location: numdata.php?id=".$ligne->id); + Header("Location: numdata.php?id=".$ligne->id); + } + else + { + print $db->error(); + } + } +} + +if ($_GET["action"] == 'delete') +{ + + if (strlen(trim($_GET["id"])) > 0) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_numdata"; + $sql .= " WHERE rowid = ".$_GET["id"]; + + if ( $db->query($sql) ) + { + Header("Location: numdata.php"); + } + else + { + print $db->error(); + } + } +} + +llxHeader('','Telephonie - Ligne - Liste'); +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + + +/* + * Recherche + * + * + */ + +if ($page == -1) { $page = 0 ; } + +$offset = $conf->liste_limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + +/* + * Mode Liste + * + * + * + */ + + +print_barre_liste("Numéros data", $page, "numdata.php", $urladd, $sortfield, $sortorder, '', $num); + +print ''; +print ''; +print_liste_field_titre("Numéro","numdata.php","l.ligne"); + +print_liste_field_titre("Client","numdata.php","s.nom"); +print ''; + +print "\n"; + +print ''; +print ''; +print ''; print ''; + +print ''; + +print ''; +print ''; + + +print ''; +print ''; +print ''; +print ''; + +print ''; +print ''; + +print ''; +print ''; + + +$sql = "SELECT g.nom, n.numero, n.rowid"; +$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_groupeligne as g"; +$sql .= ",".MAIN_DB_PREFIX."telephonie_numdata as n"; + +$sql .= " WHERE n.fk_groupe = g.rowid"; + +if ($sortorder == "") { + $sortorder="ASC"; +} +if ($sortfield == "") { + $sortfield="g.nom"; +} + + +$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); + +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows(); + $i = 0; + + $var=True; + + $ligne = new LigneTel($db); + + while ($i < min($num,$conf->liste_limit)) + { + $obj = $db->fetch_object($i); + $var=!$var; + + print "\n"; + print ''; + + print ''; + + print "\n"; + $i++; + } + + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; +} + + print "
 
"; + + print dolibarr_print_phone($obj->numero)."'.$obj->nom.''; + print img_delete(); + print '
"; + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/telephonie/sql/llx_telephonie_facture.sql b/htdocs/telephonie/sql/llx_telephonie_facture.sql index 966ab4fdc68..0e7d4209d7a 100644 --- a/htdocs/telephonie/sql/llx_telephonie_facture.sql +++ b/htdocs/telephonie/sql/llx_telephonie_facture.sql @@ -20,6 +20,7 @@ -- -- ======================================================================== + create table llx_telephonie_facture ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_ligne integer NOT NULL, diff --git a/htdocs/telephonie/stats/index.php b/htdocs/telephonie/stats/index.php new file mode 100644 index 00000000000..322216f16ce --- /dev/null +++ b/htdocs/telephonie/stats/index.php @@ -0,0 +1,75 @@ + + * + * 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 - Ligne'); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + +/* + * Mode Liste + * + * + * + */ + +print ''; + +print ''; + + + +print ''; + + +print '
'; + +print '

'; +print '

'; + + +print '
'; + +print '

'; +print ''; + +print '
'; + + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/telephonie/stats/pre.inc.php b/htdocs/telephonie/stats/pre.inc.php new file mode 100644 index 00000000000..ded3ead5952 --- /dev/null +++ b/htdocs/telephonie/stats/pre.inc.php @@ -0,0 +1,62 @@ + + * + * 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/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/fournisseurs.php", "Fournisseurs"); + + $menu->add(DOL_URL_ROOT."/telephonie/stats/", "Stats"); + $menu->add_submenu(DOL_URL_ROOT."/telephonie/stats/clients/", "Clients"); + $menu->add_submenu(DOL_URL_ROOT."/telephonie/stats/commerciaux/", "Commerciaux"); + $menu->add_submenu(DOL_URL_ROOT."/telephonie/stats/lignes/", "Lignes"); + + $menu->add(DOL_URL_ROOT."/telephonie/statca/", "Chiffre d'affaire"); + + left_menu($menu->liste); +} + +?>