Ajout patch de la tache 4984 - merci Patrick

This commit is contained in:
Regis Houssin 2005-11-30 17:37:01 +00:00
parent 241ef51968
commit d0721e8567
11 changed files with 854 additions and 6 deletions

View File

@ -551,9 +551,6 @@ if ($_GET['action'] == 'pdf')
facture_pdf_create($db, $_GET['facid']);
}
/*********************************************************************
*
* Fonctions internes
@ -1101,6 +1098,7 @@ else
$author->id = $fac->user_author;
$author->fetch();
/* // modification tache 4984, je laisse en commentaire pour test
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id;
@ -1130,7 +1128,11 @@ else
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Bill').' : '.$fac->ref);
*/
$head = facture_prepare_head($fac);
dolibarr_fiche_head($head, 0, $langs->trans('Bill').' : '.$fac->ref);
/*
* Confirmation de la suppression de la facture

View File

@ -69,6 +69,7 @@ if ($_GET["facid"] > 0)
$author->id = $fac->user_author;
$author->fetch();
/* //modif tache 4984 laissé en commentaire pour test
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id;
@ -96,7 +97,10 @@ if ($_GET["facid"] > 0)
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$fac->id;
$head[$h][1] = $langs->trans("Info");
$h++;
*/
$head = facture_prepare_head($fac);
$hselected = $conf->use_preview_tabs ? 2 : false;
dolibarr_fiche_head($head, $hselected, $langs->trans("Bill")." : $fac->ref");

View File

@ -0,0 +1,438 @@
<?php
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005 Destailleur Laurent <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.
*
* $Id$
* $Source$
*/
/**
\file htdocs/compta/contact.php
\ingroup facture
\brief Onglet de gestion des contacts des factures
\version $Revision$
*/
require ("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
$langs->load("facture");
// $langs->load("orders");
$langs->load("companies");
$user->getrights('facture');
if (!$user->rights->facture->lire)
accessforbidden();
// les methodes locales
/**
* \brief Retourne la liste déroulante des sociétés
* \param selected Societe présélectionnée
* \param htmlname Nom champ formulaire
*/
function select_societes_for_newconcat($facture, $selected = '', $htmlname = 'newcompany')
{
// On recherche les societes
$sql = "SELECT s.idp, s.nom FROM";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
// if ($filter) $sql .= " WHERE $filter";
$sql .= " ORDER BY nom ASC";
$resql = $facture->db->query($sql);
if ($resql)
{
$javaScript = "window.location='./contact.php?facid=".$facture->id."&amp;".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;";
print '<select class="flat" name="'.$htmlname.'" onChange="'.$javaScript.'">';
$num = $facture->db->num_rows($resql);
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $facture->db->fetch_object($resql);
if ($i == 0)
$firstCompany = $obj->idp;
if ($selected > 0 && $selected == $obj->idp)
{
print '<option value="'.$obj->idp.'" selected="true">'.dolibarr_trunc($obj->nom,24).'</option>';
$firstCompany = $obj->idp;
} else
{
print '<option value="'.$obj->idp.'">'.dolibarr_trunc($obj->nom,24).'</option>';
}
$i ++;
}
}
print "</select>\n";
return $firstCompany;
} else
{
dolibarr_print_error($facture->db);
}
}
/**
*
*/
function select_type_contact($facture, $defValue, $htmlname = 'type', $source)
{
$lesTypes = $facture->liste_type_contact($source);
print '<select size="0" name="'.$htmlname.'">';
foreach($lesTypes as $key=>$value)
{
print '<option value="'.$key.'">'.$value.'</option>';
}
print "</select>\n";
}
// Sécurité accés client
if ($user->societe_id > 0)
{
$action = '';
$socidp = $user->societe_id;
}
/*
* Ajout d'un nouveau contact
*/
if ($_POST["action"] == 'addcontact' && $user->rights->facture->creer)
{
$result = 0;
$facture = new Facture($db);
$result = $facture->fetch($_GET["facid"]);
if ($result > 0 && $_GET["facid"] > 0)
{
$result = $facture->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]);
}
if ($result >= 0)
{
Header("Location: contact.php?facid=".$facture->id);
exit;
} else
{
$mesg = '<div class="error">'.$facture->error.'</div>';
}
}
// modification d'un contact. On enregistre le type
if ($_POST["action"] == 'updateligne' && $user->rights->facture->creer)
{
$facture = new Facture($db);
if ($facture->fetch($_GET["facid"]))
{
$contact = $facture->detail_contact($_POST["elrowid"]);
$type = $_POST["type"];
$statut = $contact->statut;
$result = $facture->update_contact($_POST["elrowid"], $statut, $type);
if ($result >= 0)
{
$db->commit();
} else
{
dolibarr_print_error($db, "result=$result");
$db->rollback();
}
} else
{
dolibarr_print_error($db);
}
}
// bascule du statut d'un contact
if ($_GET["action"] == 'swapstatut' && $user->rights->facture->creer)
{
$facture = new Facture($db);
if ($facture->fetch($_GET["facid"]))
{
$contact = $facture->detail_contact($_GET["ligne"]);
$id_type_contact = $contact->fk_c_type_contact;
$statut = ($contact->statut == 4) ? 5 : 4;
$result = $facture->update_contact($_GET["ligne"], $statut, $id_type_contact);
if ($result >= 0)
{
$db->commit();
} else
{
dolibarr_print_error($db, "result=$result");
$db->rollback();
}
} else
{
dolibarr_print_error($db);
}
}
// Efface un contact
if ($_GET["action"] == 'deleteline' && $user->rights->facture->creer)
{
$facture = new Facture($db);
$facture->fetch($_GET["facid"]);
$result = $facture->delete_contact($_GET["lineid"]);
if ($result >= 0)
{
Header("Location: contact.php?facid=".$facture->id);
exit;
}
else {
dolibarr_print_error($db);
}
}
llxHeader('', $langs->trans("Bill"), "Facture");
$html = new Form($db);
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* */
/* *************************************************************************** */
if ( isset($mesg))
print $mesg;
$id = $_GET["facid"];
if ($id > 0)
{
$facture = New Facture($db);
if ( $facture->fetch($_GET['facid'], $user->societe_id) > 0)
{
$soc = new Societe($db, $facture->socidp);
$soc->fetch($facture->socidp);
$head = facture_prepare_head($facture);
dolibarr_fiche_head($head, 1, $langs->trans('Bill').' : '.$facture->ref);
/*
* Facture synthese pour rappel
*/
print '<table class="border" width="100%">';
// Reference du facture
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $facture->ref;
print "</td></tr>";
// Customer
if ( is_null($facture->client) )
$facture->fetch_client();
print "<tr><td>".$langs->trans("Customer")."</td>";
print '<td colspan="3">';
print '<b><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$facture->client->id.'">'.$facture->client->nom.'</a></b></td></tr>';
print "</table>";
print '</div>';
/*
* Lignes de contacts
*/
echo '<br><table class="noborder" width="100%">';
/*
* Ajouter une ligne de contact
* Non affiché en mode modification de ligne
* ou si facture validée.
*/
if ($facture->statut <= 0 && $_GET["action"] != 'editline' && $user->rights->facture->creer)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>';
print '<td>'.$langs->trans("Company").'</td>';
print '<td>'.$langs->trans("Contacts").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td colspan="3">&nbsp;</td>';
print "</tr>\n";
$var = false;
print '<form action="contact.php?facid='.$id.'" method="post">';
print '<input type="hidden" name="action" value="addcontact">';
print '<input type="hidden" name="source" value="internal">';
print '<input type="hidden" name="id" value="'.$id.'">';
// Ligne ajout pour contact interne
print "<tr $bc[$var]>";
print '<td>';
print $langs->trans("Internal");
print '</td>';
print '<td colspan="1">';
print $conf->global->MAIN_INFO_SOCIETE_NOM;
print '</td>';
print '<td colspan="1">';
$html->select_users($user->id,'contactid');
print '</td>';
print '<td>';
select_type_contact($facture, '', 'type','internal');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
print '</form>';
print '<form action="contact.php?facid='.$id.'" method="post">';
print '<input type="hidden" name="action" value="addcontact">';
print '<input type="hidden" name="source" value="external">';
print '<input type="hidden" name="id" value="'.$id.'">';
// Ligne ajout pour contact externe
$var=!$var;
print "<tr $bc[$var]>";
print '<td>';
print $langs->trans("External");
print '</td>';
print '<td colspan="1">';
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$facture->client->id;
$selectedCompany = select_societes_for_newconcat($facture, $selectedCompany, $htmlname = 'newcompany');
print '</td>';
print '<td colspan="1">';
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid');
print '</td>';
print '<td>';
select_type_contact($facture, '', 'type','external');
print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
print "</form>";
}
print '<tr><td colspan="6">&nbsp;</td></tr>';
// Liste des contacts liés
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Source").'</td>';
print '<td>'.$langs->trans("Company").'</td>';
print '<td>'.$langs->trans("Contacts").'</td>';
print '<td>'.$langs->trans("ContactType").'</td>';
print '<td align="center">'.$langs->trans("Status").'</td>';
print '<td colspan="2">&nbsp;</td>';
print "</tr>\n";
$societe = new Societe($db);
$var = true;
foreach(array('internal','external') as $source)
{
$tab = $facture->liste_contact(-1,$source);
$num=sizeof($tab);
$i = 0;
while ($i < $num)
{
$var = !$var;
print '<tr '.$bc[$var].' valign="top">';
// Source
print '<td align="left">';
if ($tab[$i]['source']=='internal') print $langs->trans("Internal");
if ($tab[$i]['source']=='external') print $langs->trans("External");
print '</td>';
// Societe
print '<td align="left">';
if ($tab[$i]['socid'] > 0)
{
print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$tab[$i]['socid'].'">';
print img_object($langs->trans("ShowCompany"),"company").' '.$societe->get_nom($tab[$i]['socid']);
print '</a>';
}
if ($tab[$i]['socid'] < 0)
{
print $conf->global->MAIN_INFO_SOCIETE_NOM;
}
if (! $tab[$i]['socid'])
{
print '&nbsp;';
}
print '</td>';
// Contact
print '<td>';
if ($tab[$i]['source']=='internal')
{
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$tab[$i]['id'].'">';
print img_object($langs->trans("ShowUser"),"user").' '.$tab[$i]['nom'].'</a>';
}
if ($tab[$i]['source']=='external')
{
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$tab[$i]['id'].'">';
print img_object($langs->trans("ShowContact"),"contact").' '.$tab[$i]['nom'].'</a>';
}
print '</td>';
// Type de contact
print '<td>'.$tab[$i]['libelle'].'</td>';
// Statut
print '<td align="center">';
// Activation desativation du contact
if ($facture->statut >= 0)
print '<a href="contact.php?facid='.$facture->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
print img_statut($tab[$i]['status']);
if ($facture->statut >= 0)
print '</a>';
print '</td>';
// Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé)
print '<td align="center" nowrap>';
if ($facture->statut == 0 && $user->rights->facture->creer)
{
print '&nbsp;';
print '<a href="contact.php?facid='.$facture->id.'&amp;action=deleteline&amp;lineid='.$tab[$i]['rowid'].'">';
print img_delete();
print '</a>';
}
print '</td>';
print "</tr>\n";
$i ++;
}
$db->free($result);
}
print "</table>";
}
else
{
// Contrat non trouvé
print "Contrat inexistant ou accés refusé";
}
}
$db->close();
llxFooter('$Date$');
?>

View File

@ -45,6 +45,7 @@ $fac->info($_GET["facid"]);
$soc = new Societe($db, $fac->socidp);
$soc->fetch($fac->socidp);
/* //laissé pour test tache 4984
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id;
@ -73,8 +74,11 @@ $head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$fac->id;
$head[$h][1] = $langs->trans("Info");
$hselected = $h;
$h++;
*/
$head = facture_prepare_head($fac);
$hselected = $conf->use_preview_tabs ?
(($fac->mode_reglement_code == 'PRE') ? 5: 4): 3;
dolibarr_fiche_head($head, $hselected, $langs->trans("Bill")." : $fac->ref");

View File

@ -75,6 +75,7 @@ if ($_GET["facid"])
$soc = new Societe($db, $fac->socidp);
$soc->fetch($fac->socidp);
/* //laissé en commentaire pour test tache 4984
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id;
@ -102,7 +103,11 @@ if ($_GET["facid"])
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$fac->id;
$head[$h][1] = $langs->trans("Info");
$h++;
*/
$head = facture_prepare_head($fac);
$hselected = $conf->use_preview_tabs ?
(($fac->mode_reglement_code == 'PRE') ? 4: 3): 2;
dolibarr_fiche_head($head, $hselected, $langs->trans("Bill")." : $fac->ref");

View File

@ -56,4 +56,44 @@ function llxHeader($head = "", $title="", $help_url='') {
left_menu($menu->liste, $help_url);
}
function facture_prepare_head($fac)
{
global $langs, $conf;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('CardBill');
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('Contact');
$h++;
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/apercu.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('Preview');
$h++;
}
if ($fac->mode_reglement_code == 'PRE')
{
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('StandingOrders');
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('Note');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('Info');
$h++;
return $head;
}
?>

View File

@ -135,4 +135,43 @@ function llxHeader($head = "", $title="", $help_url='')
left_menu($menu->liste, $help_url);
}
function facture_prepare_head($fac)
{
global $langs, $conf;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('CardBill');
$hselected = $h;
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('Contact');
$h++;
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/apercu.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('Preview');
$h++;
}
if ($fac->mode_reglement_code == 'PRE')
{
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('StandingOrders');
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('Note');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$fac->id;
$head[$h][1] = $langs->trans('Info');
$h++;
return $head;
}
?>

View File

@ -92,6 +92,7 @@ class Facture
*/
function create($user)
{
global $langs,$conf;
$this->db->begin();
/* On positionne en mode brouillon la facture */
@ -575,6 +576,8 @@ class Facture
*/
function delete($rowid)
{
global $user,$langs,$conf;
$this->db->begin();
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_tva_sum WHERE fk_facture = '.$rowid;
@ -1760,6 +1763,227 @@ class Facture
}
}
/**
* \brief Ajoute un contact associé une facture
* \param fk_socpeople Id du contact a ajouter.
* \param type_contact Type de contact
* \param source extern=Contact externe (llx_socpeople), intern=Contact interne (llx_user)
* \return int <0 si erreur, >0 si ok
*/
function add_contact($fk_socpeople, $type_contact, $source='extern')
{
dolibarr_syslog("Facture::add_contact $fk_socpeople, $type_contact, $source");
if ($fk_socpeople <= 0) return -1;
// Verifie type_contact
if (! $type_contact || ! is_numeric($type_contact))
{
$this->error="Valeur pour type_contact incorrect";
return -3;
}
$datecreate = time();
// Insertion dans la base
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
$sql.= $this->db->idate($datecreate);
$sql.= ", 4, '". $type_contact . "' ";
$sql.= ");";
// Retour
if ( $this->db->query($sql) )
{
return 1;
}
else
{
// dolibarr_print_error($this->db);
$this->error=$this->db->error()." - $sql";
return -1;
}
}
/**
*
* \brief Mise a jour du contact associé une facture
* \param rowid La reference du lien facture-contact
* \param statut Le nouveau statut
* \param type_contact_id Description du type de contact
* \return int <0 si erreur, >0 si ok
*/
function update_contact($rowid, $statut, $type_contact_id)
{
// Insertion dans la base
$sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set ";
$sql.= " statut = $statut ,";
$sql.= " fk_c_type_contact = '".$type_contact_id ."'";
$sql.= " where rowid = $rowid ;";
// Retour
if ( $this->db->query($sql) )
{
return 0;
}
else
{
dolibarr_print_error($this->db);
return -1;
}
}
/**
* \brief Supprime une ligne de contact de contrat
* \param rowid La reference du contact
* \return statur >0 si ok, <0 si ko
*/
function delete_contact($rowid)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact WHERE rowid =".$rowid;
if ($this->db->query($sql))
{
return 1;
}
else
{
return -1;
}
}
/**
* \brief Récupère les lignes de contact du contrat
* \param statut Statut des lignes detail à récupérer
* \param source Source du contact external (llx_socpeople) ou internal (llx_user)
* \return array Tableau des rowid des contacts
*/
function liste_contact($statut=-1,$source='external')
{
global $langs;
$tab=array();
$sql = "SELECT ec.rowid, ec.statut, ec.fk_socpeople as id,";
if ($source == 'internal') $sql.=" '-1' as socid,";
if ($source == 'external') $sql.=" t.fk_soc as socid,";
if ($source == 'internal') $sql.=" t.name as nom,";
if ($source == 'external') $sql.=" t.name as nom,";
$sql.= "tc.source, tc.element, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact ec,";
if ($source == 'internal') $sql.=" ".MAIN_DB_PREFIX."user t,";
if ($source == 'external') $sql.=" ".MAIN_DB_PREFIX."socpeople t,";
$sql.= " ".MAIN_DB_PREFIX."c_type_contact tc";
$sql.= " WHERE element_id =".$this->id;
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element='facture'";
if ($source == 'internal') $sql.= " AND tc.source = 'internal'";
if ($source == 'external') $sql.= " AND tc.source = 'external'";
$sql.= " AND tc.active=1";
if ($source == 'internal') $sql.= " AND ec.fk_socpeople = t.rowid";
if ($source == 'external') $sql.= " AND ec.fk_socpeople = t.idp";
if ($statut >= 0) $sql.= " AND statut = '$statut'";
$sql.=" ORDER BY t.name ASC";
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
$tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,'nom'=>$obj->nom,
'rowid'=>$obj->rowid,'code'=>$obj->code,'libelle'=>$libelle_type,'status'=>$obj->statut);
$i++;
}
return $tab;
}
else
{
$this->error=$this->db->error();
dolibarr_print_error($this->db);
return -1;
}
}
/**
* \brief Le détail d'un contact
* \param rowid L'identifiant du contact
* \return object L'objet construit par DoliDb.fetch_object
*/
function detail_contact($rowid)
{
$sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,";
$sql.= " tc.code, tc.libelle, s.fk_soc";
$sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc, ";
$sql.= " ".MAIN_DB_PREFIX."socpeople as s";
$sql.= " WHERE ec.rowid =".$rowid;
$sql.= " AND ec.fk_socpeople=s.idp";
$sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.element = 'facture'";
$resql=$this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
return $obj;
}
else
{
$this->error=$this->db->error();
dolibarr_print_error($this->db);
return null;
}
}
/**
* \brief La liste des valeurs possibles de type de contacts
* \param source internal ou external
* \return array La liste des natures
*/
function liste_type_contact($source)
{
global $langs;
$element='facture';
$tab = array();
$sql = "SELECT distinct tc.rowid, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE element='".$element."'";
$sql.= " AND source='".$source."'";
$sql.= " ORDER by tc.code";
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$transkey="TypeContact_".$element."_".$source."_".$obj->code;
$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
$tab[$obj->rowid]=$libelle_type;
$i++;
}
return $tab;
}
else
{
$this->error=$this->db->error();
// dolibarr_print_error($this->db);
return null;
}
}
}
@ -1809,7 +2033,7 @@ class FactureLigne
$this->produit_id = $objp->fk_product;
$this->date_start = $objp->date_start;
$this->date_end = $objp->date_end;
$i++;
// $i++; //modification suite à la tache 4984
$this->db->free($result);
}
else

View File

@ -812,3 +812,7 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (80, 'projet', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (81, 'projet', 'external', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (50, 'facture', 'internal', 'SALESREPFOLL', 'Commercial suivi du paiement', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (60, 'facture', 'external', 'BILLING', 'Contact client facturation', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (61, 'facture', 'external', 'CUSTOMER', 'Contact client livraison/préstation', 1);

View File

@ -1928,6 +1928,10 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (80, 'projet', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (81, 'projet', 'external', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (50, 'facture', 'internal', 'SALESREPFOLL', 'Commercial suivi du paiement', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (60, 'facture', 'external', 'BILLING', 'Contact client facturation', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (61, 'facture', 'external', 'CUSTOMER', 'Contact client livraison/préstation', 1);
alter table llx_commande add ref_client varchar(30) after ref;
alter table llx_facture add ref_client varchar(30) after facnumber;

View File

@ -690,4 +690,88 @@ insert into llx_c_currencies ( code, code_iso, active, label ) values ( 'IN', 'I
insert into llx_c_currencies ( code, code_iso, active, label ) values ( 'LT', 'LTL', 1, 'Litas');
insert into llx_c_currencies ( code, code_iso, active, label ) values ( 'RU', 'SUR', 1, 'Rouble');
insert into llx_c_currencies ( code, code_iso, active, label ) values ( 'FH', 'HUF', 1, 'Forint hongrois');
insert into llx_c_currencies ( code, code_iso, active, label ) values ( 'LK', 'LKR', 1, 'Roupie sri lanka');
insert into llx_c_currencies ( code, code_iso, active, label ) values ( 'LK', 'LKR', 1, 'Roupie sri lanka');
--
-- Taux TVA
-- Source des taux: http://fr.wikipedia.org/wiki/Taxe_sur_la_valeur_ajout%C3%A9e
--
delete from llx_c_tva;
-- ALLEMAGNE (id 5)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 51, 5, '16','0','VAT Rate 16',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 52, 5, '7','0','VAT Rate 7',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 53, 5, '0','0','VAT Rate 0',1);
-- BELGIQUE (id 2)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 21, 2, '21','0','VAT Rate 21',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 22, 2, '6','0','VAT Rate 6',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 23, 2, '0','0','VAT Rate 0 ou non applicable',1);
-- CANADA (id 14)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (141,14, '7','0','VAT Rate 7',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (142,14, '0','0','VAT Rate 0',1);
-- ESPAGNE (id 4)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 41, 4, '16','0','VAT Rate 16',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 42, 4, '7','0','VAT Rate 7',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 43, 4, '4','0','VAT Rate 4',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 44, 4, '0','0','VAT Rate 0',1);
-- ITALY (id 3)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 31, 3, '20','0','VAT Rate 20',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 32, 3, '10','0','VAT Rate 10',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 33, 3, '4','0','VAT Rate 4',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 34, 3, '0','0','VAT Rate 0',1);
-- FRANCE (id 1)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 11, 1,'19.6','0','VAT Rate 19.6 (France hors DOM-TOM)',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 12, 1, '8.5','0','VAT Rate 8.5 (DOM sauf Guyane et Saint-Martin)',0);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 13, 1, '8.5','1','VAT Rate 8.5 (DOM sauf Guyane et Saint-Martin), non perçu par le vendeur mais récupérable par l\'acheteur',0);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 14, 1, '5.5','0','VAT Rate 5.5 (France hors DOM-TOM)',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 15, 1, '0','0','VAT Rate 0 ou non applicable (France, TOM)',1);
-- PAYS-BAS (id 17)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (171,17, '19','0','VAT Rate 19',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (172,17, '6','0','VAT Rate 6',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (173,17, '0','0','VAT Rate 0',1);
-- PORTUGAL (id 26)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (261,26, '17','0','VAT Rate 17',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (262,26, '12','0','VAT Rate 12',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (263,26, '0','0','VAT Rate 0',1);
-- ROYAUME UNI (id 7)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 71, 7,'17.5','0','VAT Rate 17.5',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 72, 7, '5','0','VAT Rate 5',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 73, 7, '0','0','VAT Rate 0',1);
-- SUISSE (id 6)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 61, 6, '7.6','0','VAT Rate 7.6',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 62, 6, '3.6','0','VAT Rate 3.6',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 63, 6, '2.4','0','VAT Rate 2.4',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 64, 6, '0','0','VAT Rate 0',1);
--
-- Les types de contact d'un element
--
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (10, 'contrat', 'internal', 'SALESREPSIGN', 'Commercial signataire du contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (11, 'contrat', 'internal', 'SALESREPFOLL', 'Commercial suivi du contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (20, 'contrat', 'external', 'BILLING', 'Contact client facturation contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (21, 'contrat', 'external', 'CUSTOMER', 'Contact client suivi contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (22, 'contrat', 'external', 'SALESREPSIGN', 'Contact client signataire contrat', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (30, 'propal', 'internal', 'SALESREPSIGN', 'Commercial signataire de la propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (31, 'propal', 'internal', 'SALESREPFOLL', 'Commercial suivi de la propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (40, 'propal', 'external', 'BILLING', 'Contact client facturation propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (41, 'propal', 'external', 'CUSTOMER', 'Contact client suivi propale', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (80, 'projet', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (81, 'projet', 'external', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (50, 'facture', 'internal', 'SALESREPFOLL', 'Commercial suivi du paiement', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (60, 'facture', 'external', 'BILLING', 'Contact client facturation', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (61, 'facture', 'external', 'CUSTOMER', 'Contact client livraison/préstation', 1);