New: Toutes les entites (contrat, facture, propal, commande) possde un chanp note (non affich sur PDF) et un champ note public (affich sur PDF)
This commit is contained in:
parent
31119933d7
commit
0b2724ead3
@ -118,6 +118,7 @@ if ($_POST['action'] == 'add')
|
||||
|
||||
$facture->number = $_POST['facnumber'];
|
||||
$facture->date = $datefacture;
|
||||
$facture->note_public = $_POST['note_public'];
|
||||
$facture->note = $_POST['note'];
|
||||
|
||||
if ($_POST['fac_rec'] > 0)
|
||||
@ -155,11 +156,16 @@ if ($_POST['action'] == 'add')
|
||||
}
|
||||
$facid = $facture->create($user);
|
||||
|
||||
if ($facid)
|
||||
if ($facid > 0)
|
||||
{
|
||||
Header('Location: facture.php?facid='.$facid);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["action"]='create';
|
||||
$mesg='<div class="error">'.$facture->error.'</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -280,7 +286,7 @@ if ($_POST['action'] == 'add')
|
||||
}
|
||||
|
||||
// Fin création facture, on l'affiche
|
||||
if ($facid)
|
||||
if ($facid > 0)
|
||||
{
|
||||
Header('Location: facture.php?facid='.$facid);
|
||||
exit;
|
||||
@ -334,7 +340,8 @@ if ($_POST['action'] == 'addligne' && $user->rights->facture->creer)
|
||||
{
|
||||
$dateend=$_POST['date_endyear'].'-'.$_POST['date_endmonth'].'-'.$_POST['date_endday'];
|
||||
}
|
||||
$result = $fac->addline($_POST['facid'],
|
||||
$result = $fac->addline(
|
||||
$_POST['facid'],
|
||||
$_POST['desc'],
|
||||
$_POST['product_desc'],
|
||||
$_POST['pu'],
|
||||
@ -404,7 +411,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
||||
|
||||
if ($_POST['action'] == 'confirm_canceled' && $_POST['confirm'] == 'yes')
|
||||
{
|
||||
if ($user->rights->facture->supprimer )
|
||||
if ($user->rights->facture->supprimer)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($_GET['facid']);
|
||||
@ -595,6 +602,8 @@ if ($_GET['action'] == 'create')
|
||||
{
|
||||
print_titre($langs->trans('NewBill'));
|
||||
|
||||
if ($mesg) print $mesg;
|
||||
|
||||
$soc = new Societe($db);
|
||||
|
||||
if ($_GET['propalid'])
|
||||
@ -642,32 +651,12 @@ if ($_GET['action'] == 'create')
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$soc->nom.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Author').'</td><td>'.$user->fullname.'</td>';
|
||||
print '<td class="border">'.$langs->trans('Comments').'</td>';
|
||||
print '<tr><td>'.$langs->trans('Author').'</td><td colspan="2">'.$user->fullname.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Date').'</td><td>';
|
||||
$html->select_date();
|
||||
print '</td>';
|
||||
|
||||
// Notes
|
||||
$nbrows=4;
|
||||
if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) $nbrows++;
|
||||
print '<td rowspan="'.$nbrows.'" valign="top">';
|
||||
print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_5.'">';
|
||||
if (is_object($propal))
|
||||
{
|
||||
print $propal->note;
|
||||
}
|
||||
if (is_object($commande))
|
||||
{
|
||||
print $commande->note;
|
||||
}
|
||||
if (is_object($contrat))
|
||||
{
|
||||
print $contrat->note;
|
||||
}
|
||||
print '</textarea></td></tr>';
|
||||
print '</td></tr>';
|
||||
|
||||
// Conditions de réglement
|
||||
$cond_reglement_id_defaut=1;
|
||||
@ -688,10 +677,42 @@ if ($_GET['action'] == 'create')
|
||||
$html->select_projects($societe_id, $projet, 'projetid');
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
|
||||
// Note publique
|
||||
print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
|
||||
print '<td valign="top">';
|
||||
print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">';
|
||||
if (is_object($propal))
|
||||
{
|
||||
print '<tr><td colspan="2"> </td></tr>';
|
||||
print $propal->note_public;
|
||||
}
|
||||
if (is_object($commande))
|
||||
{
|
||||
print $commande->note_public;
|
||||
}
|
||||
if (is_object($contrat))
|
||||
{
|
||||
print $contrat->note_public;
|
||||
}
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
// Note privée
|
||||
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
|
||||
print '<td valign="top">';
|
||||
print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">';
|
||||
if (is_object($propal))
|
||||
{
|
||||
print $propal->note;
|
||||
}
|
||||
if (is_object($commande))
|
||||
{
|
||||
print $commande->note;
|
||||
}
|
||||
if (is_object($contrat))
|
||||
{
|
||||
print $contrat->note;
|
||||
}
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
/*
|
||||
\todo
|
||||
@ -753,7 +774,6 @@ if ($_GET['action'] == 'create')
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan="3"> </td></tr>';
|
||||
print '<tr><td colspan="3">';
|
||||
|
||||
print '<table class="noborder">';
|
||||
@ -1242,7 +1262,7 @@ else
|
||||
print '<td> </td><td colspan="3"> </td>';
|
||||
}
|
||||
|
||||
$nbrows=8;
|
||||
$nbrows=7;
|
||||
if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) $nbrows++;
|
||||
print '<td rowspan="'.$nbrows.'" colspan="2" valign="top">';
|
||||
|
||||
@ -1352,15 +1372,18 @@ else
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans('Status').'</td><td align="left" colspan="3">'.($fac->getLibStatut()).'</td></tr>';
|
||||
|
||||
if ($fac->note)
|
||||
/*
|
||||
if ($fac->note_public)
|
||||
{
|
||||
print '<tr><td colspan="4" valign="top">'.$langs->trans('Note').' : '.nl2br($fac->note).'</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans('NotePublic').'</td>';
|
||||
print '<td colspan="3">'.nl2br(dolibarr_trunc($fac->note_public,40)).'</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td colspan="4"> </td></tr>';
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
/*
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php');
|
||||
|
||||
$socidp=isset($_GET["socidp"])?$_GET["socidp"]:isset($_POST["socidp"])?$_POST["socidp"]:"";
|
||||
|
||||
$user->getrights('facture');
|
||||
if (!$user->rights->facture->lire)
|
||||
@ -38,9 +39,7 @@ if (!$user->rights->facture->lire)
|
||||
$langs->load("companies");
|
||||
$langs->load("bills");
|
||||
|
||||
/*
|
||||
* Sécurité accés client
|
||||
*/
|
||||
// Sécurité accés
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
unset($_GET["action"]);
|
||||
@ -56,16 +55,43 @@ $fac->fetch($_GET["facid"]);
|
||||
/* Actions */
|
||||
/******************************************************************************/
|
||||
|
||||
if ($_POST["action"] == 'update_public' && $user->rights->facture->creer)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$res=$fac->update_note_public($_POST["note_public"]);
|
||||
if ($res < 0)
|
||||
{
|
||||
$db->rollback();
|
||||
$msg=$fac->error();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST["action"] == 'update' && $user->rights->facture->creer)
|
||||
{
|
||||
$fac->update_note($_POST["note"]);
|
||||
$db->begin();
|
||||
|
||||
$res=$fac->update_note($_POST["note"]);
|
||||
if ($res < 0)
|
||||
{
|
||||
$db->rollback();
|
||||
$msg=$fac->error();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Fin des Actions */
|
||||
/******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/* Affichage fiche */
|
||||
/******************************************************************************/
|
||||
|
||||
llxHeader();
|
||||
|
||||
@ -108,19 +134,39 @@ if ($_GET["facid"])
|
||||
$html->form_modes_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->mode_reglement_id,"none");
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top" colspan="4">'.$langs->trans("Note").' :</td></tr>';
|
||||
|
||||
print '<tr><td valign="top" colspan="4">'.($fac->note?nl2br($fac->note):" ")."</td></tr>";
|
||||
// Note publique
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
print '<form method="post" action="note.php?facid='.$fac->id.'">';
|
||||
print '<input type="hidden" name="action" value="update_public">';
|
||||
print '<textarea name="note_public" cols="80" rows="8">'.$fac->note_public."</textarea><br>";
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ($fac->note_public?nl2br($fac->note_public):" ");
|
||||
}
|
||||
print "</td></tr>";
|
||||
|
||||
// Note privée
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePrivate").' :</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
if ($_GET["action"] == 'edit')
|
||||
{
|
||||
print '<form method="post" action="note.php?facid='.$fac->id.'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<tr><td valign="top" colspan="4"><textarea name="note" cols="80" rows="8">'.$fac->note."</textarea></td></tr>";
|
||||
print '<tr><td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>';
|
||||
print '<textarea name="note" cols="80" rows="8">'.$fac->note."</textarea><br>";
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
print ($fac->note?nl2br($fac->note):" ");
|
||||
}
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
|
||||
|
||||
|
||||
@ -54,6 +54,7 @@ class Facture
|
||||
var $tva;
|
||||
var $total;
|
||||
var $note;
|
||||
var $note_public;
|
||||
var $paye;
|
||||
var $propalid;
|
||||
var $projetid;
|
||||
@ -94,12 +95,21 @@ class Facture
|
||||
function create($user)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
/* On positionne en mode brouillon la facture */
|
||||
$this->brouillon = 1;
|
||||
// Nettoyage paramètres
|
||||
$this->note=trim($this->note);
|
||||
$this->note_public=trim($this->note_public);
|
||||
if (! $this->remise) $this->remise = 0 ;
|
||||
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
||||
|
||||
/* Facture récurrente */
|
||||
// On positionne en mode brouillon la facture
|
||||
$this->brouillon = 1;
|
||||
|
||||
dolibarr_syslog("Facture::create");
|
||||
|
||||
// Facture récurrente
|
||||
if ($this->fac_rec > 0)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/compta/facture/facture-rec.class.php';
|
||||
@ -119,56 +129,60 @@ class Facture
|
||||
// Definition de la date limite
|
||||
$datelim=$this->calculate_date_lim_reglement();
|
||||
|
||||
/*
|
||||
* Insertion dans la base
|
||||
*/
|
||||
// Insertion dans la base
|
||||
$socid = $this->socidp;
|
||||
$number = $this->number;
|
||||
$amount = $this->amount;
|
||||
$remise = $this->remise;
|
||||
|
||||
if (! $remise) $remise = 0 ;
|
||||
if (strlen($this->mode_reglement_id)==0) $this->mode_reglement_id = 0;
|
||||
if (! $this->projetid) $this->projetid = 'NULL';
|
||||
|
||||
$totalht = ($amount - $remise);
|
||||
// NE ME SEMBLE PLUS JUSTIFIE ICI
|
||||
// $tva = tva($totalht);
|
||||
// $total = $totalht + $tva;
|
||||
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture (facnumber, fk_soc, datec, amount, remise, remise_percent';
|
||||
$sql .= ', datef, note, fk_user_author, fk_projet';
|
||||
$sql .= ', fk_cond_reglement, fk_mode_reglement, date_lim_reglement, ref_client) ';
|
||||
$sql .= " VALUES ('$number','$socid', now(), '$totalht', '$remise'";
|
||||
$sql .= ",'$this->remise_percent', ".$this->db->idate($this->date);
|
||||
$sql .= ",'".addslashes($this->note)."',$user->id, $this->projetid";
|
||||
$sql .= ','.$this->cond_reglement_id.','.$this->mode_reglement_id.','.$this->db->idate($datelim).', \''.$this->ref_client.'\')';
|
||||
if ( $this->db->query($sql) )
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture (';
|
||||
$sql.= ' facnumber, fk_soc, datec, amount, remise, remise_percent,';
|
||||
$sql.= ' datef,';
|
||||
$sql.= ' note,';
|
||||
$sql.= ' note_public,';
|
||||
$sql.= ' fk_user_author, fk_projet,';
|
||||
$sql.= ' fk_cond_reglement, fk_mode_reglement, date_lim_reglement, ref_client) ';
|
||||
$sql.= " VALUES (";
|
||||
$sql.= "'$number','$socid', now(), '$totalht', '$remise'";
|
||||
$sql.= ",'$this->remise_percent', ".$this->db->idate($this->date);
|
||||
$sql.= ",".($this->note?"'".addslashes($this->note)."'":"null");
|
||||
$sql.= ",".($this->note_public?"'".addslashes($this->note_public)."'":"null");
|
||||
$sql.= ",".$user->id;
|
||||
$sql.= ",".($this->projetid?$this->projetid:"null");
|
||||
$sql.= ','.$this->cond_reglement_id;
|
||||
$sql.= ",".$this->mode_reglement_id;
|
||||
$sql.= ','.$this->db->idate($datelim);
|
||||
$sql.= ', \''.$this->ref_client.'\')';
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture');
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET facnumber='(PROV".$this->id.")' WHERE rowid=".$this->id;
|
||||
$this->db->query($sql);
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
if ($this->id && $this->propalid)
|
||||
if ($resql && $this->id && $this->propalid)
|
||||
{
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'fa_pr (fk_facture, fk_propal) VALUES ('.$this->id.','.$this->propalid.')';
|
||||
$this->db->query($sql);
|
||||
$resql=$this->db->query($sql);
|
||||
}
|
||||
if ($this->id && $this->commandeid)
|
||||
if ($resql && $this->id && $this->commandeid)
|
||||
{
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_fa (fk_facture, fk_commande) VALUES ('.$this->id.','.$this->commandeid.')';
|
||||
$this->db->query($sql);
|
||||
$resql=$this->db->query($sql);
|
||||
}
|
||||
|
||||
/*
|
||||
* Produits/services
|
||||
*
|
||||
*/
|
||||
* Produits/services
|
||||
*/
|
||||
for ($i = 0 ; $i < sizeof($this->products) ; $i++)
|
||||
{
|
||||
$prod = new Product($this->db, $this->products[$i]);
|
||||
$prod->fetch($this->products[$i]);
|
||||
$res=$prod->fetch($this->products[$i]);
|
||||
|
||||
// multiprix
|
||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||
{
|
||||
@ -177,8 +191,12 @@ class Facture
|
||||
$price = $prod->multiprices[$soc->price_level];
|
||||
}
|
||||
else
|
||||
{
|
||||
$price = $prod->price;
|
||||
$result_insert = $this->addline($this->id,
|
||||
}
|
||||
|
||||
$resql = $this->addline(
|
||||
$this->id,
|
||||
$prod->libelle,
|
||||
$prod->description,
|
||||
$price,
|
||||
@ -188,19 +206,20 @@ class Facture
|
||||
$this->products_remise_percent[$i],
|
||||
$this->products_date_start[$i],
|
||||
$this->products_date_end[$i]
|
||||
);
|
||||
);
|
||||
|
||||
if ( $result_insert < 0)
|
||||
if ($resql < 0)
|
||||
{
|
||||
$this->error=$this->db->error;
|
||||
dolibarr_print_error($this->db);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Produits de la facture récurrente
|
||||
*
|
||||
*/
|
||||
if ($this->fac_rec > 0)
|
||||
* Produits de la facture récurrente
|
||||
*/
|
||||
if ($resql && $this->fac_rec > 0)
|
||||
{
|
||||
for ($i = 0 ; $i < sizeof($_facrec->lignes) ; $i++)
|
||||
{
|
||||
@ -210,13 +229,14 @@ class Facture
|
||||
$prod->fetch($_facrec->lignes[$i]->produit_id);
|
||||
}
|
||||
|
||||
$result_insert = $this->addline($this->id,
|
||||
addslashes($_facrec->lignes[$i]->desc),
|
||||
$_facrec->lignes[$i]->subprice,
|
||||
$_facrec->lignes[$i]->qty,
|
||||
$_facrec->lignes[$i]->tva_taux,
|
||||
$_facrec->lignes[$i]->produit_id,
|
||||
$_facrec->lignes[$i]->remise_percent);
|
||||
$result_insert = $this->addline(
|
||||
$this->id,
|
||||
$_facrec->lignes[$i]->desc,
|
||||
$_facrec->lignes[$i]->subprice,
|
||||
$_facrec->lignes[$i]->qty,
|
||||
$_facrec->lignes[$i]->tva_taux,
|
||||
$_facrec->lignes[$i]->produit_id,
|
||||
$_facrec->lignes[$i]->remise_percent);
|
||||
|
||||
if ( $result_insert < 0)
|
||||
{
|
||||
@ -225,18 +245,26 @@ class Facture
|
||||
}
|
||||
}
|
||||
|
||||
$resql=$this->updateprice($this->id);
|
||||
if ($resql)
|
||||
{
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('BILL_CREATE',$this,$user,$langs,$conf);
|
||||
// Fin appel triggers
|
||||
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
$resql=$this->updateprice($this->id);
|
||||
if ($resql)
|
||||
{
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('BILL_CREATE',$this,$user,$langs,$conf);
|
||||
// Fin appel triggers
|
||||
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
@ -245,6 +273,8 @@ class Facture
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog("Facture::create error ".$this->error." sql=".$sql);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
@ -275,7 +305,7 @@ class Facture
|
||||
}
|
||||
|
||||
$result_insert = $this->addline($this->id,
|
||||
addslashes('Remise exceptionnelle'),
|
||||
'Remise exceptionnelle',
|
||||
(0 - $remise),
|
||||
1,
|
||||
'0'); // Une remise est un négatif sur le TTC, on ne doit pas appliquer de TVA,
|
||||
@ -340,7 +370,7 @@ class Facture
|
||||
$sql = 'SELECT f.fk_soc,f.facnumber,f.amount,f.tva,f.total,f.total_ttc,f.remise,f.remise_percent';
|
||||
$sql .= ','.$this->db->pdate('f.datef').' as df, f.fk_projet';
|
||||
$sql .= ','.$this->db->pdate('f.date_lim_reglement').' as dlr';
|
||||
$sql .= ', f.note, f.paye, f.fk_statut, f.fk_user_author';
|
||||
$sql .= ', f.note, f.note_public, f.paye, f.fk_statut, f.fk_user_author';
|
||||
$sql .= ', f.fk_mode_reglement, f.ref_client, p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
|
||||
$sql .= ', f.fk_cond_reglement, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_facture';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'cond_reglement as c, '.MAIN_DB_PREFIX.'facture as f';
|
||||
@ -381,7 +411,8 @@ class Facture
|
||||
$this->cond_reglement = $obj->cond_reglement_libelle;
|
||||
$this->cond_reglement_facture = $obj->cond_reglement_libelle_facture;
|
||||
$this->projetid = $obj->fk_projet;
|
||||
$this->note = stripslashes($obj->note);
|
||||
$this->note = $obj->note;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->user_author = $obj->fk_user_author;
|
||||
$this->lignes = array();
|
||||
|
||||
@ -982,12 +1013,14 @@ class Facture
|
||||
{
|
||||
global $conf;
|
||||
dolibarr_syslog("facture.class.php::addline($facid,$desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$datestart,$dateend,$ventil)");
|
||||
|
||||
if ($this->brouillon)
|
||||
{
|
||||
// Nettoyage paramètres
|
||||
$remise_percent=price2num($remise_percent);
|
||||
$qty=price2num($qty);
|
||||
if (strlen(trim($qty))==0) $qty=1;
|
||||
if (! $qty) $qty=1;
|
||||
if (! $ventil) $ventil=0;
|
||||
|
||||
if ($fk_product && ! $pu)
|
||||
{
|
||||
@ -1045,13 +1078,13 @@ class Facture
|
||||
$sql.= ' (fk_facture, description, price, qty, tva_taux, fk_product, remise_percent, subprice, remise, date_start, date_end, fk_code_ventilation, rang)';
|
||||
|
||||
if ($conf->global->CHANGE_PROD_DESC)
|
||||
{
|
||||
$sql.= " VALUES ($facid, '".addslashes($product_desc)."','$price','$qty','$txtva',";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " VALUES ($facid, '".addslashes($desc)."','$price','$qty','$txtva',";
|
||||
}
|
||||
{
|
||||
$sql.= " VALUES ($facid, '".addslashes($product_desc)."','$price','$qty','$txtva',";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " VALUES ($facid, '".addslashes($desc)."','$price','$qty','$txtva',";
|
||||
}
|
||||
|
||||
if ($fk_product) { $sql.= "'$fk_product',"; }
|
||||
else { $sql.='0,'; }
|
||||
@ -1421,16 +1454,16 @@ class Facture
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mets à jour les commentaires
|
||||
* \param note note
|
||||
* \return int <0 si erreur, >0 si ok
|
||||
* \brief Mets à jour les commentaires privés
|
||||
* \param note Commentaire
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function update_note($note)
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET note = '".addslashes($note)."'";
|
||||
$sql .= ' WHERE rowid ='. $this->id;
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->note = $note;
|
||||
return 1;
|
||||
@ -1441,9 +1474,30 @@ class Facture
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mets à jour les commentaires publiques
|
||||
* \param note_public Commentaire
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function update_note_public($note_public)
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET note_public = '".addslashes($note_public)."'";
|
||||
$sql .= ' WHERE rowid ='. $this->id;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->note_public = $note_public;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Charge les informations d'ordre info dans l'objet facture
|
||||
* \param id Id de la facture a charger
|
||||
* \param id Id de la facture a charger
|
||||
*/
|
||||
function info($id)
|
||||
{
|
||||
|
||||
@ -31,6 +31,8 @@ ReturnCodeLastAccess=Return code for last database access
|
||||
InformationLastAccess=Information for last database access
|
||||
DolibarrHasDetectedError=Dolibarr has detected a technical error
|
||||
InformationToHelpDiagnose=This is informations that can help to diagnose
|
||||
NotePublic=Note (public)
|
||||
NotePrivate=Note (private)
|
||||
yes=yes
|
||||
Yes=Yes
|
||||
no=no
|
||||
|
||||
@ -31,6 +31,8 @@ ReturnCodeLastAccess=Code retour dernier acces en base
|
||||
InformationLastAccess=Information sur le dernier accès en base
|
||||
DolibarrHasDetectedError=Dolibarr a détecté une erreur technique
|
||||
InformationToHelpDiagnose=Voici les informations qui pourront aider au diagnostic
|
||||
NotePublic=Note (publique)
|
||||
NotePrivate=Note (privée)
|
||||
yes=oui
|
||||
Yes=Oui
|
||||
no=non
|
||||
|
||||
@ -282,7 +282,7 @@ function dolibarr_get_const($db, $name)
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$db->fetch_object($resql);
|
||||
$value=stripslashes($obj->value);
|
||||
$value=$obj->value;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
@ -530,6 +530,8 @@ class Product
|
||||
global $langs;
|
||||
global $conf;
|
||||
|
||||
dolibarr_syslog("Product::fecth $id=$id ref=$ref");
|
||||
|
||||
// Verification parametres
|
||||
if (! $id && ! $ref)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user