* * 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 = ''; $dt = time(); $h = strftime("%H",$dt); $m = strftime("%M",$dt); $s = strftime("%S",$dt); if ($_POST["action"] == 'add') { $ligne = new LigneTel($db); $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->create($user) == 0) { Header("Location: fiche.php?id=".$ligne->id); } else { $_GET["action"] = 'create'; } } if ($_POST["action"] == 'addcontact') { $ligne = new LigneTel($db); $ligne->id = $_GET["id"]; if ( $ligne->add_contact($_POST["contact_id"]) ) { Header("Location: fiche.php?id=".$ligne->id); } } if ($_GET["action"] == 'delcontact') { $ligne = new LigneTel($db); $ligne->id = $_GET["id"]; if ( $ligne->del_contact($_GET["contact_id"]) ) { Header("Location: fiche.php?id=".$ligne->id); } } if ($_GET["action"] == 'active') { $ligne = new LigneTel($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, 3, $datea) == 0) { Header("Location: fiche.php?id=".$ligne->id); } } if ($_GET["action"] == 'refuse') { $ligne = new LigneTel($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 LigneTel($db); $ligne->fetch_by_id($_GET["id"]); if ( $ligne->set_statut($user, 4) == 0) { Header("Location: fiche.php?id=".$ligne->id); } } if ($_GET["action"] == 'annuleresilier') { $ligne = new LigneTel($db); $ligne->fetch_by_id($_GET["id"]); if ( $ligne->set_statut($user, 3) == 0) { Header("Location: fiche.php?id=".$ligne->id); } } if ($_GET["action"] == 'confirmresilier') { $ligne = new LigneTel($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, 6, $datea, $_POST["commentaire"]) == 0) { Header("Location: fiche.php?id=".$ligne->id); } } if ($_GET["action"] == 'acommander') { $ligne = new LigneTel($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 LigneTel($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 à jour'; } else { $action = 're-edit'; $mesg = 'Fiche non mise à jour !' . "
" . $entrepot->mesg_error; } } llxHeader("","","Fiche Ligne"); if ($cancel == $langs->trans("Cancel")) { $action = ''; } /* * Création * */ if ($_GET["action"] == 'create') { $form = new Form($db); print_titre("Nouvelle ligne"); if (is_object($ligne)) { // La création a échouée print $ligne->error_message; } else { $ligne = new LigneTel($db); } print "
\n"; print ''; print ''."\n"; print ''; print ''; print ''; print ''; print ''; print ''; /* * Commercial */ print ''; /* * Concurrents */ print ''; print ''."\n"; print ''."\n"; print ''."\n"; print '
Client'; $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($i); $ff[$row[0]] = $row[1] . " (".$row[2].")"; $i++; } } $db->free(); } $form->select_array("client_comm",$ff,$ligne->client_comm); 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 '
'; } else { if ($_GET["id"] or $_GET["numero"]) { if ($_GET["action"] <> 're-edit') { $ligne = new LigneTel($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/ligne/fiche.php?id=".$ligne->id; $head[$h][1] = $langs->trans("Ligne"); $hselected = $h; $h++; $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/infoc.php?id=".$ligne->id; $head[$h][1] = $langs->trans('Infos'); $h++; $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/history.php?id=".$ligne->id; $head[$h][1] = $langs->trans('Historique'); $h++; $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/conso.php?id=".$ligne->id; $head[$h][1] = $langs->trans('Conso'); $h++; dolibarr_fiche_head($head, $hselected, 'Ligne : '.$ligne->numero); print_fiche_titre('Fiche Ligne', $mesg); print ''; $client_comm = new Societe($db, $ligne->client_comm_id); $client_comm->fetch($ligne->client_comm_id); print ''; print ''; print ''; $client = new Societe($db, $ligne->client_id); $client->fetch($ligne->client_id); print ''; $client_facture = new Societe($db); $client_facture->fetch($ligne->client_facture_id); print ''; print ''; $commercial = new User($db, $ligne->commercial_id); $commercial->fetch(); print ''; print ''; print ''; print ''; print ''; print ''; print ''; /* Contacts */ $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 = ".$ligne->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 ''; print '"; $i++; } } $db->free(); } else { print $sql; } /* Fin Contacts */ if ($_GET["action"] <> 'edit' && 0) { print ''; } print "
Client'; print ''; print $client_comm->nom.' '.$client_comm->code_client; print '
Numéro'.dolibarr_print_phone($ligne->numero).'Facturée : '.$ligne->facturable.'
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 '
'; if ($ligne->mode_paiement == 'pre') { print 'RIB : '.$client_facture->display_rib(); } else { print 'Paiement par virement'; } print '
Remise LMN'.$ligne->remise.' %
Commercial'.$commercial->fullname.'
Fournisseur précédent'.$ligne->print_concurrent_nom().'
Statut'; print ' '; print $ligne->statuts[$ligne->statut]; print '
Communications'; print 'liste'; print '
Factures'; print 'liste'; print '
Contact facture '.$i.''.$row[1] . " " . $row[2] . " <".$row[3].">
Point de rentabilité'; print ''; print '
"; } /* * Edition * * * */ if ($_GET["action"] == 'edit' || $action == 're-edit') { $h=0; $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/fiche.php?id=".$ligne->id; $head[$h][1] = $langs->trans("Ligne"); $hselected = $h; $h++; $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/infoc.php?id=".$ligne->id; $head[$h][1] = $langs->trans('Infos'); $h++; $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/history.php?id=".$ligne->id; $head[$h][1] = $langs->trans('Historique'); $h++; $head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/conso.php?id=".$ligne->id; $head[$h][1] = $langs->trans('Conso'); $h++; dolibarr_fiche_head($head, $hselected, 'Ligne : '.$ligne->numero); print_fiche_titre('Edition de la ligne', $mesg); print "
id\" method=\"post\">\n"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n".''; /* * Commercial */ print ''."\n"; /* * * */ print ''; print '"; print ''; print '
Client'; print '
Numéro
Client (Agence/Filiale)'; print '
Client à facturer'."\n"; print '
Fournisseur'; print '
Commercial'; print '
Fournisseur précédent'; print '
Remise LMN %
Note'; print '
 '; print 'Annuler
'."\n"; print '
'."\n"; } /* * Contact * * */ if ($_GET["action"] == 'contact') { print_fiche_titre('Ajouter un contact', $mesg); print "
id\" method=\"post\">\n"; print ''; print ''; $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 = ".$ligne->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 ''; print '"; $i++; } } $db->free(); } else { print $sql; } print ''; print ''; print '
Contact facture '.$i.''.$row[1] . " " . $row[2] . " <".$row[3].">"; print ''; print ''; print img_delete(); print "
Contact'; $sql = "SELECT idp, name, firstname, email FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$ligne->client_facture_id." ORDER BY name "; if ( $db->query( $sql) ) { print ''; } else { print $sql; } print '

Contact auquel est envoyé la facture par email

 '; if ($num > 0) { print ''; } print 'Annuler
'; print '
'; } /* * * * */ print ''; } } else { print "Error"; } } if ( $user->rights->telephonie->ligne_activer && $ligne->statut == 2) { $form = new Form($db); print '
'; print '
'; print ''; print ''; print ''; print '
Activer'; print '
Date'; print $form->select_date(); print '
'; print '
'; print '
'; print ''; print ''; print ''; print ''; print '
Refuser'; print '
Date'; print $form->select_date(); print '
Commentaire
'; print '
'; } if ( $user->rights->telephonie->ligne_activer && ( $ligne->statut == 5 || $ligne->statut == 3)) { /** * Résiliation demandée */ $form = new Form($db); print '
'; print '
'; print ''; print ''; print ''; print ''; print '
Confirmation de la résiliation'; print '
Date'; print $form->select_date(); print '
Commentaire
'; print '
'; print ' 
'; } if ( $user->rights->telephonie->ligne_activer && $ligne->statut == 6) { /** * A commander */ $form = new Form($db); print '
'; print '
'; print ''; print ''; print ''; print ''; print '
Commander la ligne'; print '
Date'; print $form->select_date(); print '
Commentaire
'; print '
'; print ' 
'; } /* ************************************************************************** */ /* */ /* Barre d'action */ /* */ /* ************************************************************************** */ print "\n
\n
\n"; if ($_GET["action"] == '') { if ( $user->rights->telephonie->ligne_activer && $ligne->statut == 3) { print "id\">".$langs->trans("Resilier").""; } if ( $user->rights->telephonie->ligne_activer && $ligne->statut == 4) { print "id\">".$langs->trans("Annuler la demande de résiliation").""; } print "id\">".$langs->trans("Contact").""; print "id\">".$langs->trans("Edit").""; } print "
"; $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>