Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-08-01 19:29:58 +02:00
commit 07a09cad1d
18 changed files with 225 additions and 200 deletions

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -40,7 +40,7 @@ $socid=0;
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST("ref"); $ref = GETPOST("ref");
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'propale', $id, 'propal'); $result = restrictedArea($user, 'propal', $id);
/* /*

View File

@ -2381,7 +2381,7 @@ class Propal extends CommonObject
$sql = 'SELECT pt.rowid, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql = 'SELECT pt.rowid, pt.description, pt.fk_product, pt.fk_remise_except,';
$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,';
$sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang,'; $sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang, pt.fk_parent_line,';
$sql.= ' p.label as product_label, 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.= ' p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
@ -2400,7 +2400,8 @@ class Propal extends CommonObject
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->lines[$i] = (object) array(); $this->lines[$i] = (object) array();
$this->lines[$i]->id = $obj->rowid; $this->lines[$i]->id = $obj->rowid; // for backward compatibility
$this->lines[$i]->rowid = $obj->rowid;
$this->lines[$i]->description = $obj->description; $this->lines[$i]->description = $obj->description;
$this->lines[$i]->fk_product = $obj->fk_product; $this->lines[$i]->fk_product = $obj->fk_product;
$this->lines[$i]->ref = $obj->ref; $this->lines[$i]->ref = $obj->ref;
@ -2422,6 +2423,7 @@ class Propal extends CommonObject
$this->lines[$i]->pa_ht = $marginInfos[0]; $this->lines[$i]->pa_ht = $marginInfos[0];
$this->lines[$i]->marge_tx = $marginInfos[1]; $this->lines[$i]->marge_tx = $marginInfos[1];
$this->lines[$i]->marque_tx = $marginInfos[2]; $this->lines[$i]->marque_tx = $marginInfos[2];
$this->lines[$i]->fk_parent_line = $obj->fk_parent_line;
$this->lines[$i]->special_code = $obj->special_code; $this->lines[$i]->special_code = $obj->special_code;
$this->lines[$i]->rang = $obj->rang; $this->lines[$i]->rang = $obj->rang;
$this->lines[$i]->date_start = $this->db->jdate($obj->date_start); $this->lines[$i]->date_start = $this->db->jdate($obj->date_start);
@ -2436,7 +2438,7 @@ class Propal extends CommonObject
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("Error sql=$sql, error=".$this->error,LOG_ERR); dol_syslog(get_class($this)."::getLinesArray Error sql=$sql, error=".$this->error,LOG_ERR);
return -1; return -1;
} }
} }
@ -2556,6 +2558,7 @@ class PropaleLigne
$this->total_ttc = $objp->total_ttc; $this->total_ttc = $objp->total_ttc;
$this->fk_fournprice = $objp->fk_fournprice; $this->fk_fournprice = $objp->fk_fournprice;
$marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht);
$this->pa_ht = $marginInfos[0]; $this->pa_ht = $marginInfos[0];
$this->marge_tx = $marginInfos[1]; $this->marge_tx = $marginInfos[1];
@ -2623,7 +2626,7 @@ class PropaleLigne
$sql.= ' (fk_propal, fk_parent_line, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,'; $sql.= ' (fk_propal, fk_parent_line, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,';
$sql.= ' subprice, remise_percent, '; $sql.= ' subprice, remise_percent, ';
$sql.= ' info_bits, '; $sql.= ' info_bits, ';
$sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, special_code, rang, fk_product_fournisseur_price, buy_price_ht)'; $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang)';
$sql.= " VALUES (".$this->fk_propal.","; $sql.= " VALUES (".$this->fk_propal.",";
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
$sql.= " '".$this->db->escape($this->desc)."',"; $sql.= " '".$this->db->escape($this->desc)."',";
@ -2648,7 +2651,7 @@ class PropaleLigne
$sql.= ' '.$this->rang; $sql.= ' '.$this->rang;
$sql.= ')'; $sql.= ')';
dol_syslog("PropaleLigne::insert sql=$sql"); dol_syslog(get_class($this).'::insert sql='.$sql, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -2671,7 +2674,7 @@ class PropaleLigne
else else
{ {
$this->error=$this->db->error()." sql=".$sql; $this->error=$this->db->error()." sql=".$sql;
dol_syslog("PropaleLigne::insert Error ".$this->error, LOG_ERR); dol_syslog(get_class($this).'::insert Error '.$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }

View File

@ -43,7 +43,7 @@ $action=GETPOST('action','alpha');
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'propale', $id, 'propal'); $result = restrictedArea($user, 'propal', $id);
$object = new Propal($db); $object = new Propal($db);

View File

@ -27,8 +27,6 @@ require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
require_once(DOL_DOCUMENT_ROOT ."/comm/propal/class/propal.class.php"); require_once(DOL_DOCUMENT_ROOT ."/comm/propal/class/propal.class.php");
if (!$user->rights->propale->lire) accessforbidden();
$langs->load("propal"); $langs->load("propal");
$langs->load("companies"); $langs->load("companies");
@ -39,7 +37,7 @@ if (isset($user->societe_id) && $user->societe_id > 0)
$action = ''; $action = '';
$socid = $user->societe_id; $socid = $user->societe_id;
} }
$result = restrictedArea($user, 'propal');
/* /*
@ -65,7 +63,7 @@ print '<tr><td valign="top" width="30%" class="notopnoleft">';
*/ */
$var=false; $var=false;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal.php">'; print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchPropal").'</td></tr>'; print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchPropal").'</td></tr>';
print '<tr '.$bc[$var].'><td>'; print '<tr '.$bc[$var].'><td>';

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -31,11 +31,12 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php");
$langs->load('propal'); $langs->load('propal');
$langs->load('compta'); $langs->load('compta');
$id = isset($_GET["id"])?$_GET["id"]:''; $id=GETPOST('id','int');
$socid=GETPOST('socid','int');
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if (! empty($user->societe_id)) $socid=$user->societe_id;
$result = restrictedArea($user, 'propale', $id, 'propal'); $result = restrictedArea($user, 'propal', $id);
/* /*
@ -44,25 +45,22 @@ $result = restrictedArea($user, 'propale', $id, 'propal');
llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');
$propal = new Propal($db); $object = new Propal($db);
$propal->fetch($_GET["id"]); $object->fetch($id);
$object->fetch_thirdparty();
$societe = new Societe($db); $head = propal_prepare_head($object);
$societe->fetch($propal->socid);
$head = propal_prepare_head($propal);
dol_fiche_head($head, 'info', $langs->trans('Proposal'), 0, 'propal'); dol_fiche_head($head, 'info', $langs->trans('Proposal'), 0, 'propal');
$propal->info($propal->id); $object->info($object->id);
print '<table width="100%"><tr><td>'; print '<table width="100%"><tr><td>';
dol_print_object_info($propal); dol_print_object_info($object);
print '</td></tr></table>'; print '</td></tr></table>';
print '</div>'; print '</div>';
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -67,7 +67,8 @@ $month=GETPOST("month");
$NBLINES=4; $NBLINES=4;
// Security check // Security check
$module='propale'; $module='propal';
$dbtable='';
if (isset($socid)) if (isset($socid))
{ {
$objectid=$socid; $objectid=$socid;
@ -77,8 +78,6 @@ if (isset($socid))
else if (isset($id) && $id > 0) else if (isset($id) && $id > 0)
{ {
$objectid=$id; $objectid=$id;
$module='propale';
$dbtable='propal';
} }
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, $module, $objectid, $dbtable); $result = restrictedArea($user, $module, $objectid, $dbtable);

View File

@ -2743,10 +2743,9 @@ class Commande extends CommonOrder
$lines = array(); $lines = array();
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_tx, '; $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_tx, ';
$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits,l.rang,l.special_code,'; $sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits, l.rang, l.special_code, l.fk_parent_line';
$sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.localtax1_tx, l.localtax2_tx,'; $sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.localtax1_tx, l.localtax2_tx,';
$sql.= ' l.date_start,'; $sql.= ' l.date_start, l.date_end,';
$sql.= ' l.date_end,';
$sql.= ' p.label as product_label, 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.= ' p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
@ -2781,6 +2780,7 @@ class Commande extends CommonOrder
$this->lines[$i]->total_ht = $obj->total_ht; $this->lines[$i]->total_ht = $obj->total_ht;
$this->lines[$i]->total_tva = $obj->total_tva; $this->lines[$i]->total_tva = $obj->total_tva;
$this->lines[$i]->total_ttc = $obj->total_ttc; $this->lines[$i]->total_ttc = $obj->total_ttc;
$this->lines[$i]->fk_parent_line = $obj->fk_parent_line;
$this->lines[$i]->special_code = $obj->special_code; $this->lines[$i]->special_code = $obj->special_code;
$this->lines[$i]->rang = $obj->rang; $this->lines[$i]->rang = $obj->rang;
$this->lines[$i]->date_start = $this->db->jdate($obj->date_start); $this->lines[$i]->date_start = $this->db->jdate($obj->date_start);
@ -3003,7 +3003,7 @@ class OrderLine
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseign<67> et utilis<69> pour calcul des marges alors prix achat = prix vente (idem pour remises) // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente (idem pour remises)
if ($this->pa_ht == 0) { if ($this->pa_ht == 0) {
if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
@ -3027,34 +3027,28 @@ class OrderLine
$sql.= " '".price2num($this->tva_tx)."',"; $sql.= " '".price2num($this->tva_tx)."',";
$sql.= " '".price2num($this->localtax1_tx)."',"; $sql.= " '".price2num($this->localtax1_tx)."',";
$sql.= " '".price2num($this->localtax2_tx)."',"; $sql.= " '".price2num($this->localtax2_tx)."',";
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; } $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").',';
else { $sql.='null,'; }
$sql.= " '".$this->product_type."',"; $sql.= " '".$this->product_type."',";
$sql.= " '".price2num($this->remise_percent)."',"; $sql.= " '".price2num($this->remise_percent)."',";
$sql.= " ".($this->subprice!=''?"'".price2num($this->subprice)."'":"null").","; $sql.= " ".($this->subprice!=''?"'".price2num($this->subprice)."'":"null").",";
$sql.= " ".($this->price!=''?"'".price2num($this->price)."'":"null").","; $sql.= " ".($this->price!=''?"'".price2num($this->price)."'":"null").",";
$sql.= " '".price2num($this->remise)."',"; $sql.= " '".price2num($this->remise)."',";
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.","; $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").',';
else $sql.= 'null,';
$sql.= ' '.$this->special_code.','; $sql.= ' '.$this->special_code.',';
$sql.= ' '.$this->rang.','; $sql.= ' '.$this->rang.',';
if (isset($this->fk_fournprice)) $sql.= ' '.$this->fk_fournprice.','; $sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").',';
else $sql.= ' null,'; $sql.= ' '.price2num($this->pa_ht).',';
if (isset($this->pa_ht)) $sql.= ' '.price2num($this->pa_ht).',';
else $sql.= ' null,';
$sql.= " '".$this->info_bits."',"; $sql.= " '".$this->info_bits."',";
$sql.= " '".price2num($this->total_ht)."',"; $sql.= " '".price2num($this->total_ht)."',";
$sql.= " '".price2num($this->total_tva)."',"; $sql.= " '".price2num($this->total_tva)."',";
$sql.= " '".price2num($this->total_localtax1)."',"; $sql.= " '".price2num($this->total_localtax1)."',";
$sql.= " '".price2num($this->total_localtax2)."',"; $sql.= " '".price2num($this->total_localtax2)."',";
$sql.= " '".price2num($this->total_ttc)."',"; $sql.= " '".price2num($this->total_ttc)."',";
if ($this->date_start) { $sql.= "'".$this->db->idate($this->date_start)."',"; } $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").',';
else { $sql.='null,'; } $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
if ($this->date_end) { $sql.= "'".$this->db->idate($this->date_end)."'"; }
else { $sql.='null'; }
$sql.= ')'; $sql.= ')';
dol_syslog("OrderLine::insert sql=".$sql); dol_syslog(get_class($this)."::insert sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -3076,7 +3070,7 @@ class OrderLine
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("OrderLine::insert Error ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
@ -3140,9 +3134,8 @@ class OrderLine
$sql.= " , total_localtax1=".price2num($this->total_localtax1); $sql.= " , total_localtax1=".price2num($this->total_localtax1);
$sql.= " , total_localtax2=".price2num($this->total_localtax2); $sql.= " , total_localtax2=".price2num($this->total_localtax2);
$sql.= " , info_bits=".$this->info_bits; $sql.= " , info_bits=".$this->info_bits;
if ($this->date_start) { $sql.= " , date_start='".$this->db->idate($this->date_start)."'"; } $sql.= " , date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null");
else { $sql.=' , date_start=null'; } $sql.= " , date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
if ($this->date_end) { $sql.= " , date_end='".$this->db->idate($this->date_end)."'"; }
$sql.= " , product_type=".$this->product_type; $sql.= " , product_type=".$this->product_type;
$sql.= " , fk_parent_line=".(! empty($this->fk_parent_line)?$this->fk_parent_line:"null"); $sql.= " , fk_parent_line=".(! empty($this->fk_parent_line)?$this->fk_parent_line:"null");
if (! empty($this->rang)) $sql.= ", rang=".$this->rang; if (! empty($this->rang)) $sql.= ", rang=".$this->rang;

View File

@ -3010,7 +3010,7 @@ class Facture extends CommonInvoice
{ {
$sql = 'SELECT l.rowid, l.description, l.fk_product, l.product_type, l.qty, l.tva_tx,'; $sql = 'SELECT l.rowid, l.description, l.fk_product, l.product_type, l.qty, l.tva_tx,';
$sql.= ' l.fk_remise_except,'; $sql.= ' l.fk_remise_except,';
$sql.= ' l.remise_percent, l.subprice, l.info_bits, l.rang, l.special_code,'; $sql.= ' l.remise_percent, l.subprice, l.info_bits, l.rang, l.special_code, l.fk_parent_line,';
$sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; $sql.= ' l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,';
$sql.= ' l.date_start,'; $sql.= ' l.date_start,';
$sql.= ' l.date_end,'; $sql.= ' l.date_end,';
@ -3049,6 +3049,7 @@ class Facture extends CommonInvoice
$this->lines[$i]->total_ht = $obj->total_ht; $this->lines[$i]->total_ht = $obj->total_ht;
$this->lines[$i]->total_tva = $obj->total_tva; $this->lines[$i]->total_tva = $obj->total_tva;
$this->lines[$i]->total_ttc = $obj->total_ttc; $this->lines[$i]->total_ttc = $obj->total_ttc;
$this->lines[$i]->fk_parent_line = $obj->fk_parent_line;
$this->lines[$i]->special_code = $obj->special_code; $this->lines[$i]->special_code = $obj->special_code;
$this->lines[$i]->rang = $obj->rang; $this->lines[$i]->rang = $obj->rang;
$this->lines[$i]->date_start = $this->db->jdate($obj->date_start); $this->lines[$i]->date_start = $this->db->jdate($obj->date_start);
@ -3266,10 +3267,9 @@ class FactureLigne
if (empty($this->special_code)) $this->special_code=0; if (empty($this->special_code)) $this->special_code=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseign<67> et utilis<69> pour calcul des marges alors prix achat = prix vente (idem pour remises) // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente (idem pour remises)
if ($this->pa_ht == 0) { if ($this->pa_ht == 0) {
if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
@ -3294,27 +3294,19 @@ class FactureLigne
$sql.= " ".price2num($this->tva_tx).","; $sql.= " ".price2num($this->tva_tx).",";
$sql.= " ".price2num($this->localtax1_tx).","; $sql.= " ".price2num($this->localtax1_tx).",";
$sql.= " ".price2num($this->localtax2_tx).","; $sql.= " ".price2num($this->localtax2_tx).",";
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; } $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").',';
else { $sql.='null,'; }
$sql.= " ".$this->product_type.","; $sql.= " ".$this->product_type.",";
$sql.= " ".price2num($this->remise_percent).","; $sql.= " ".price2num($this->remise_percent).",";
$sql.= " ".price2num($this->subprice).","; $sql.= " ".price2num($this->subprice).",";
//$sql.= " ".price2num($this->price).","; $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").',';
//$sql.= " ".($this->remise?price2num($this->remise):'0').","; // Deprecated $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").",";
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.","; $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").",";
else $sql.= 'null,';
if ($this->date_start) { $sql.= "'".$this->db->idate($this->date_start)."',"; }
else { $sql.='null,'; }
if ($this->date_end) { $sql.= "'".$this->db->idate($this->date_end)."',"; }
else { $sql.='null,'; }
$sql.= ' '.$this->fk_code_ventilation.','; $sql.= ' '.$this->fk_code_ventilation.',';
$sql.= ' '.$this->fk_export_compta.','; $sql.= ' '.$this->fk_export_compta.',';
$sql.= ' '.$this->rang.','; $sql.= ' '.$this->rang.',';
$sql.= ' '.$this->special_code.','; $sql.= ' '.$this->special_code.',';
if (isset($this->fk_fournprice)) $sql.= ' '.$this->fk_fournprice.','; $sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").',';
else $sql.= ' null,'; $sql.= ' '.price2num($this->pa_ht).',';
if (isset($this->pa_ht)) $sql.= ' '.price2num($this->pa_ht).',';
else $sql.= ' null,';
$sql.= " '".$this->info_bits."',"; $sql.= " '".$this->info_bits."',";
$sql.= " ".price2num($this->total_ht).","; $sql.= " ".price2num($this->total_ht).",";
$sql.= " ".price2num($this->total_tva).","; $sql.= " ".price2num($this->total_tva).",";
@ -3431,7 +3423,7 @@ class FactureLigne
if (empty($this->pa_ht)) $this->pa_ht=0; if (empty($this->pa_ht)) $this->pa_ht=0;
// si prix d'achat non renseign<67> et utilis<69> pour calcul des marges alors prix achat = prix vente (idem pour remises) // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente (idem pour remises)
if ($this->pa_ht == 0) { if ($this->pa_ht == 0) {
if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1))
$this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100);
@ -3452,10 +3444,8 @@ class FactureLigne
$sql.= ",localtax1_tx=".price2num($this->localtax1_tx).""; $sql.= ",localtax1_tx=".price2num($this->localtax1_tx)."";
$sql.= ",localtax2_tx=".price2num($this->localtax2_tx).""; $sql.= ",localtax2_tx=".price2num($this->localtax2_tx)."";
$sql.= ",qty=".price2num($this->qty).""; $sql.= ",qty=".price2num($this->qty)."";
if ($this->date_start) { $sql.= ",date_start='".$this->db->idate($this->date_start)."'"; } $sql.= ",date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null");
else { $sql.=',date_start=null'; } $sql.= ",date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
if ($this->date_end) { $sql.= ",date_end='".$this->db->idate($this->date_end)."'"; }
else { $sql.=',date_end=null'; }
$sql.= ",product_type=".$this->product_type; $sql.= ",product_type=".$this->product_type;
$sql.= ",info_bits='".$this->info_bits."'"; $sql.= ",info_bits='".$this->info_bits."'";
if (empty($this->skip_update_total)) if (empty($this->skip_update_total))

View File

@ -2521,7 +2521,7 @@ abstract class CommonObject
* @param HookManager $hookmanager Hookmanager * @param HookManager $hookmanager Hookmanager
* @return void * @return void
*/ */
function printObjectLines($action,$seller,$buyer,$selected=0,$dateSelector=0,$hookmanager=false) function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0, $hookmanager=false)
{ {
global $conf,$langs; global $conf,$langs;
@ -2540,9 +2540,9 @@ abstract class CommonObject
print '<td align="right" width="80">'.$langs->trans('BuyingPrice').'</td>'; print '<td align="right" width="80">'.$langs->trans('BuyingPrice').'</td>';
else else
print '<td align="right" width="80">'.$langs->trans('BuyingCost').'</td>'; print '<td align="right" width="80">'.$langs->trans('BuyingCost').'</td>';
if($conf->global->DISPLAY_MARGIN_RATES) if (! empty($conf->global->DISPLAY_MARGIN_RATES))
print '<td align="right" width="50">'.$langs->trans('MarginRate').'</td>'; print '<td align="right" width="50">'.$langs->trans('MarginRate').'</td>';
if($conf->global->DISPLAY_MARK_RATES) if (! empty($conf->global->DISPLAY_MARK_RATES))
print '<td align="right" width="50">'.$langs->trans('MarkRate').'</td>'; print '<td align="right" width="50">'.$langs->trans('MarkRate').'</td>';
} }
print '<td align="right" width="50">'.$langs->trans('TotalHTShort').'</td>'; print '<td align="right" width="50">'.$langs->trans('TotalHTShort').'</td>';
@ -2564,7 +2564,7 @@ abstract class CommonObject
if (empty($line->fk_parent_line)) if (empty($line->fk_parent_line))
{ {
$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected); $parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected);
$reshook=$hookmanager->executeHooks('printObjectLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
} }
} }
else else

View File

@ -3755,7 +3755,7 @@ class Form
* @param int $force_entity Possibility to force entity * @param int $force_entity Possibility to force entity
* @return void * @return void
*/ */
function select_dolgroups($selected='',$htmlname='groupid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity='') function select_dolgroups($selected='', $htmlname='groupid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity='')
{ {
global $conf,$user,$langs; global $conf,$user,$langs;

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -201,10 +201,14 @@ class modCommande extends DolibarrModules
$this->remove($options); $this->remove($options);
//ODT template //ODT template
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; $dirodt=DOL_DATA_ROOT.'/doctemplates/orders';
$dest=$dirodt.'/template_order.odt';
if (file_exists($src) && ! file_exists($dest))
{
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
dol_mkdir($dirodt); dol_mkdir($dirodt);
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; $dest=$dirodt.'/template_order.odt';
$result=dol_copy($src,$dest,0,0); $result=dol_copy($src,$dest,0,0);
if ($result < 0) if ($result < 0)
{ {
@ -212,6 +216,7 @@ class modCommande extends DolibarrModules
$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
return 0; return 0;
} }
}
$sql = array( $sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -223,10 +223,15 @@ class modFacture extends DolibarrModules
// Remove permissions and default values // Remove permissions and default values
$this->remove($options); $this->remove($options);
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); //ODT template
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/invoices'; $dirodt=DOL_DATA_ROOT.'/doctemplates/invoices';
$dest=$dirodt.'/template_invoice.odt';
if (file_exists($src) && ! file_exists($dest))
{
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
dol_mkdir($dirodt); dol_mkdir($dirodt);
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt'; $dest=$dirodt.'/template_invoice.odt';
$result=dol_copy($src,$dest,0,0); $result=dol_copy($src,$dest,0,0);
if ($result < 0) if ($result < 0)
{ {
@ -234,6 +239,7 @@ class modFacture extends DolibarrModules
$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
return 0; return 0;
} }
}
$sql = array( $sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2012 Juanjo Menentr <jmenent@2byte.es> * Copyright (C) 2012 Juanjo Menentr <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -199,10 +199,14 @@ class modPropale extends DolibarrModules
$this->remove($options); $this->remove($options);
//ODT template //ODT template
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/proposals/template_proposal.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/proposals'; $dirodt=DOL_DATA_ROOT.'/doctemplates/proposals';
$dest=$dirodt.'/template_proposal.odt';
if (file_exists($src) && ! file_exists($dest))
{
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
dol_mkdir($dirodt); dol_mkdir($dirodt);
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/proposals/template_proposal.odt'; $dest=$dirodt.'/template_proposal.odt';
$result=dol_copy($src,$dest,0,0); $result=dol_copy($src,$dest,0,0);
if ($result < 0) if ($result < 0)
{ {
@ -210,6 +214,7 @@ class modPropale extends DolibarrModules
$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
return 0; return 0;
} }
}
$sql = array( $sql = array(
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,

View File

@ -368,10 +368,15 @@ class modSociete extends DolibarrModules
// We disable this to prevent pb of modules not correctly disabled // We disable this to prevent pb of modules not correctly disabled
//$this->remove($options); //$this->remove($options);
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); //ODT template
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/thirdparties'; $dirodt=DOL_DATA_ROOT.'/doctemplates/thirdparties';
$dest=$dirodt.'/template_thirdparty.odt';
if (file_exists($src) && ! file_exists($dest))
{
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
dol_mkdir($dirodt); dol_mkdir($dirodt);
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt'; $dest=$dirodt.'/template_thirdparty.odt';
$result=dol_copy($src,$dest,0,0); $result=dol_copy($src,$dest,0,0);
if ($result < 0) if ($result < 0)
{ {
@ -379,6 +384,7 @@ class modSociete extends DolibarrModules
$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
return 0; return 0;
} }
}
$sql = array(); $sql = array();

View File

@ -337,6 +337,7 @@ if (! $error && $db->connected && $action == "set")
$dir[4] = $main_data_dir."/propale"; $dir[4] = $main_data_dir."/propale";
$dir[5] = $main_data_dir."/ficheinter"; $dir[5] = $main_data_dir."/ficheinter";
$dir[6] = $main_data_dir."/produit"; $dir[6] = $main_data_dir."/produit";
$dir[7] = $main_data_dir."/doctemplates";
// Boucle sur chaque repertoire de dir[] pour les creer s'ils nexistent pas // Boucle sur chaque repertoire de dir[] pour les creer s'ils nexistent pas
$num=count($dir); $num=count($dir);
@ -372,6 +373,27 @@ if (! $error && $db->connected && $action == "set")
print "</td></tr>"; print "</td></tr>";
print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>'; print '<tr><td colspan="2"><br>'.$langs->trans("CorrectProblemAndReloadPage",$_SERVER['PHP_SELF'].'?testget=ok').'</td></tr>';
} }
else
{
//ODT templates
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
$srcroot='./doctemplates';
$destroot=$main_data_dir.'/doctemplates';
$docs=array('thirdparties' => 'thirdparty', 'proposals' => 'proposal', 'orders' => 'order', 'invoices' => 'invoice');
foreach($docs as $dir => $file)
{
$src=$srcroot.'/thirdparties/template_'.$file.'.odt';
$dirodt=$destroot.'/'.$dir;
$dest=$dirodt.'/template_'.$file.'.odt';
dol_mkdir($dirodt);
$result=dol_copy($src,$dest,0,0);
if ($result < 0)
{
print '<tr><td colspan="2"><br>'.$langs->trans('ErrorFailToCopyFile',$src,$dest).'</td></tr>';
}
}
}
} }
} }

View File

@ -255,8 +255,8 @@ class User extends CommonObject
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$p=$obj->param; $p=(! empty($obj->param)?$obj->param:'');
if ($p) $this->conf->$p = $obj->value; if (! empty($p)) $this->conf->$p = $obj->value;
$i++; $i++;
} }
$this->db->free($resql); $this->db->free($resql);

View File

@ -1313,9 +1313,9 @@ else
$usergroup=new UserGroup($db); $usergroup=new UserGroup($db);
$groupslist = $usergroup->listGroupsForUser($fuser->id); $groupslist = $usergroup->listGroupsForUser($fuser->id);
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
{
if (! empty($groupslist)) if (! empty($groupslist))
{
if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)))
{ {
foreach($groupslist as $groupforuser) foreach($groupslist as $groupforuser)
{ {
@ -1333,7 +1333,7 @@ else
print '<table class="noborder" width="100%">'."\n"; print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><th class="liste_titre" width="25%">'.$langs->trans("GroupsToAdd").'</th>'."\n"; print '<tr class="liste_titre"><th class="liste_titre" width="25%">'.$langs->trans("GroupsToAdd").'</th>'."\n";
print '<th>'; print '<th>';
print $form->select_dolgroups('','group',1,$exclude,0,'','',$fuser->entity); print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $fuser->entity);
print ' &nbsp; '; print ' &nbsp; ';
// Multicompany // Multicompany
if (! empty($conf->multicompany->enabled)) if (! empty($conf->multicompany->enabled))

View File

@ -350,9 +350,9 @@ else
// On selectionne les users qui ne sont pas deja dans le groupe // On selectionne les users qui ne sont pas deja dans le groupe
$exclude = array(); $exclude = array();
if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))
{
if (! empty($object->members)) if (! empty($object->members))
{
if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)))
{ {
foreach($object->members as $useringroup) foreach($object->members as $useringroup)
{ {