From 0dcfc7bb9706837dc4d88df4fef9aeb28332221e Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 26 Jan 2005 17:16:21 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20lien=20vers=20les=20contrats=20aff=E9ra?= =?UTF-8?q?nts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/telephonie/ligne/fiche.php | 617 +++++++++++++++++------------- 1 file changed, 361 insertions(+), 256 deletions(-) diff --git a/htdocs/telephonie/ligne/fiche.php b/htdocs/telephonie/ligne/fiche.php index b88357c536a..54141069f15 100644 --- a/htdocs/telephonie/ligne/fiche.php +++ b/htdocs/telephonie/ligne/fiche.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2005 Rodolphe Quiedeville * * 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 @@ -20,8 +20,9 @@ * */ -require("./pre.inc.php"); - +require "./pre.inc.php"; +require_once DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php"; +require_once DOL_DOCUMENT_ROOT.'/telephonie/telephonie.contrat.class.php'; $mesg = ''; @@ -34,7 +35,7 @@ $s = strftime("%S",$dt); if ($_POST["action"] == 'add') { $ligne = new LigneTel($db); - + $ligne->contrat = $_POST["contrat"]; $ligne->numero = $_POST["numero"]; $ligne->client_comm = $_POST["client_comm"]; $ligne->client = $_POST["client"]; @@ -52,6 +53,7 @@ if ($_POST["action"] == 'add') else { $_GET["action"] = 'create'; + $_GET["contratid"] = $_POST["contrat"]; } } @@ -147,6 +149,36 @@ if ($_GET["action"] == 'confirmresilier') $_POST["reday"], $_POST["reyear"])); + $comm = new User($db,$ligne->commercial_id); + $comm->fetch(); + + $soc = new Societe($db); + $soc->fetch($ligne->socid); + + /* + * Envoi mail au commercial responsable + * + */ + + $subject = "Résiliation de la ligne ".$ligne->numero; + $sendto = $comm->prenom . " " .$comm->nom . "<".$comm->email.">"; + $from = $user->prenom . " " .$user->nom . "<".$user->email.">"; + + $message = "La ligne numéro ".$ligne->numero; + $message .= " de la société : ".$soc->nom; + $message .= ", a été désactivée le ".strftime("%d/%m/%Y",mktime($h, $m , $s, $_POST["remonth"], $_POST["reday"], $_POST["reyear"])); + $message .= " pour la raison suivante : ".$_POST["commentaire"]; + $message .= "."; + $message .= "\n\n--\n"; + $message .= "Ceci est un message automatique envoyé par Dolibarr"; + + $mailfile = new DolibarrMail($subject, + $sendto, + $from, + $message); + $mailfile->sendfile(); + + if ( $ligne->set_statut($user, 6, $datea, $_POST["commentaire"]) == 0) { Header("Location: fiche.php?id=".$ligne->id); @@ -202,11 +234,10 @@ if ($cancel == $langs->trans("Cancel")) } /* - * Création + * Création en 2 étape * */ - -if ($_GET["action"] == 'create') +if ($_GET["action"] == 'create1') { $form = new Form($db); print_titre("Nouvelle ligne"); @@ -221,10 +252,8 @@ if ($_GET["action"] == 'create') $ligne = new LigneTel($db); } - print "
\n"; - print ''; - print ''."\n"; - + print ''; + print ''; print ''; @@ -250,141 +279,204 @@ if ($_GET["action"] == 'create') $form->select_array("client_comm",$ff,$ligne->client_comm); print ''; - - - print ''; - - print ''; - - print ''; - - print ''; - - /* - * Commercial - */ - - print ''; - - /* - * Concurrents - */ - - print ''; - - print ''."\n"; - - print ''."\n"; - print ''."\n"; print '
Numéro
Client (Agence/Filiale)'; - $ff = array(); - $sql = "SELECT idp, 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]] = $row[1] . " (".$row[2].")"; - $i++; - } - } - $db->free(); - } - $form->select_array("client",$ff,$ligne->client); - print '
Client à facturer'; - $ff = array(); - $sql = "SELECT idp, 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]] = $row[1] . " (".$row[2].")"; - $i++; - } - } - $db->free(); - } - $form->select_array("client_facture",$ff,$ligne->client_facture); - print '
Fournisseur'; - $ff = array(); - $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur WHERE commande_active = 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]] = $row[1]; - $i++; - } - } - $db->free(); - - } - $form->select_array("fournisseur",$ff,$ligne->fournisseur); - print '
Commercial'; - $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]] = $row[1] . " " . $row[2]; - $i++; - } - } - $db->free(); - - } - - $form->select_array("commercial",$ff,$ligne->commercial); - - print '
Fournisseur précédent'; - $ff = array(); - $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_concurrents ORDER BY rowid "; - if ( $db->query( $sql) ) - { - $num = $db->num_rows(); - if ( $num > 0 ) - { - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($i); - $ff[$row[0]] = $row[1]; - $i++; - } - } - $db->free(); - - } - $form->select_array("concurrent",$ff,$ligne->concurrent); - print '
Remise LMN %
Note'."\n"; - print '
 
'."\n"; print '
'; } +elseif ($_GET["action"] == 'create' && $_GET["contratid"] > 0) +{ + + $contrat = new TelephonieContrat($db); + $contrat->fetch($_GET["contratid"]); + + + $form = new Form($db); + print_titre("Nouvelle ligne sur le contrat : ".$contrat->ref); + + if (is_object($ligne)) + { + // La création a échouée + print $ligne->error_message; + } + else + { + $ligne = new LigneTel($db); + } + + + $socc = new Societe($db); + //if ( $socc->fetch($_GET["client_comm"]) == 1) + if ( $socc->fetch($contrat->client_comm_id) == 1) + { + + if (strlen($socc->code_client) == 0) + { + print ''; + print ''; + + print ''; + print '
Client'; + print ''.$socc->nom.''; + print '
Code client'; + print $socc->code_client; + print '


'; + print 'Impossible de créer une ligne pour cette société, vous devez au préalablement lui affecter un code client.'; + } + elseif (strlen($socc->code_client) > 0 && $socc->check_codeclient() <> 0) + { + print ''; + print ''; + + print ''; + print '
Client'; + print ''.$socc->nom.''; + print '
Code client'; + print $socc->code_client; + print '


'; + print 'Le code client de cette société est incorrect, vous devez lui affecter un code client correct.'; + } + else + { + print '
'; + print ''; + print ''."\n"; + print ''."\n"; + + print ''; + print ''; + + print ''; + + + print ''; + + $client = new Societe($db, $contrat->client_id); + $client->fetch($contrat->client_id); + + print ''; + print ''; + + $client_facture = new Societe($db); + $client_facture->fetch($contrat->client_facture_id); + + print ''; + + /* + * Commercial + */ + + print ''; + + /* + * Concurrents + */ + + print ''; + + print ''."\n"; + + print ''."\n"; + + print ''."\n"; + print '
Client'; + print $socc->nom; + print '
Code client'; + print $socc->code_client; + print '
Numéro
Client (Agence/Filiale)'; + print $client->nom.'
'; + + print $client->cp . " " .$client->ville; + print '
Client Facturé'; + print $client_facture->nom.'
'; + print $client_facture->cp . " " .$client_facture->ville; + + print '
'; + print ''; + + print '
Fournisseur'; + $ff = array(); + $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur WHERE commande_active = 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]] = $row[1]; + $i++; + } + } + $db->free(); + + } + $form->select_array("fournisseur",$ff,$ligne->fournisseur); + print '
Commercial'; + $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]] = $row[1] . " " . $row[2]; + $i++; + } + } + $db->free(); + + } + + $form->select_array("commercial",$ff,$ligne->commercial); + + print '
Fournisseur précédent'; + $ff = array(); + $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_concurrents ORDER BY rowid "; + if ( $db->query( $sql) ) + { + $num = $db->num_rows(); + if ( $num > 0 ) + { + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($i); + $ff[$row[0]] = $row[1]; + $i++; + } + } + $db->free(); + + } + $form->select_array("concurrent",$ff,$ligne->concurrent); + print '
Remise LMN %
Note'."\n"; + print '
 
'."\n"; + print '
'; + + } + + } + else + { + print "Erreur"; + } + +} else { + /* + * Mode Visualisation + * + * + */ if ($_GET["id"] or $_GET["numero"]) { if ($_GET["action"] <> 're-edit') @@ -411,6 +503,10 @@ else $hselected = $h; $h++; + $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/factures.php?id=".$ligne->id; + $head[$h][1] = $langs->trans('Factures'); + $h++; + $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/infoc.php?id=".$ligne->id; $head[$h][1] = $langs->trans('Infos'); $h++; @@ -422,6 +518,10 @@ else $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/conso.php?id=".$ligne->id; $head[$h][1] = $langs->trans('Conso'); $h++; + + $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/stat.php?id=".$ligne->id; + $head[$h][1] = $langs->trans('Stats'); + $h++; dolibarr_fiche_head($head, $hselected, 'Ligne : '.$ligne->numero); @@ -429,13 +529,21 @@ else print ''; + if ($ligne->contrat) + { + $contrat = new TelephonieContrat($db); + $contrat->fetch($ligne->contrat); + + print ''; + } + $client_comm = new Societe($db, $ligne->client_comm_id); $client_comm->fetch($ligne->client_comm_id); - print ''; print ''; @@ -450,6 +558,8 @@ else print $client->cp . " " .$client->ville; print ''; + + $client_facture = new Societe($db); $client_facture->fetch($ligne->client_facture_id); @@ -471,6 +581,23 @@ else print ''; + print ''; + print ''; $commercial = new User($db, $ligne->commercial_id); @@ -479,7 +606,7 @@ else print ''; print ''; - print ''; + print ''; print ''; print '
Contrat'.$contrat->ref_url.'
Client'; + print '
Client'; print ''; - print $client_comm->nom.' '.$client_comm->code_client; + print $client_comm->nom.''.$client_comm->code_client; print '
Numéro'.dolibarr_print_phone($ligne->numero).'
Fournisseur'; + + $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur"; + $sql .= " WHERE commande_active = 1 AND rowid = ".$ligne->fournisseur_id; + + if ( $db->query( $sql) ) + { + $num = $db->num_rows(); + if ( $num > 0 ) + { + $row = $db->fetch_row(); + print $row[1]; + } + $db->free(); + } + print '
Remise LMN'.$ligne->remise.' %
Commercial'.$commercial->fullname.'
Fournisseur précédent
Concurrent précédent'.$ligne->print_concurrent_nom().'
Statut'; @@ -576,122 +703,99 @@ else print ''; print ''; - - print ''; - print ''; - - print ''; - - print ''; - - print ''; + print ''."\n"; + + print ''; + + $client = new Societe($db, $ligne->client_id); + $client->fetch($ligne->client_id); - print ''; + print ''; + print ''; + + $client_facture = new Societe($db); + $client_facture->fetch($ligne->client_facture_id); + + print ''; + print ''; + + print ''; - print "\n".'"; - print ''; print '
Client'; - print '
Numéro
Client (Agence/Filiale)'; - print '
Client à facturer'."\n"; - print '
Fournisseur'; - print '
Client'; + print $client_comm->nom; + print '
Numéro'; + if ($ligne->statut == -1) + { + print ''; } + else + { + print ''; + print dolibarr_print_phone($ligne->numero); + } + print '
Client (Agence/Filiale)'; + print $client->nom.'
'; + + print $client->cp . " " .$client->ville; + print '
Client Facturé'; + print $client_facture->nom.'
'; + print $client_facture->cp . " " .$client_facture->ville; + + print '
Fournisseur'; + + if ($ligne->statut == -1) + { + print ''; + } + else + { + print ''; + + $sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur"; + $sql .= " WHERE commande_active = 1 AND rowid = ".$ligne->fournisseur_id; + + if ( $db->query( $sql) ) + { + $num = $db->num_rows(); + if ( $num > 0 ) + { + $row = $db->fetch_row(); + print $row[1]; + } + $db->free(); + } + } + + print '
Commercial'; + print "\n".'
Commercial'; print '
Fournisseur précédent'; + print '
Fournisseur précédent'; print '
 '; + print '
'; print 'Annuler
'."\n"; print ''."\n"; @@ -980,6 +1084,7 @@ if ($_GET["action"] == '') print "id\">".$langs->trans("Contact").""; print "id\">".$langs->trans("Edit").""; + } print "";