Uniformize code and make fix on predefined invoice feature.
This commit is contained in:
parent
04ca16df2b
commit
930b400458
@ -1252,7 +1252,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$sql.= ' '.$db->pdate('pt.date_start').' as date_start,';
|
||||
$sql.= ' '.$db->pdate('pt.date_end').' as date_end,';
|
||||
$sql.= ' pt.product_type,';
|
||||
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||
$sql.= ' p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
|
||||
@ -1308,9 +1308,9 @@ if ($id > 0 || ! empty($ref))
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product;
|
||||
$product_static->libelle=$objp->product_label;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product;
|
||||
$text.= ' - '.$objp->product_label;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
@ -1320,7 +1320,7 @@ if ($id > 0 || ! empty($ref))
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||
{
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
@ -1513,7 +1513,7 @@ if ($id > 0 || ! empty($ref))
|
||||
if ($objp->fk_product_type==1) print img_object($langs->trans('ShowService'),'service');
|
||||
else print img_object($langs->trans('ShowProduct'),'product');
|
||||
print ' '.$objp->ref.'</a>';
|
||||
print ' - '.nl2br($objp->product);
|
||||
print ' - '.nl2br($objp->product_label);
|
||||
print '<br>';
|
||||
}
|
||||
if ($_GET["action"] == 'editline')
|
||||
|
||||
@ -1500,7 +1500,7 @@ else
|
||||
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
|
||||
$sql.= ' '.$db->pdate('l.date_start').' as date_start,';
|
||||
$sql.= ' '.$db->pdate('l.date_end').' as date_end,';
|
||||
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid, ';
|
||||
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, ';
|
||||
$sql.= ' p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
|
||||
@ -1552,9 +1552,9 @@ else
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product;
|
||||
$product_static->libelle=$objp->product_label;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product;
|
||||
$text.= ' - '.$objp->product_label;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
@ -1564,7 +1564,7 @@ else
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||
{
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
@ -1688,9 +1688,9 @@ else
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product;
|
||||
$product_static->libelle=$objp->product_label;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product;
|
||||
$text.= ' - '.$objp->product_label;
|
||||
print $text;
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -778,6 +778,7 @@ class CommonObject
|
||||
// Now update field total_ht, total_ttc and tva
|
||||
$fieldht='total_ht';
|
||||
if ($this->element == 'facture') $fieldht='total';
|
||||
if ($this->element == 'facturerec') $fieldht='total';
|
||||
$fieldtva='tva';
|
||||
if ($this->element == 'facture_fourn') $fieldtva='total_tva';
|
||||
$fieldttc='total_ttc';
|
||||
|
||||
@ -359,7 +359,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
|
||||
$sql.= ' '.$db->pdate('l.date_start').' as date_start,';
|
||||
$sql.= ' '.$db->pdate('l.date_end').' as date_end,';
|
||||
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||
$sql.= ' p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX."commandedet as l";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
|
||||
@ -410,9 +410,9 @@ if ($id > 0 || ! empty($ref))
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product;
|
||||
$product_static->libelle=$objp->product_label;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product;
|
||||
$text.= ' - '.$objp->product_label;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
@ -422,7 +422,7 @@ if ($id > 0 || ! empty($ref))
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||
{
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
|
||||
@ -2711,7 +2711,7 @@ else
|
||||
$sql.= ' '.$db->pdate('l.date_start').' as date_start,';
|
||||
$sql.= ' '.$db->pdate('l.date_end').' as date_end,';
|
||||
$sql.= ' l.product_type,';
|
||||
$sql.= ' p.ref, p.fk_product_type, p.label as product,';
|
||||
$sql.= ' p.ref as product_ref, p.fk_product_type, p.label as product_label,';
|
||||
$sql.= ' p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON l.fk_product=p.rowid';
|
||||
@ -2753,7 +2753,7 @@ else
|
||||
if (! empty($objp->date_start)) $type=1;
|
||||
if (! empty($objp->date_end)) $type=1;
|
||||
|
||||
// Ligne en mode visu
|
||||
// Show line
|
||||
if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
|
||||
{
|
||||
print '<tr '.$bc[$var].'>';
|
||||
@ -2765,10 +2765,10 @@ else
|
||||
// Show product and description
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product;
|
||||
$product_static->ref=$objp->product_ref;
|
||||
$product_static->libelle=$objp->product_label;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product;
|
||||
$text.= ' - '.$objp->product_label;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
@ -2776,7 +2776,7 @@ else
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
@ -2906,10 +2906,10 @@ else
|
||||
print '<input type="hidden" name="productid" value="'.$objp->fk_product.'">';
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product;
|
||||
$product_static->ref=$objp->product_ref;
|
||||
$product_static->libelle=$objp->product_label;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product;
|
||||
$text.= ' - '.$objp->product_label;
|
||||
print $text;
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2009 Laurent Destailleur <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
|
||||
@ -18,11 +18,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/facture/facture-rec.class.php
|
||||
\ingroup facture
|
||||
\brief Fichier de la classe des factures recurentes
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/compta/facture/facture-rec.class.php
|
||||
* \ingroup facture
|
||||
* \brief Fichier de la classe des factures recurentes
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/notify.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||
@ -30,9 +30,9 @@ require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
|
||||
|
||||
|
||||
/**
|
||||
\class FactureRec
|
||||
\brief Classe de gestion des factures recurrentes/Modèles
|
||||
*/
|
||||
* \class FactureRec
|
||||
* \brief Classe de gestion des factures recurrentes/Mod<EFBFBD>les
|
||||
*/
|
||||
class FactureRec extends Facture
|
||||
{
|
||||
var $db ;
|
||||
@ -44,47 +44,46 @@ class FactureRec extends Facture
|
||||
var $id ;
|
||||
|
||||
var $socid; // Id client
|
||||
var $client; // Objet societe client (à charger par fetch_client)
|
||||
var $client; // Objet societe client (<EFBFBD> charger par fetch_client)
|
||||
|
||||
var $number;
|
||||
var $author;
|
||||
var $date;
|
||||
var $ref;
|
||||
var $amount;
|
||||
var $remise;
|
||||
var $tva;
|
||||
var $total;
|
||||
var $note;
|
||||
var $db_table;
|
||||
var $propalid;
|
||||
var $projetid;
|
||||
var $number;
|
||||
var $author;
|
||||
var $date;
|
||||
var $ref;
|
||||
var $amount;
|
||||
var $remise;
|
||||
var $tva;
|
||||
var $total;
|
||||
var $note;
|
||||
var $db_table;
|
||||
var $propalid;
|
||||
var $projetid;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialisation de la class
|
||||
*
|
||||
*/
|
||||
function FactureRec($DB, $facid=0)
|
||||
{
|
||||
$this->db = $DB ;
|
||||
$this->facid = $facid;
|
||||
}
|
||||
/**
|
||||
* \brief Initialisation de la class
|
||||
*/
|
||||
function FactureRec($DB, $facid=0)
|
||||
{
|
||||
$this->db = $DB ;
|
||||
$this->facid = $facid;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Créé la facture recurrente/modele
|
||||
* \return int <0 si ko, id facture rec crée si ok
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $langs;
|
||||
/**
|
||||
* \brief Create a predefined invoice
|
||||
* \return int <0 if KO, id of invoice if OK
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$error=0;
|
||||
$error=0;
|
||||
|
||||
// Nettoyage parametere
|
||||
// Clean parameters
|
||||
$this->titre=trim($this->titre);
|
||||
|
||||
// Validation parameteres
|
||||
if (! $this->titre)
|
||||
// Validate parameters
|
||||
if (empty($this->titre))
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Title"));
|
||||
return -3;
|
||||
@ -92,73 +91,76 @@ class FactureRec extends Facture
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Charge facture modele
|
||||
$facsrc=new Facture($this->db);
|
||||
$result=$facsrc->fetch($this->facid);
|
||||
if ($result > 0)
|
||||
{
|
||||
// On positionne en mode brouillon la facture
|
||||
$this->brouillon = 1;
|
||||
// Charge facture modele
|
||||
$facsrc=new Facture($this->db);
|
||||
$result=$facsrc->fetch($this->facid);
|
||||
if ($result > 0)
|
||||
{
|
||||
// On positionne en mode brouillon la facture
|
||||
$this->brouillon = 1;
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (titre, fk_soc, datec, amount, remise, note, fk_user_author,fk_projet, fk_cond_reglement, fk_mode_reglement) ";
|
||||
$sql.= " VALUES ('$this->titre', '$facsrc->socid', ".$this->db->idate(mktime()).", '$facsrc->amount', '$facsrc->remise', '".addslashes($this->note)."','$user->id',";
|
||||
$sql.= " ".($facsrc->projetid?"'".$facsrc->projetid."'":"null").", ";
|
||||
$sql.= " '".$facsrc->cond_reglement_id."',";
|
||||
$sql.= " '".$facsrc->mode_reglement_id."')";
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec");
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_rec (titre, fk_soc, datec, amount, remise, note, fk_user_author,fk_projet, fk_cond_reglement, fk_mode_reglement) ";
|
||||
$sql.= " VALUES ('$this->titre', '$facsrc->socid', ".$this->db->idate(mktime()).", '$facsrc->amount', '$facsrc->remise', '".addslashes($this->note)."','$user->id',";
|
||||
$sql.= " ".($facsrc->projetid?"'".$facsrc->projetid."'":"null").", ";
|
||||
$sql.= " '".$facsrc->cond_reglement_id."',";
|
||||
$sql.= " '".$facsrc->mode_reglement_id."')";
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."facture_rec");
|
||||
|
||||
/*
|
||||
* Produits
|
||||
*/
|
||||
for ($i = 0 ; $i < sizeof($facsrc->lignes) ; $i++)
|
||||
{
|
||||
$result_insert = $this->addline($this->id,
|
||||
$facsrc->lignes[$i]->desc,
|
||||
$facsrc->lignes[$i]->subprice,
|
||||
$facsrc->lignes[$i]->qty,
|
||||
$facsrc->lignes[$i]->tva_tx,
|
||||
$facsrc->lignes[$i]->fk_product,
|
||||
$facsrc->lignes[$i]->remise_percent);
|
||||
/*
|
||||
* Lines
|
||||
*/
|
||||
for ($i = 0 ; $i < sizeof($facsrc->lignes) ; $i++)
|
||||
{
|
||||
$result_insert = $this->addline($this->id,
|
||||
$facsrc->lignes[$i]->desc,
|
||||
$facsrc->lignes[$i]->subprice,
|
||||
$facsrc->lignes[$i]->qty,
|
||||
$facsrc->lignes[$i]->tva_tx,
|
||||
$facsrc->lignes[$i]->fk_product,
|
||||
$facsrc->lignes[$i]->remise_percent,
|
||||
'HT',0,'',0,
|
||||
$facsrc->lignes[$i]->product_type
|
||||
);
|
||||
|
||||
if ($result_insert < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
if ($result_insert < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($error)
|
||||
{
|
||||
if ($error)
|
||||
{
|
||||
$this->db->rollback();
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error().' sql='.$sql;
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error().' sql='.$sql;
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Recupére l'objet facture et ses lignes de factures
|
||||
\param rowid id de la facture a récupérer
|
||||
\param societe_id id de societe
|
||||
\return int >0 si ok, <0 si ko
|
||||
*/
|
||||
* \brief Recupere l'objet facture et ses lignes de factures
|
||||
* \param rowid id de la facture a recuperer
|
||||
* \param societe_id id de societe
|
||||
* \return int >0 si ok, <0 si ko
|
||||
*/
|
||||
function fetch($rowid, $societe_id=0)
|
||||
{
|
||||
dol_syslog("Facture::Fetch rowid=".$rowid.", societe_id=".$societe_id, LOG_DEBUG);
|
||||
@ -242,8 +244,8 @@ class FactureRec extends Facture
|
||||
if ($this->statut == 0) $this->brouillon = 1;
|
||||
|
||||
/*
|
||||
* Lignes
|
||||
*/
|
||||
* Lines
|
||||
*/
|
||||
$result=$this->fetch_lines();
|
||||
if ($result < 0)
|
||||
{
|
||||
@ -270,15 +272,15 @@ class FactureRec extends Facture
|
||||
|
||||
|
||||
/**
|
||||
\brief Recupére les lignes de factures dans this->lignes
|
||||
\return int 1 si ok, < 0 si erreur
|
||||
*/
|
||||
* \brief Recupere les lignes de factures predefinies dans this->lignes
|
||||
* \return int 1 if OK, < 0 if KO
|
||||
*/
|
||||
function fetch_lines()
|
||||
{
|
||||
$sql = 'SELECT l.rowid, l.fk_product, l.description, l.price, l.qty, l.tva_taux, ';
|
||||
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_taux, ';
|
||||
$sql.= ' l.remise, l.remise_percent, l.subprice,';
|
||||
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
|
||||
$sql.= ' p.label as label, p.description as product_desc';
|
||||
$sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as label, p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
$sql.= ' WHERE l.fk_facture = '.$this->id;
|
||||
@ -294,9 +296,12 @@ class FactureRec extends Facture
|
||||
$objp = $this->db->fetch_object($result);
|
||||
$faclig = new FactureLigne($this->db);
|
||||
$faclig->rowid = $objp->rowid;
|
||||
$faclig->desc = $objp->description; // Description ligne
|
||||
$faclig->libelle = $objp->label; // Label produit
|
||||
$faclig->product_desc = $objp->product_desc; // Description produit
|
||||
$faclig->desc = $objp->description; // Description line
|
||||
$faclig->product_type = $objp->product_type; // Type of line
|
||||
$faclig->product_ref = $objp->product_ref; // Ref product
|
||||
$faclig->libelle = $objp->label; // Label product
|
||||
$faclig->product_desc = $objp->product_desc; // Description product
|
||||
$faclig->fk_product_type = $objp->fk_product_type; // Type of product
|
||||
$faclig->qty = $objp->qty;
|
||||
$faclig->subprice = $objp->subprice;
|
||||
$faclig->tva_tx = $objp->tva_taux;
|
||||
@ -334,51 +339,66 @@ class FactureRec extends Facture
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Supprime la facture
|
||||
*/
|
||||
function delete($rowid)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = $rowid;";
|
||||
/**
|
||||
* Supprime la facture
|
||||
*/
|
||||
function delete($rowid)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = $rowid;";
|
||||
|
||||
if ($this->db->query( $sql) )
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = $rowid";
|
||||
if ($this->db->query( $sql) )
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facture_rec WHERE rowid = $rowid";
|
||||
|
||||
if ($this->db->query( $sql) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Err : ".$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Err : ".$this->db->error();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
if ($this->db->query( $sql) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Err : ".$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Err : ".$this->db->error();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Ajoute une ligne de facture
|
||||
* \brief Add a line to invoice
|
||||
*/
|
||||
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0)
|
||||
function addline($facid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0)
|
||||
{
|
||||
dol_syslog("FactureRec::Addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
|
||||
// Check parameters
|
||||
if ($type < 0) return -1;
|
||||
|
||||
if ($this->brouillon)
|
||||
{
|
||||
if (strlen(trim($qty))==0)
|
||||
// Clean parameters
|
||||
$remise_percent=price2num($remise_percent);
|
||||
$qty=price2num($qty);
|
||||
if (! $qty) $qty=1;
|
||||
if (! $ventil) $ventil=0;
|
||||
if (! $info_bits) $info_bits=0;
|
||||
$pu_ht=price2num($pu_ht);
|
||||
$pu_ttc=price2num($pu_ttc);
|
||||
$txtva=price2num($txtva);
|
||||
|
||||
if ($price_base_type=='HT')
|
||||
{
|
||||
$qty=1;
|
||||
$pu=$pu_ht;
|
||||
}
|
||||
else
|
||||
{
|
||||
$pu=$pu_ttc;
|
||||
}
|
||||
$remise = 0;
|
||||
$price = $pu;
|
||||
$subprice = $price;
|
||||
|
||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
||||
// qty, pu, remise_percent et txtva
|
||||
@ -389,26 +409,37 @@ class FactureRec extends Facture
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
|
||||
// \TODO A virer
|
||||
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
|
||||
if (trim(strlen($remise_percent)) > 0)
|
||||
{
|
||||
$remise = round(($pu * $remise_percent / 100), 2);
|
||||
$price = $pu - $remise;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet_rec (fk_facture,description,price,qty,tva_taux, fk_product, remise_percent, subprice, remise, total_ht, total_tva, total_ttc)";
|
||||
$product_type=$type;
|
||||
if ($fk_product)
|
||||
{
|
||||
$product=new Product($this->db);
|
||||
$result=$product->fetch($fk_product);
|
||||
$product_type=$product->type;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facturedet_rec (fk_facture,description,price,qty,tva_taux, fk_product, product_type, remise_percent, subprice, remise, total_ht, total_tva, total_ttc)";
|
||||
$sql .= " VALUES ('".$facid."', '".addslashes($desc)."'";
|
||||
$sql .= ",".price2num($price);
|
||||
$sql .= ",".price2num($qty);
|
||||
$sql .= ",".price2num($txtva);
|
||||
$sql .= ",".($fk_product?"'".$fk_product."'":"null");
|
||||
$sql .= ",".$product_type;
|
||||
$sql .= ",'".price2num($remise_percent)."'";
|
||||
$sql .= ",'".price2num($subprice)."'";
|
||||
$sql .= ",'".price2num($pu_ht)."'";
|
||||
$sql .= ",'".price2num($remise)."'";
|
||||
$sql .= ",'".price2num($total_ht)."'";
|
||||
$sql .= ",'".price2num($total_tva)."'";
|
||||
$sql .= ",'".price2num($total_ttc)."') ;";
|
||||
|
||||
dol_syslog("Facture-rec::addline sql=".$sql, LOG_DEBUG);
|
||||
dol_syslog("FactureRec::addline sql=".$sql, LOG_DEBUG);
|
||||
if ($this->db->query( $sql))
|
||||
{
|
||||
$this->id=$facid; // \TODO A virer
|
||||
@ -418,7 +449,7 @@ class FactureRec extends Facture
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
dol_syslog("Facture-rec::addline sql=".$this->error, LOG_ERR);
|
||||
dol_syslog("FactureRec::addline sql=".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
/**
|
||||
* \file htdocs/compta/facture/fiche-rec.php
|
||||
* \ingroup facture
|
||||
* \brief Page d'affichage d'une facture récurrent
|
||||
* \brief Page d'affichage d'une facture r<EFBFBD>current
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
@ -62,6 +62,7 @@ if ($_POST["action"] == 'add')
|
||||
{
|
||||
$facturerec = new FactureRec($db, $facid);
|
||||
$facturerec->titre = $_POST["titre"];
|
||||
$facturerec->note = $_POST["comment"];
|
||||
|
||||
if ($facturerec->create($user) > 0)
|
||||
{
|
||||
@ -106,6 +107,7 @@ if ($_GET["action"] == 'create')
|
||||
if ($mesg) print $mesg.'<br>';
|
||||
|
||||
$facture = new Facture($db);
|
||||
$product_static=new Product($db);
|
||||
|
||||
if ($facture->fetch($_GET["facid"]) > 0)
|
||||
{
|
||||
@ -118,32 +120,42 @@ if ($_GET["action"] == 'create')
|
||||
|
||||
$facture->fetch_client();
|
||||
|
||||
print '<tr><td>'.$langs->trans("Customer").' :</td><td>'.$facture->client->nom.'</td>';
|
||||
print '<td>'.$langs->trans("Comment").'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Customer").'</td><td>'.$facture->client->getNomUrl(1).'</td>';
|
||||
print '<td>';
|
||||
//print $langs->trans("NotePrivate");
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Title").' :</td><td><input class="flat" type="text" name="titre" size="16"></td>';
|
||||
print '<tr><td>'.$langs->trans("Title").'</td><td>';
|
||||
print '<input class="flat" type="text" name="titre" size="16" value="'.$_POST["titre"].'">';
|
||||
print '</td>';
|
||||
|
||||
print '<td rowspan="4" valign="top">';
|
||||
print '<textarea class="flat" name="note" wrap="soft" cols="60" rows="'.ROWS_4.'"></textarea></td></tr>';
|
||||
print '<textarea class="flat" name="note" wrap="soft" cols="60" rows="'.ROWS_4.'"></textarea>';
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr><td>".$langs->trans("Author")." :</td><td>".$user->fullname."</td></tr>";
|
||||
print "<tr><td>".$langs->trans("Author")."</td><td>".$user->fullname."</td></tr>";
|
||||
|
||||
print "<tr><td>".$langs->trans("PaymentConditions")." :</td><td>";
|
||||
print "<tr><td>".$langs->trans("PaymentConditions")."</td><td>";
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$facture->id,$facture->cond_reglement_id,'none');
|
||||
print "</td></tr>";
|
||||
|
||||
print "<tr><td>".$langs->trans("PaymentMode")." :</td><td>";
|
||||
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
|
||||
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$facture->id,$facture->mode_reglement_id,'none');
|
||||
print "</td></tr>";
|
||||
|
||||
print "<tr><td>".$langs->trans("Project")." :</td><td>";
|
||||
if ($facture->projetid > 0)
|
||||
if ($conf->projet->enabled)
|
||||
{
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($facture->projetid);
|
||||
print $proj->title;
|
||||
print "<tr><td>".$langs->trans("Project")."</td><td>";
|
||||
if ($facture->projetid > 0)
|
||||
{
|
||||
$proj = new Project($db);
|
||||
$proj->fetch($facture->projetid);
|
||||
print $proj->title;
|
||||
}
|
||||
print "</td></tr>";
|
||||
}
|
||||
print "</td></tr></table>";
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
|
||||
@ -155,14 +167,22 @@ if ($_GET["action"] == 'create')
|
||||
}
|
||||
|
||||
/*
|
||||
* Lignes de factures
|
||||
*
|
||||
* Lines de factures
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr><td colspan="3">';
|
||||
|
||||
$sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux, l.remise_percent, l.subprice";
|
||||
$sql = 'SELECT l.fk_product, l.product_type, l.description, l.qty, l.rowid, l.tva_taux,';
|
||||
$sql.= ' l.fk_remise_except,';
|
||||
$sql.= ' l.remise_percent, l.subprice, l.info_bits,';
|
||||
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
|
||||
$sql.= ' '.$db->pdate('l.date_start').' as date_start,';
|
||||
$sql.= ' '.$db->pdate('l.date_end').' as date_end,';
|
||||
$sql.= ' l.product_type,';
|
||||
$sql.= ' p.ref, p.fk_product_type, p.label as product,';
|
||||
$sql.= ' p.description as product_desc';
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet as l";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid";
|
||||
$sql.= " WHERE l.fk_facture = ".$facture->id;
|
||||
$sql.= " ORDER BY l.rowid";
|
||||
|
||||
@ -196,15 +216,51 @@ if ($_GET["action"] == 'create')
|
||||
}
|
||||
|
||||
$var=!$var;
|
||||
print "<TR $bc[$var]>";
|
||||
print "<tr $bc[$var]>";
|
||||
|
||||
// Show product and description
|
||||
$type=$objp->product_type?$objp->product_type:$objp->fk_product_type;
|
||||
|
||||
if ($objp->fk_product)
|
||||
{
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'.stripslashes(nl2br($objp->description)).'</a></td>';
|
||||
print '<td>';
|
||||
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
|
||||
// Show product and description
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product_label;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product_label;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
// Show range
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td>".nl2br($objp->description)."</TD>\n";
|
||||
print '<td>';
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
|
||||
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
print $text.' '.nl2br($objp->description);
|
||||
|
||||
// Show range
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
|
||||
print "</td>\n";
|
||||
}
|
||||
|
||||
|
||||
print '<TD align="center">'.$objp->tva_taux.' %</TD>';
|
||||
print '<TD align="center">'.$objp->qty.'</TD>';
|
||||
if ($objp->remise_percent > 0)
|
||||
@ -298,8 +354,7 @@ else
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans("Customer").'</td>';
|
||||
print "<td colspan=\"3\">";
|
||||
print '<b><a href="../fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></b></td>';
|
||||
print '<td colspan="3">'.$soc->getNomUrl(1).'</td>';
|
||||
|
||||
print "<td>". $langs->trans("PaymentConditions") ." : ";
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$fac->id,$fac->cond_reglement_id,'none');
|
||||
@ -334,15 +389,19 @@ else
|
||||
}
|
||||
|
||||
print "</table><br>";
|
||||
|
||||
/*
|
||||
* Lignes
|
||||
*
|
||||
* Lines
|
||||
*/
|
||||
print_titre($langs->trans("Products"));
|
||||
if ($conf->service->enabled) {
|
||||
print_titre($langs->trans("ProductsAndServices"));
|
||||
} else {
|
||||
print_titre($langs->trans("Products"));
|
||||
}
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="2">'.$langs->trans("Description").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Price").'</td>';
|
||||
print '<td align="center">'.$langs->trans("ReductionShort").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Qty").'</td></tr>';
|
||||
@ -353,23 +412,55 @@ else
|
||||
while ($i < $num)
|
||||
{
|
||||
$var=!$var;
|
||||
if ($fac->lignes[$i]->produit_id > 0)
|
||||
|
||||
$product_static=new Product($db);
|
||||
|
||||
// Show product and description
|
||||
$type=$fac->lignes[$i]->product_type?$fac->lignes[$i]->product_type:$fac->lignes[$i]->fk_product_type;
|
||||
// Try to enhance type detection using date_start and date_end for free lines when type
|
||||
// was not saved.
|
||||
if (! empty($objp->date_start)) $type=1;
|
||||
if (! empty($objp->date_end)) $type=1;
|
||||
|
||||
// Show line
|
||||
print "<tr $bc[$var]>";
|
||||
if ($fac->lignes[$i]->fk_product > 0)
|
||||
{
|
||||
$prod = New Product($db);
|
||||
$prod->fetch($fac->lignes[$i]->produit_id);
|
||||
print "<tr $bc[$var]><td>";
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$prod->id.'">';
|
||||
print img_object($langs->trans("ShowProduct"),"product").' '.$prod->ref;
|
||||
print '</a>';
|
||||
print '<td>';
|
||||
print '<a name="'.$fac->lignes[$i]->id.'"></a>'; // ancre pour retourner sur la ligne
|
||||
|
||||
// Show product and description
|
||||
$product_static->type=$fac->lignes[$i]->fk_product_type;
|
||||
$product_static->id=$fac->lignes[$i]->fk_product;
|
||||
$product_static->ref=$fac->lignes[$i]->product_ref;
|
||||
$product_static->libelle=$fac->lignes[$i]->libelle;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$fac->lignes[$i]->libelle;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($fac->lignes[$i]->desc));
|
||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
// Show range
|
||||
print_date_range($fac->lignes[$i]->date_start,$fac->lignes[$i]->date_end);
|
||||
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($fac->lignes[$i]->desc && $fac->lignes[$i]->desc!=$fac->lignes[$i]->libelle)?'<br>'.dol_htmlentitiesbr($fac->lignes[$i]->desc):'';
|
||||
|
||||
print '</td>';
|
||||
print '<td>'.$fac->lignes[$i]->desc.'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr $bc[$var]><td> </td>";
|
||||
print '<td>'.$fac->lignes[$i]->desc.'</td>';
|
||||
print '<td>';
|
||||
|
||||
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
print $text.' '.nl2br($fac->lignes[$i]->desc);
|
||||
|
||||
// Show range
|
||||
print_date_range($fac->lignes[$i]->date_start,$fac->lignes[$i]->date_end);
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
print "<td align=\"right\">".price($fac->lignes[$i]->price)."</TD>";
|
||||
print "<td align=\"right\">".price($fac->lignes[$i]->price)."</td>";
|
||||
print '<td align="center">'.$fac->lignes[$i]->remise_percent.' %</td>';
|
||||
print "<td align=\"center\">".$fac->lignes[$i]->qty."</td></tr>\n";
|
||||
$i++;
|
||||
@ -456,7 +547,7 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center"><a href="facture.php?filtre=paye:0,fk_statut:1">impayée</a></td>';
|
||||
print '<td align="center"><a href="facture.php?filtre=paye:0,fk_statut:1">impay<EFBFBD>e</a></td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -319,7 +319,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.fk_remise_except,';
|
||||
$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
|
||||
$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc,';
|
||||
$sql.= ' p.rowid as prodid, p.label as product, p.ref, p.fk_product_type, ';
|
||||
$sql.= ' p.rowid as prodid, p.label as product_label, p.ref, p.fk_product_type, ';
|
||||
$sql.= ' p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
|
||||
@ -371,9 +371,9 @@ if ($id > 0 || ! empty($ref))
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product;
|
||||
$product_static->libelle=$objp->product_label;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product;
|
||||
$text.= ' - '.$objp->product_label;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
@ -383,7 +383,7 @@ if ($id > 0 || ! empty($ref))
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||
{
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$sql.= " cd.qty,";
|
||||
$sql.= ' '.$db->pdate('cd.date_start').' as date_start,';
|
||||
$sql.= ' '.$db->pdate('cd.date_end').' as date_end,';
|
||||
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||
$sql.= ' p.description as product_desc';
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
||||
@ -437,9 +437,9 @@ if ($id > 0 || ! empty($ref))
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product;
|
||||
$product_static->libelle=$objp->product_label;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product;
|
||||
$text.= ' - '.$objp->product_label;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
@ -449,7 +449,7 @@ if ($id > 0 || ! empty($ref))
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||
{
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
print ($objp->description && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
}
|
||||
|
||||
print '</td>';
|
||||
|
||||
@ -154,7 +154,7 @@ class Facture extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Facture récurrente
|
||||
// Create invoice from a predefined invoice
|
||||
if ($this->fac_rec > 0)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT.'/compta/facture/facture-rec.class.php');
|
||||
@ -171,7 +171,7 @@ class Facture extends CommonObject
|
||||
$this->remise_percent = $_facrec->remise_percent;
|
||||
$this->remise = $_facrec->remise;
|
||||
|
||||
// Nettoyage parametres
|
||||
// Clean parametres
|
||||
if (! $this->type) $this->type = 0;
|
||||
$this->ref_client=trim($this->ref_client);
|
||||
$this->note=trim($this->note);
|
||||
@ -297,7 +297,10 @@ class Facture extends CommonObject
|
||||
$_facrec->lignes[$i]->qty,
|
||||
$tva_tx,
|
||||
$_facrec->lignes[$i]->produit_id,
|
||||
$_facrec->lignes[$i]->remise_percent);
|
||||
$_facrec->lignes[$i]->remise_percent,
|
||||
'','',0,0,'','HT',
|
||||
$_facref->lignes[$i]->product_type
|
||||
);
|
||||
|
||||
if ( $result_insert < 0)
|
||||
{
|
||||
@ -595,7 +598,7 @@ class Facture extends CommonObject
|
||||
if ($this->statut == 0) $this->brouillon = 1;
|
||||
|
||||
/*
|
||||
* Lignes
|
||||
* Lines
|
||||
*/
|
||||
$result=$this->fetch_lines();
|
||||
if ($result < 0)
|
||||
@ -623,8 +626,8 @@ class Facture extends CommonObject
|
||||
|
||||
|
||||
/**
|
||||
* \brief Recupére les lignes de factures dans this->lignes
|
||||
* \return int 1 si ok, < 0 si erreur
|
||||
* \brief Recupere les lignes de factures dans this->lignes
|
||||
* \return int 1 if OK, < 0 if KO
|
||||
*/
|
||||
function fetch_lines()
|
||||
{
|
||||
@ -632,7 +635,7 @@ class Facture extends CommonObject
|
||||
$sql.= ' l.remise, l.remise_percent, l.fk_remise_except, l.subprice,';
|
||||
$sql.= ' '.$this->db->pdate('l.date_start').' as date_start,'.$this->db->pdate('l.date_end').' as date_end,';
|
||||
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc, l.fk_code_ventilation, l.fk_export_compta,';
|
||||
$sql.= ' p.fk_product_type as fk_product_type, p.label as label, p.description as product_desc';
|
||||
$sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as label, p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
$sql.= ' WHERE l.fk_facture = '.$this->id;
|
||||
@ -650,10 +653,12 @@ class Facture extends CommonObject
|
||||
$faclig = new FactureLigne($this->db);
|
||||
|
||||
$faclig->rowid = $objp->rowid;
|
||||
$faclig->desc = $objp->description; // Description ligne
|
||||
$faclig->libelle = $objp->label; // Label produit
|
||||
$faclig->product_desc = $objp->product_desc; // Description produit
|
||||
$faclig->desc = $objp->description; // Description line
|
||||
$faclig->product_type = $objp->product_type; // Type of line
|
||||
$faclig->product_ref = $objp->product_ref; // Ref product
|
||||
$faclig->libelle = $objp->label; // Label product
|
||||
$faclig->product_desc = $objp->product_desc; // Description product
|
||||
$faclig->fk_product_type = $objp->fk_product_type; // Type of product
|
||||
$faclig->qty = $objp->qty;
|
||||
$faclig->subprice = $objp->subprice;
|
||||
$faclig->tva_tx = $objp->tva_taux;
|
||||
@ -661,7 +666,6 @@ class Facture extends CommonObject
|
||||
$faclig->fk_remise_except = $objp->fk_remise_except;
|
||||
$faclig->produit_id = $objp->fk_product;
|
||||
$faclig->fk_product = $objp->fk_product;
|
||||
$faclig->fk_product_type = $objp->fk_product_type;
|
||||
$faclig->date_start = $objp->date_start;
|
||||
$faclig->date_end = $objp->date_end;
|
||||
$faclig->date_start = $objp->date_start;
|
||||
@ -1542,7 +1546,7 @@ class Facture extends CommonObject
|
||||
$price = ($pu - $remise);
|
||||
}
|
||||
|
||||
$product_type=0;
|
||||
$product_type=$type;
|
||||
if ($fk_product)
|
||||
{
|
||||
$product=new Product($this->db);
|
||||
@ -1569,7 +1573,6 @@ class Facture extends CommonObject
|
||||
$ligne->total_ht=$total_ht;
|
||||
$ligne->total_tva=$total_tva;
|
||||
$ligne->total_ttc=$total_ttc;
|
||||
$ligne->product_type=$type;
|
||||
|
||||
// \TODO Ne plus utiliser
|
||||
$ligne->price=$price;
|
||||
|
||||
@ -599,7 +599,7 @@ if ($id > 0 || ! empty($ref))
|
||||
/* print '<tr><td>'.$langs->trans("RefSupplier")."</td>";
|
||||
print '<td colspan="2">'.$commande->ref_supplier.'</td>';
|
||||
print '</tr>';
|
||||
*/
|
||||
*/
|
||||
// Fournisseur
|
||||
print '<tr><td>'.$langs->trans("Supplier")."</td>";
|
||||
print '<td colspan="2">'.$soc->getNomUrl(1,'supplier').'</td>';
|
||||
@ -727,7 +727,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print_date_range($commandline->date_start,$commandline->date_end);
|
||||
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($commandline->description && $commandline->description!=$product_static->libelle)?'<br>'.dol_htmlentitiesbr($commandline->description):'';
|
||||
}
|
||||
|
||||
// Description - Editor wysiwyg
|
||||
|
||||
@ -889,10 +889,10 @@ else
|
||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
// Show range
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
print_date_range($fac->lignes[$i]->date_start,$fac->lignes[$i]->date_end);
|
||||
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($fac->lignes[$i]->description && $fac->lignes[$i]->description!=$product_static->libelle)?'<br>'.dol_htmlentitiesbr($fac->lignes[$i]->description):'';
|
||||
}
|
||||
|
||||
// Description - Editor wysiwyg
|
||||
|
||||
@ -69,6 +69,7 @@ class Form
|
||||
* \param tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2, 4=tooltip sur les 2 et forcé en Ajax
|
||||
* \param direction -1=Le picto est avant, 0=pas de picto, 1=le picto est après
|
||||
* \param img Code img du picto
|
||||
* \param i Numero of tooltip
|
||||
* \return string Code html du tooltip (texte+picto)
|
||||
*/
|
||||
function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$i=1,$width='200',$shiftX='10')
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
-- when current version is 2.6.0 or higher.
|
||||
--
|
||||
|
||||
alter table llx_facturedet_rec add column product_type integer DEFAULT 0 after fk_product;
|
||||
|
||||
-- Usage of llx_menu_const and llx_menu_constraint is too complicated
|
||||
-- so we made first change to remove it
|
||||
alter table llx_menu_const drop foreign key fk_menu_const_fk_menu;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2009 Laurent Destailleur <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
|
||||
@ -23,14 +24,15 @@ create table llx_facturedet_rec
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_facture integer NOT NULL,
|
||||
fk_product integer,
|
||||
product_type integer DEFAULT 0,
|
||||
description text,
|
||||
tva_taux real DEFAULT 19.6, -- taux tva
|
||||
qty real, -- quantité
|
||||
qty real, -- quantity
|
||||
remise_percent real DEFAULT 0, -- pourcentage de remise
|
||||
remise real DEFAULT 0, -- montant de la remise
|
||||
subprice real, -- prix avant remise
|
||||
price real, -- prix final
|
||||
total_ht real, -- Total HT de la ligne toute quantité et incluant remise ligne et globale
|
||||
total_tva real, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale
|
||||
total_ttc real -- Total TTC de la ligne toute quantité et incluant remise ligne et globale
|
||||
total_ht real, -- Total HT de la ligne toute quantity et incluant remise ligne et globale
|
||||
total_tva real, -- Total TVA de la ligne toute quantity et incluant remise ligne et globale
|
||||
total_ttc real -- Total TTC de la ligne toute quantity et incluant remise ligne et globale
|
||||
)type=innodb;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user