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

This commit is contained in:
Laurent Destailleur 2016-12-10 15:59:52 +01:00
commit 185e9e88ae
7 changed files with 262 additions and 241 deletions

View File

@ -187,11 +187,11 @@ if ($action == 'writebookkeeping') {
// Fees // Fees
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k); $accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
// get compte id and label // get compte id and label
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
if ($accountingaccount->fetch(null, $k)) { if ($accountingaccount->fetch(null, $k, true)) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
@ -355,7 +355,7 @@ if ($action == 'export_csv') {
// Fees // Fees
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k); $accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
@ -464,7 +464,7 @@ if (empty($action) || $action == 'view') {
// Fees // Fees
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k); $accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
print "<tr " . $bc[$var] . " >"; print "<tr " . $bc[$var] . " >";

View File

@ -219,11 +219,11 @@ if ($action == 'writebookkeeping') {
// Product / Service // Product / Service
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k); $accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
// get compte id and label // get compte id and label
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
if ($accountingaccount->fetch(null, $k)) { if ($accountingaccount->fetch(null, $k, true)) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
@ -398,7 +398,7 @@ if ($action == 'export_csv') {
// Product / Service // Product / Service
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k); $accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep; print '"' . $val["ref"] . '"' . $sep;
@ -518,7 +518,7 @@ if (empty($action) || $action == 'view') {
// Product / Service // Product / Service
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k); $accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
print "<tr " . $bc[$var] . " >"; print "<tr " . $bc[$var] . " >";

View File

@ -243,7 +243,7 @@ if ($action == 'writebookkeeping') {
if ($mt) { if ($mt) {
// get compte id and label // get compte id and label
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
if ($accountingaccount->fetch(null, $k)) { if ($accountingaccount->fetch(null, $k, true)) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"]; $bookkeeping->doc_ref = $val["ref"];
@ -375,7 +375,7 @@ if ($action == 'export_csv') {
// Product / Service // Product / Service
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount_static = new AccountingAccount($db); $accountingaccount_static = new AccountingAccount($db);
if ($accountingaccount_static->fetch(null, $k)) { if ($accountingaccount_static->fetch(null, $k, true)) {
print $date . $sep; print $date . $sep;
print $sell_journal . $sep; print $sell_journal . $sep;
print length_accountg(html_entity_decode($k)) . $sep; print length_accountg(html_entity_decode($k)) . $sep;
@ -429,7 +429,7 @@ if ($action == 'export_csv') {
// Product / Service // Product / Service
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k); $accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
print '"' . $date . '"' . $sep; print '"' . $date . '"' . $sep;
@ -559,7 +559,7 @@ if (empty($action) || $action == 'view') {
// Product / Service // Product / Service
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k); $accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
print "<tr " . $bc[$var] . ">"; print "<tr " . $bc[$var] . ">";

View File

@ -1070,17 +1070,17 @@ if (empty($reshook))
// Set project // Set project
else if ($action == 'classin' && $user->rights->propal->creer) { else if ($action == 'classin' && $user->rights->propal->creer) {
$object->setProject($_POST['projectid']); $object->setProject(GETPOST('projectid','int'));
} }
// Delai de livraison // Delai de livraison
else if ($action == 'setavailability' && $user->rights->propal->creer) { else if ($action == 'setavailability' && $user->rights->propal->creer) {
$result = $object->availability($_POST['availability_id']); $result = $object->set_availability($user, GETPOST('availability_id','int'));
} }
// Origine de la propale // Origine de la propale
else if ($action == 'setdemandreason' && $user->rights->propal->creer) { else if ($action == 'setdemandreason' && $user->rights->propal->creer) {
$result = $object->demand_reason($_POST['demand_reason_id']); $result = $object->set_demand_reason($user, GETPOST('demand_reason_id','int'));
} }
// Conditions de reglement // Conditions de reglement

View File

@ -1839,7 +1839,7 @@ class Propal extends CommonObject
*/ */
function set_availability($user, $id, $notrigger=0) function set_availability($user, $id, $notrigger=0)
{ {
if (! empty($user->rights->propal->creer)) if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT)
{ {
$error=0; $error=0;
@ -1849,7 +1849,7 @@ class Propal extends CommonObject
$sql.= " SET fk_availability = '".$id."'"; $sql.= " SET fk_availability = '".$id."'";
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__.' availability('.$availability_id.')', LOG_DEBUG);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (!$resql) if (!$resql)
{ {
@ -1861,6 +1861,7 @@ class Propal extends CommonObject
{ {
$this->oldcopy= clone $this; $this->oldcopy= clone $this;
$this->fk_availability = $id; $this->fk_availability = $id;
$this->availability_id = $availability_id;
} }
if (! $notrigger && empty($error)) if (! $notrigger && empty($error))
@ -1887,6 +1888,14 @@ class Propal extends CommonObject
return -1*$error; return -1*$error;
} }
} }
else
{
$error_str='Propal status do not meet requirement '.$this->statut;
dol_syslog(__METHOD__.$error_str, LOG_ERR);
$this->error=$error_str;
$this->errors[]= $this->error;
return -2;
}
} }
/** /**
@ -1899,14 +1908,14 @@ class Propal extends CommonObject
*/ */
function set_demand_reason($user, $id, $notrigger=0) function set_demand_reason($user, $id, $notrigger=0)
{ {
if (! empty($user->rights->propal->creer)) if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT)
{ {
$error=0; $error=0;
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal "; $sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET fk_input_reason = '".$id."'"; $sql.= " SET fk_input_reason = ".$id;
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -1922,6 +1931,7 @@ class Propal extends CommonObject
{ {
$this->oldcopy= clone $this; $this->oldcopy= clone $this;
$this->fk_input_reason = $id; $this->fk_input_reason = $id;
$this->demand_reason_id = $id;
} }
@ -1949,6 +1959,14 @@ class Propal extends CommonObject
return -1*$error; return -1*$error;
} }
} }
else
{
$error_str='Propal status do not meet requirement '.$this->statut;
dol_syslog(__METHOD__.$error_str, LOG_ERR);
$this->error=$error_str;
$this->errors[]= $this->error;
return -2;
}
} }
/** /**
@ -2733,6 +2751,7 @@ class Propal extends CommonObject
* @param int $availability_id Id of new delivery time * @param int $availability_id Id of new delivery time
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
* @deprecated use set_availability
*/ */
function availability($availability_id, $notrigger=0) function availability($availability_id, $notrigger=0)
{ {
@ -2800,6 +2819,7 @@ class Propal extends CommonObject
* @param int $demand_reason_id Id of new source demand * @param int $demand_reason_id Id of new source demand
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int >0 si ok, <0 si ko * @return int >0 si ok, <0 si ko
* @deprecated use set_demand_reason
*/ */
function demand_reason($demand_reason_id, $notrigger=0) function demand_reason($demand_reason_id, $notrigger=0)
{ {

View File

@ -983,8 +983,8 @@ if ($action == 'create')
$projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project; $projectid = GETPOST('projectid')?GETPOST('projectid'):$object->fk_project;
$langs->load('projects'); $langs->load('projects');
print '<tr><td>' . $langs->trans('Project') . '</td><td>'; print '<tr><td>' . $langs->trans('Project') . '</td><td>';
$numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0); $numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, $forceaddid=0, $morecss='');
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>'; print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $object->thirdparty->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id)?'&id='.$id:'')).'">' . $langs->trans("AddProject") . '</a>';
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2010-2015 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2010-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Meos * Copyright (C) 2009 Meos
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 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
* 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
@ -105,7 +106,7 @@ elseif ($modulepart == 'holiday')
if (empty($backtourl)) if (empty($backtourl))
{ {
if (in_array($modulepart, array('product','produit','service'))) $backtourl=DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]); if (in_array($modulepart, array('product','produit','service','produit|service'))) $backtourl=DOL_URL_ROOT."/product/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else if (in_array($modulepart, array('holiday'))) $backtourl=DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); else if (in_array($modulepart, array('project'))) $backtourl=DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]);
} }