Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Juanjo Menent 2016-12-10 14:50:40 +01:00
commit 198bef1bb5
6 changed files with 260 additions and 240 deletions

View File

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

View File

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

View File

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

View File

@ -1070,17 +1070,17 @@ if (empty($reshook))
// Set project
else if ($action == 'classin' && $user->rights->propal->creer) {
$object->setProject($_POST['projectid']);
$object->setProject(GETPOST('projectid','int'));
}
// Delai de livraison
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
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

View File

@ -1839,7 +1839,7 @@ class Propal extends CommonObject
*/
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;
@ -1849,7 +1849,7 @@ class Propal extends CommonObject
$sql.= " SET fk_availability = '".$id."'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
dol_syslog(__METHOD__.' availability('.$availability_id.')', LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{
@ -1861,6 +1861,7 @@ class Propal extends CommonObject
{
$this->oldcopy= clone $this;
$this->fk_availability = $id;
$this->availability_id = $availability_id;
}
if (! $notrigger && empty($error))
@ -1887,6 +1888,14 @@ class Propal extends CommonObject
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)
{
if (! empty($user->rights->propal->creer))
if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT)
{
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql.= " SET fk_input_reason = '".$id."'";
$sql.= " SET fk_input_reason = ".$id;
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
@ -1922,6 +1931,7 @@ class Propal extends CommonObject
{
$this->oldcopy= clone $this;
$this->fk_input_reason = $id;
$this->demand_reason_id = $id;
}
@ -1949,6 +1959,14 @@ class Propal extends CommonObject
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 $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int >0 if OK, <0 if KO
* @deprecated use set_availability
*/
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 $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int >0 si ok, <0 si ko
* @deprecated use set_demand_reason
*/
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;
$langs->load('projects');
print '<tr><td>' . $langs->trans('Project') . '</td><td>';
$numprojet = $formproject->select_projects($socid, $projectid, 'projectid', 0);
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>';
$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=' . $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>';
}