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

This commit is contained in:
Laurent Destailleur 2016-08-28 15:59:04 +02:00
commit 60bd986efa
13 changed files with 317 additions and 85 deletions

View File

@ -132,6 +132,7 @@ NEW: Use ellipsis truncation on too large left menu text
NEW: When a new field to show into lists is selected, the form is automatically submited and field added. NEW: When a new field to show into lists is selected, the form is automatically submited and field added.
NEW: When creating a template invoice from a draft invoice, if there is link to contract on draft invoice, link is kept on template invoice. NEW: When creating a template invoice from a draft invoice, if there is link to contract on draft invoice, link is kept on template invoice.
NEW: When emailing is not sent completely, show progression. NEW: When emailing is not sent completely, show progression.
NEW: Add entity field in llx_societe_remise_except and llx_societe_remise
For developers: For developers:
NEW: Add a css class style called 'reposition', so when clicking on a link with this class will move scrollbarr to be placed at same page location. NEW: Add a css class style called 'reposition', so when clicking on a link with this class will move scrollbarr to be placed at same page location.

View File

@ -513,7 +513,7 @@ class ActionComm extends CommonObject
$sql.= " a.fk_contact, a.percent as percentage,"; $sql.= " a.fk_contact, a.percent as percentage,";
$sql.= " a.fk_element, a.elementtype,"; $sql.= " a.fk_element, a.elementtype,";
$sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,"; $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,";
$sql.= " c.id as type_id, c.code as type_code, c.libelle,"; $sql.= " c.id as type_id, c.code as type_code, c.libelle, c.color as type_color,";
$sql.= " s.nom as socname,"; $sql.= " s.nom as socname,";
$sql.= " u.firstname, u.lastname as lastname"; $sql.= " u.firstname, u.lastname as lastname";
$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a "; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a ";
@ -541,6 +541,7 @@ class ActionComm extends CommonObject
// Properties of parent table llx_c_actioncomm (will be deprecated in future) // Properties of parent table llx_c_actioncomm (will be deprecated in future)
$this->type_id = $obj->type_id; $this->type_id = $obj->type_id;
$this->type_code = $obj->type_code; $this->type_code = $obj->type_code;
$this->type_color = $obj->type_color;
$transcode=$langs->trans("Action".$obj->type_code); $transcode=$langs->trans("Action".$obj->type_code);
$type_libelle=($transcode!="Action".$obj->type_code?$transcode:$obj->libelle); $type_libelle=($transcode!="Action".$obj->type_code?$transcode:$obj->libelle);
$this->type = $type_libelle; $this->type = $type_libelle;
@ -1109,7 +1110,11 @@ class ActionComm extends CommonObject
if (! empty($this->location)) if (! empty($this->location))
$tooltip .= '<br><b>' . $langs->trans('Location') . ':</b> ' . $this->location; $tooltip .= '<br><b>' . $langs->trans('Location') . ':</b> ' . $this->location;
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE) && $this->type_color)
$linkclose = ' style="background-color:#'.$this->type_color.'" class="'.$classname.' classfortooltip" title="'.dol_escape_htmltag($tooltip, 1).'">';
else
$linkclose = ' class="'.$classname.' classfortooltip" title="'.dol_escape_htmltag($tooltip, 1).'">'; $linkclose = ' class="'.$classname.' classfortooltip" title="'.dol_escape_htmltag($tooltip, 1).'">';
if (! is_object($hookmanager)) if (! is_object($hookmanager))
{ {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';

View File

@ -440,7 +440,7 @@ $sql.= ' a.percent,';
$sql.= ' a.fk_user_author,a.fk_user_action,'; $sql.= ' a.fk_user_author,a.fk_user_action,';
$sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,';
$sql.= ' a.fk_soc, a.fk_contact,'; $sql.= ' a.fk_soc, a.fk_contact,';
$sql.= ' ca.code as type_code, ca.libelle as type_label'; $sql.= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color';
$sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
// We must filter on resource table // We must filter on resource table
@ -531,6 +531,8 @@ if ($resql)
$event->type_code=$obj->type_code; $event->type_code=$obj->type_code;
$event->type_label=$obj->type_label; $event->type_label=$obj->type_label;
$event->type_color=$obj->type_color;
$event->libelle=$obj->label; $event->libelle=$obj->label;
$event->percentage=$obj->percent; $event->percentage=$obj->percent;
$event->authorid=$obj->fk_user_author; // user id of creator $event->authorid=$obj->fk_user_author; // user id of creator

View File

@ -162,6 +162,7 @@ if ($socid > 0)
$sql.= " u.login, u.rowid as user_id"; $sql.= " u.login, u.rowid as user_id";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE rc.fk_soc = " . $object->id; $sql.= " WHERE rc.fk_soc = " . $object->id;
$sql.= " AND rc.entity = " . $conf->entity;
$sql.= " AND u.rowid = rc.fk_user_author"; $sql.= " AND u.rowid = rc.fk_user_author";
$sql.= " ORDER BY rc.datec DESC"; $sql.= " ORDER BY rc.datec DESC";

View File

@ -249,6 +249,7 @@ if ($socid > 0)
$sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user"; $sql = "SELECT SUM(rc.amount_ht) as amount, rc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
$sql.= " WHERE rc.fk_soc = " . $object->id; $sql.= " WHERE rc.fk_soc = " . $object->id;
$sql.= " AND rc.entity = " . $conf->entity;
$sql.= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)"; $sql.= " AND (fk_facture_line IS NULL AND fk_facture IS NULL)";
$sql.= " GROUP BY rc.fk_user"; $sql.= " GROUP BY rc.fk_user";
$resql=$db->query($sql); $resql=$db->query($sql);
@ -328,6 +329,7 @@ if ($socid > 0)
$sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."societe_remise_except as rc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
$sql.= " WHERE rc.fk_soc = " . $object->id; $sql.= " WHERE rc.fk_soc = " . $object->id;
$sql.= " AND rc.entity = " . $conf->entity;
$sql.= " AND u.rowid = rc.fk_user"; $sql.= " AND u.rowid = rc.fk_user";
$sql.= " AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)"; $sql.= " AND (rc.fk_facture_line IS NULL AND rc.fk_facture IS NULL)";
$sql.= " ORDER BY rc.datec DESC"; $sql.= " ORDER BY rc.datec DESC";

View File

@ -66,6 +66,8 @@ class DiscountAbsolute
*/ */
function fetch($rowid,$fk_facture_source=0) function fetch($rowid,$fk_facture_source=0)
{ {
global $conf;
// Check parameters // Check parameters
if (! $rowid && ! $fk_facture_source) if (! $rowid && ! $fk_facture_source)
{ {
@ -81,9 +83,9 @@ class DiscountAbsolute
$sql.= " f.facnumber as ref_facture_source"; $sql.= " f.facnumber as ref_facture_source";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid";
$sql.= " WHERE"; $sql.= " WHERE sr.entity = " . $conf->entity;
if ($rowid) $sql.= " sr.rowid=".$rowid; if ($rowid) $sql.= " AND sr.rowid=".$rowid;
if ($fk_facture_source) $sql.= " sr.fk_facture_source=".$fk_facture_source; if ($fk_facture_source) $sql.= " AND sr.fk_facture_source=".$fk_facture_source;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -150,11 +152,11 @@ class DiscountAbsolute
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except";
$sql.= " (datec, fk_soc, fk_user, description,"; $sql.= " (entity, datec, fk_soc, fk_user, description,";
$sql.= " amount_ht, amount_tva, amount_ttc, tva_tx,"; $sql.= " amount_ht, amount_tva, amount_ttc, tva_tx,";
$sql.= " fk_facture_source"; $sql.= " fk_facture_source";
$sql.= ")"; $sql.= ")";
$sql.= " VALUES ('".$this->db->idate($this->datec!=''?$this->datec:dol_now())."', ".$this->fk_soc.", ".$user->id.", '".$this->db->escape($this->description)."',"; $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec!=''?$this->datec:dol_now())."', ".$this->fk_soc.", ".$user->id.", '".$this->db->escape($this->description)."',";
$sql.= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.","; $sql.= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.",";
$sql.= " ".($this->fk_facture_source?"'".$this->fk_facture_source."'":"null"); $sql.= " ".($this->fk_facture_source?"'".$this->fk_facture_source."'":"null");
$sql.= ")"; $sql.= ")";
@ -343,10 +345,13 @@ class DiscountAbsolute
*/ */
function getAvailableDiscounts($company='', $user='',$filter='', $maxvalue=0) function getAvailableDiscounts($company='', $user='',$filter='', $maxvalue=0)
{ {
global $conf;
$sql = "SELECT SUM(rc.amount_ttc) as amount"; $sql = "SELECT SUM(rc.amount_ttc) as amount";
// $sql = "SELECT rc.amount_ttc as amount"; // $sql = "SELECT rc.amount_ttc as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
$sql.= " WHERE (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available $sql.= " WHERE rc.entity = " . $conf->entity;
$sql.= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available
if (is_object($company)) $sql.= " AND rc.fk_soc = ".$company->id; if (is_object($company)) $sql.= " AND rc.fk_soc = ".$company->id;
if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id; if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id;
if ($filter) $sql.=' AND ('.$filter.')'; if ($filter) $sql.=' AND ('.$filter.')';

View File

@ -1118,7 +1118,8 @@ class Form
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
$sql.= " re.description, re.fk_facture_source"; $sql.= " re.description, re.fk_facture_source";
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
$sql.= " WHERE fk_soc = ".(int) $socid; $sql.= " WHERE re.fk_soc = ".(int) $socid;
$sql.= " AND re.entity = " . $conf->entity;
if ($filter) $sql.= " AND ".$filter; if ($filter) $sql.= " AND ".$filter;
$sql.= " ORDER BY re.description ASC"; $sql.= " ORDER BY re.description ASC";

View File

@ -329,6 +329,9 @@ ALTER TABLE llx_paiement_facture ADD COLUMN multicurrency_amount double(24,8) DE
ALTER TABLE llx_paiementfourn ADD COLUMN multicurrency_amount double(24,8) DEFAULT 0; ALTER TABLE llx_paiementfourn ADD COLUMN multicurrency_amount double(24,8) DEFAULT 0;
ALTER TABLE llx_paiementfourn_facturefourn ADD COLUMN multicurrency_amount double(24,8) DEFAULT 0; ALTER TABLE llx_paiementfourn_facturefourn ADD COLUMN multicurrency_amount double(24,8) DEFAULT 0;
ALTER TABLE llx_societe_remise ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
ALTER TABLE llx_societe_remise_except ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
ALTER TABLE llx_societe_remise_except ADD COLUMN multicurrency_amount_ht double(24,8) DEFAULT 0 NOT NULL; ALTER TABLE llx_societe_remise_except ADD COLUMN multicurrency_amount_ht double(24,8) DEFAULT 0 NOT NULL;
ALTER TABLE llx_societe_remise_except ADD COLUMN multicurrency_amount_tva double(24,8) DEFAULT 0 NOT NULL; ALTER TABLE llx_societe_remise_except ADD COLUMN multicurrency_amount_tva double(24,8) DEFAULT 0 NOT NULL;
ALTER TABLE llx_societe_remise_except ADD COLUMN multicurrency_amount_ttc double(24,8) DEFAULT 0 NOT NULL; ALTER TABLE llx_societe_remise_except ADD COLUMN multicurrency_amount_ttc double(24,8) DEFAULT 0 NOT NULL;

View File

@ -1,6 +1,6 @@
-- ======================================================================== -- ========================================================================
-- Copyright (C) 2000-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> -- Copyright (C) 2000-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com> -- Copyright (C) 2011-2016 Regis Houssin <regis.houssin@capnetworks.com>
-- --
-- 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
@ -22,6 +22,7 @@
create table llx_societe_remise create table llx_societe_remise
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
entity integer DEFAULT 1 NOT NULL, -- multi company id
fk_soc integer NOT NULL, fk_soc integer NOT NULL,
tms timestamp, tms timestamp,
datec datetime, -- creation date datec datetime, -- creation date

View File

@ -22,6 +22,7 @@
create table llx_societe_remise_except create table llx_societe_remise_except
( (
rowid integer AUTO_INCREMENT PRIMARY KEY, rowid integer AUTO_INCREMENT PRIMARY KEY,
entity integer DEFAULT 1 NOT NULL, -- multi company id
fk_soc integer NOT NULL, -- client fk_soc integer NOT NULL, -- client
datec datetime, datec datetime,
amount_ht double(24,8) NOT NULL, amount_ht double(24,8) NOT NULL,

View File

@ -403,6 +403,12 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action')))
$beforeversionarray=explode('.','4.0.9'); $beforeversionarray=explode('.','4.0.9');
if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0)
{ {
// Migrate to add entity value into llx_societe_remise
migrate_remise_entity($db,$langs,$conf);
// Migrate to add entity value into llx_societe_remise_except
migrate_remise_except_entity($db,$langs,$conf);
migrate_directories($db,$langs,$conf,'/fckeditor','/medias'); migrate_directories($db,$langs,$conf,'/fckeditor','/medias');
// Reload modules (this must be always and only into last targeted version) // Reload modules (this must be always and only into last targeted version)
@ -3659,6 +3665,196 @@ function migrate_event_assignement($db,$langs,$conf)
print '</td></tr>'; print '</td></tr>';
} }
/**
* Migrate to add entity value into llx_societe_remise
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_remise_entity($db,$langs,$conf)
{
print '<tr><td colspan="4">';
print '<br>';
print '<b>'.$langs->trans('MigrationRemiseEntity')."</b><br>\n";
$error = 0;
dolibarr_install_syslog("upgrade2::migrate_remise_entity");
$db->begin();
$sqlSelect = "SELECT sr.rowid, s.entity";
$sqlSelect.= " FROM ".MAIN_DB_PREFIX."societe_remise as sr, ".MAIN_DB_PREFIX."societe as s";
$sqlSelect.= " WHERE sr.fk_soc = s.rowid";
//print $sqlSelect;
$resql = $db->query($sqlSelect);
if ($resql)
{
$i = 0;
$num = $db->num_rows($resql);
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise SET";
$sqlUpdate.= " entity = " . $obj->entity;
$sqlUpdate.= " WHERE rowid = " . $obj->rowid;
$result=$db->query($sqlUpdate);
if (! $result)
{
$error++;
dol_print_error($db);
}
print ". ";
$i++;
}
}
else
{
print $langs->trans('AlreadyDone')."<br>\n";
}
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
}
else
{
dol_print_error($db);
$db->rollback();
}
print '</td></tr>';
}
/**
* Migrate to add entity value into llx_societe_remise_except
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_remise_except_entity($db,$langs,$conf)
{
print '<tr><td colspan="4">';
print '<br>';
print '<b>'.$langs->trans('MigrationRemiseExceptEntity')."</b><br>\n";
$error = 0;
dolibarr_install_syslog("upgrade2::migrate_remise_except_entity");
$db->begin();
$sqlSelect = "SELECT sr.rowid, sr.fk_soc, sr.fk_facture_source, sr.fk_facture, sr.fk_facture_line";
$sqlSelect.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr";
//print $sqlSelect;
$resql = $db->query($sqlSelect);
if ($resql)
{
$i = 0;
$num = $db->num_rows($resql);
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($resql);
if (!empty($obj->fk_facture_source) || !empty($obj->fk_facture))
{
$fk_facture = (!empty($obj->fk_facture_source) ? $obj->fk_facture_source : $obj->fk_facture);
$sqlSelect2 = "SELECT f.entity";
$sqlSelect2.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sqlSelect2.= " WHERE f.rowid = " . $fk_facture;
}
else if (!empty($obj->fk_facture_line))
{
$sqlSelect2 = "SELECT f.entity";
$sqlSelect2.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as fd";
$sqlSelect2.= " WHERE fd.rowid = " . $obj->fk_facture_line;
$sqlSelect2.= " AND fd.fk_facture = f.rowid";
}
else
{
$sqlSelect2 = "SELECT s.entity";
$sqlSelect2.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sqlSelect2.= " WHERE s.rowid = " . $obj->fk_soc;
}
$resql2 = $db->query($sqlSelect2);
if ($resql2)
{
if ($db->num_rows($resql2) > 0)
{
$obj2 = $db->fetch_object($resql2);
$sqlUpdate = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except SET";
$sqlUpdate.= " entity = " . $obj2->entity;
$sqlUpdate.= " WHERE rowid = " . $obj->rowid;
$result=$db->query($sqlUpdate);
if (! $result)
{
$error++;
dol_print_error($db);
}
}
}
else
{
$error++;
dol_print_error($db);
}
print ". ";
$i++;
}
}
else
{
print $langs->trans('AlreadyDone')."<br>\n";
}
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
}
else
{
dol_print_error($db);
$db->rollback();
}
print '</td></tr>';
}
/** /**
* Migration directory * Migration directory
* *

View File

@ -191,6 +191,8 @@ MigrationActioncommElement=Update data on actions
MigrationPaymentMode=Data migration for payment mode MigrationPaymentMode=Data migration for payment mode
MigrationCategorieAssociation=Migration of categories MigrationCategorieAssociation=Migration of categories
MigrationEvents=Migration of events to add event owner into assignement table MigrationEvents=Migration of events to add event owner into assignement table
MigrationRemiseEntity=Update entity field value of llx_societe_remise
MigrationRemiseExceptEntity=Update entity field value of llx_societe_remise_except
MigrationReloadModule=Reload module %s MigrationReloadModule=Reload module %s
ShowNotAvailableOptions=Show not available options ShowNotAvailableOptions=Show not available options
HideNotAvailableOptions=Hide not available options HideNotAvailableOptions=Hide not available options

View File

@ -1431,6 +1431,18 @@ class Societe extends CommonObject
} }
} }
// Remove societe_remise
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise";
$sql.= " WHERE fk_soc = " . $id;
if (! $this->db->query($sql))
{
$error++;
$this->error = $this->db->lasterror();
}
}
// Remove societe_remise_except // Remove societe_remise_except
if (! $error) if (! $error)
{ {
@ -1542,7 +1554,7 @@ class Societe extends CommonObject
*/ */
function set_remise_client($remise, $note, User $user) function set_remise_client($remise, $note, User $user)
{ {
global $langs; global $conf, $langs;
// Nettoyage parametres // Nettoyage parametres
$note=trim($note); $note=trim($note);
@ -1574,8 +1586,8 @@ class Societe extends CommonObject
// Ecrit trace dans historique des remises // Ecrit trace dans historique des remises
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise";
$sql.= " (datec, fk_soc, remise_client, note, fk_user_author)"; $sql.= " (entity, datec, fk_soc, remise_client, note, fk_user_author)";
$sql.= " VALUES ('".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',"; $sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',";
$sql.= " '".$this->db->escape($note)."',"; $sql.= " '".$this->db->escape($note)."',";
$sql.= " ".$user->id; $sql.= " ".$user->id;
$sql.= ")"; $sql.= ")";
@ -3508,9 +3520,9 @@ class Societe extends CommonObject
*/ */
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'societe_commerciaux '; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'societe_commerciaux ';
$sql .= ' WHERE fk_soc = '.(int) $dest_id.' AND fk_user IN ( '; $sql .= ' WHERE fk_soc = '.(int) $dest_id.' AND fk_user IN ( ';
$sql = ' SELECT fk_user '; $sql .= ' SELECT fk_user ';
$sql = ' FROM '.MAIN_DB_PREFIX.'societe_commerciaux '; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_commerciaux ';
$sql = ' WHERE fk_soc = '.(int) $origin_id.') '; $sql .= ' WHERE fk_soc = '.(int) $origin_id.') ';
$query = $db->query($sql); $query = $db->query($sql);