Skip to content

Commit

Permalink
Merge pull request #6065 from atm-florian/3.9
Browse files Browse the repository at this point in the history
FIX : delete contract extrafields on contract deletion
  • Loading branch information
eldy committed Dec 7, 2016
2 parents 196428e + de5ad57 commit ad46798
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 39 deletions.
26 changes: 18 additions & 8 deletions htdocs/contrat/class/contrat.class.php
Expand Up @@ -56,7 +56,7 @@ class Contrat extends CommonObject
* @var string
*/
var $ref_customer;

/**
* Supplier reference of the contract
* @var string
Expand Down Expand Up @@ -536,7 +536,7 @@ function reopen($user, $notrigger=0)
return -1;
}
}

/**
* Load a contract from database
*
Expand Down Expand Up @@ -1134,6 +1134,16 @@ function delete($user)
}
}

// Removed extrafields
if (! $error) {
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR);
}
}

if (! $error)
{
// We remove directory
Expand Down Expand Up @@ -1333,7 +1343,7 @@ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_pr

$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc);
$txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate.

$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1,$mysoc, $localtaxes_type);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
Expand All @@ -1356,9 +1366,9 @@ function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_pr

if (empty($pa_ht)) $pa_ht=0;


// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($pu_ht, $remise_percent, $fk_product)) < 0)
{
Expand Down Expand Up @@ -1515,7 +1525,7 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $dat

$localtaxes_type=getLocalTaxesFromRate($tvatx, 0, $this->societe, $mysoc);
$tvatx = preg_replace('/\s*\(.*\)/','',$tvatx); // Remove code into vatrate.

$tabprice=calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtax1tx, $localtax2tx, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
Expand All @@ -1539,7 +1549,7 @@ function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $dat
if (empty($pa_ht)) $pa_ht=0;

// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($pu_ht, $remise_percent)) < 0)
{
Expand Down Expand Up @@ -2571,7 +2581,7 @@ function update($user, $notrigger=0)
if (empty($this->pa_ht)) $this->pa_ht=0;

// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0)
if ($this->pa_ht == 0)
{
if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0)
{
Expand Down
62 changes: 32 additions & 30 deletions htdocs/core/extrafieldsinexport.inc.php
@@ -1,4 +1,4 @@
<?php
<?php

if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra))
{
Expand All @@ -15,36 +15,38 @@
{
while ($obj=$this->db->fetch_object($resql))
{
$fieldname=$keyforaliasextra.'.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$tmp='';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if ($tmpparam['options'] && is_array($tmpparam['options'])) {
$tmpkeys=array_keys($tmpparam['options']);
$tmp=array_shift($tmpkeys);
}
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
break;
if ($obj->type!='separate') {
$fieldname=$keyforaliasextra.'.'.$obj->name;
$fieldlabel=ucfirst($obj->label);
$typeFilter="Text";
switch($obj->type)
{
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$tmp='';
$tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if ($tmpparam['options'] && is_array($tmpparam['options'])) {
$tmpkeys=array_keys($tmpparam['options']);
$tmp=array_shift($tmpkeys);
}
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]=$keyforelement;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]=$keyforelement;
}
}
// End add axtra fields
2 changes: 1 addition & 1 deletion htdocs/fichinter/class/fichinter.class.php
Expand Up @@ -1202,7 +1202,7 @@ function update($user,$notrigger=0)
// Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinterdet SET";
$sql.= " description='".$this->db->escape($this->desc)."'";
$sql.= ",date=".$this->db->idate($this->datei);
$sql.= ",date='".$this->db->idate($this->datei)."'";
$sql.= ",duree=".$this->duration;
$sql.= ",rang='".$this->rang."'";
$sql.= " WHERE rowid = ".$this->rowid;
Expand Down

0 comments on commit ad46798

Please sign in to comment.