2
0
forked from Wavyzz/dolibarr

Merge branch 'develop' into develop-ecmfiles

This commit is contained in:
Laurent Destailleur
2018-04-13 23:08:26 +02:00
committed by GitHub
12 changed files with 70 additions and 35 deletions

View File

@@ -50,7 +50,7 @@ llxHeader();
print load_fiche_titre($langs->trans("PerfDolibarr"),'','title_setup'); print load_fiche_titre($langs->trans("PerfDolibarr"),'','title_setup');
print $langs->trans("YouMayFindPerfAdviceHere",'http://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' (<a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("Reload").'</a>)<br>'; print $langs->trans("YouMayFindPerfAdviceHere",'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' (<a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("Reload").'</a>)<br>';
// Recupere la version de PHP // Recupere la version de PHP
$phpversion=version_php(); $phpversion=version_php();

View File

@@ -2730,14 +2730,15 @@ class Facture extends CommonInvoice
// Mise a jour informations denormalisees au niveau de la facture meme // Mise a jour informations denormalisees au niveau de la facture meme
$result=$this->update_price(1,'auto',0,$mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. $result=$this->update_price(1,'auto',0,$mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode.
if ($result > 0) if ($result > 0)
{ {
$this->db->commit(); $this->db->commit();
return $this->line->rowid; return $this->line->id;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@@ -4482,11 +4483,11 @@ class FactureLigne extends CommonInvoiceLine
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet'); $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet');
$this->rowid=$this->id; // For backward compatibility
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
$this->id=$this->rowid;
$result=$this->insertExtraFields(); $result=$this->insertExtraFields();
if ($result < 0) if ($result < 0)
{ {
@@ -4558,12 +4559,12 @@ class FactureLigne extends CommonInvoiceLine
} }
$this->db->commit(); $this->db->commit();
return $this->rowid; return $this->id;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }

View File

@@ -369,7 +369,8 @@ if (! is_array($x_coll) || ! is_array($x_paye))
foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) { foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) {
// Define type // Define type
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']); // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type // Try to enhance type detection using date_start and date_end for free lines where type
// was not saved. // was not saved.
if (!empty($fields['ddate_start'])) { if (!empty($fields['ddate_start'])) {
@@ -401,10 +402,10 @@ if (! is_array($x_coll) || ! is_array($x_paye))
{ {
$product_static->id=$fields['pid']; $product_static->id=$fields['pid'];
$product_static->ref=$fields['pref']; $product_static->ref=$fields['pref'];
$product_static->type=$fields['ptype']; $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered
print $product_static->getNomUrl(1); print $product_static->getNomUrl(1);
if (dol_string_nohtmltag($fields['descr'])) { if (dol_string_nohtmltag($fields['descr'])) {
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
} }
} }
else else
@@ -423,7 +424,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$fields['descr']=$langs->transnoentitiesnoconv($reg[1]); $fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
} }
} }
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
// Show range // Show range
print_date_range($fields['ddate_start'],$fields['ddate_end']); print_date_range($fields['ddate_start'],$fields['ddate_end']);
@@ -550,7 +551,8 @@ if (! is_array($x_coll) || ! is_array($x_paye))
foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields) { foreach ($x_both[$rate]['paye']['detail'] as $index=>$fields) {
// Define type // Define type
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']); // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown.
$type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']);
// Try to enhance type detection using date_start and date_end for free lines where type // Try to enhance type detection using date_start and date_end for free lines where type
// was not saved. // was not saved.
if (!empty($fields['ddate_start'])) { if (!empty($fields['ddate_start'])) {
@@ -582,10 +584,10 @@ if (! is_array($x_coll) || ! is_array($x_paye))
{ {
$product_static->id=$fields['pid']; $product_static->id=$fields['pid'];
$product_static->ref=$fields['pref']; $product_static->ref=$fields['pref'];
$product_static->type=$fields['ptype']; $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered
print $product_static->getNomUrl(1); print $product_static->getNomUrl(1);
if (dol_string_nohtmltag($fields['descr'])) { if (dol_string_nohtmltag($fields['descr'])) {
print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
} }
} }
else else
@@ -595,7 +597,16 @@ if (! is_array($x_coll) || ! is_array($x_paye))
} else { } else {
$text = img_object($langs->trans('Product'),'product'); $text = img_object($langs->trans('Product'),'product');
} }
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) {
if ($reg[1]=='DEPOSIT') {
$fields['descr']=$langs->transnoentitiesnoconv('Deposit');
} elseif ($reg[1]=='CREDIT_NOTE') {
$fields['descr']=$langs->transnoentitiesnoconv('CreditNote');
} else {
$fields['descr']=$langs->transnoentitiesnoconv($reg[1]);
}
}
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24);
// Show range // Show range
print_date_range($fields['ddate_start'],$fields['ddate_end']); print_date_range($fields['ddate_start'],$fields['ddate_end']);

View File

@@ -97,7 +97,7 @@ class Conf
// First level object // First level object
// TODO Remove this part. // TODO Remove this part.
$this->expedition_bon = new stdClass(); $this->expedition_bon = new stdClass();
$this->livraison_bon = new stdClass(); $this->livraison_bon = new stdClass();
$this->fournisseur = new stdClass(); $this->fournisseur = new stdClass();
$this->product = new stdClass(); $this->product = new stdClass();
$this->service = new stdClass(); $this->service = new stdClass();
@@ -107,12 +107,12 @@ class Conf
$this->propal = new stdClass(); $this->propal = new stdClass();
$this->facture = new stdClass(); $this->facture = new stdClass();
$this->contrat = new stdClass(); $this->contrat = new stdClass();
$this->usergroup = new stdClass(); $this->usergroup = new stdClass();
$this->adherent = new stdClass(); $this->adherent = new stdClass();
$this->bank = new stdClass(); $this->bank = new stdClass();
$this->notification = new stdClass(); $this->notification = new stdClass();
$this->mailing = new stdClass(); $this->mailing = new stdClass();
$this->expensereport = new stdClass(); $this->expensereport = new stdClass();
$this->productbatch = new stdClass(); $this->productbatch = new stdClass();
} }

View File

@@ -867,7 +867,7 @@ class FormFile
} }
else else
{ {
preg_match('/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir).'$/', $filedir, $regs); preg_match('/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir,'/').'$/', $filedir, $regs);
$entity = ((! empty($regs[1]) && $regs[1] > 1) ? $regs[1] : $conf->entity); $entity = ((! empty($regs[1]) && $regs[1] > 1) ? $regs[1] : $conf->entity);
} }

View File

@@ -1266,8 +1266,11 @@ class FormMail extends Form
$product = new Product($this->db); $product = new Product($this->db);
$product->fetch($line->fk_product, '', '', 1); $product->fetch($line->fk_product, '', '', 1);
$product->fetch_optionals(); $product->fetch_optionals();
foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) { if (is_array($extrafieldstmp->attributes[$object->table_element]['label']) && count($extrafieldstmp->attributes[$object->table_element]['label']) > 0)
$substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key]; {
foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) {
$substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key];
}
} }
} }
$this->substit_lines[] = $substit_line; $this->substit_lines[] = $substit_line;

View File

@@ -5792,7 +5792,7 @@ function dol_concatdesc($text1,$text2,$forxml=false)
*/ */
function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null) function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
{ {
global $db, $conf, $mysoc, $user; global $db, $conf, $mysoc, $user, $extrafields;
$substitutionarray=array(); $substitutionarray=array();
@@ -5964,13 +5964,17 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
// Create dynamic tags for __EXTRAFIELD_FIELD__ // Create dynamic tags for __EXTRAFIELD_FIELD__
if ($object->table_element && $object->id > 0) if ($object->table_element && $object->id > 0)
{ {
$extrafieldstmp = new ExtraFields($db); if (! is_object($extrafields)) $extrafields = new ExtraFields($db);
$extralabels = $extrafieldstmp->fetch_name_optionals_label($object->table_element, true); $extrafields->fetch_name_optionals_label($object->table_element, true);
if ($object->fetch_optionals() > 0)
{ if ($object->fetch_optionals() > 0)
foreach ($extrafieldstmp->attributes[$object->table_element]['label'] as $key => $label) { {
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key]; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
} {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
$substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key];
}
}
} }
} }

View File

@@ -323,7 +323,6 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
} }
//print $sql.'<br>';
if (! $sql) return -1; if (! $sql) return -1;
if ($sql == 'TODO') return -2; if ($sql == 'TODO') return -2;
if ($sql != 'TODO') if ($sql != 'TODO')

View File

@@ -429,3 +429,11 @@ drop table tmp_bank_url_expense_user;
-- Backport a change of value into the hourly rate. -- Backport a change of value into the hourly rate.
-- update llx_projet_task_time as ptt set ptt.thm = (SELECT thm from llx_user as u where ptt.fk_user = u.rowid) where (ptt.thm is null) -- update llx_projet_task_time as ptt set ptt.thm = (SELECT thm from llx_user as u where ptt.fk_user = u.rowid) where (ptt.thm is null)
-- select * from llx_facturedet as fd, llx_product as p where fd.fk_product = p.rowid AND fd.product_type != p.fk_product_type;
update llx_facturedet set product_type = 0 where product_type = 1 AND fk_product > 0 AND fk_product IN (SELECT rowid FROM llx_product WHERE fk_product_type = 0);
update llx_facturedet set product_type = 1 where product_type = 0 AND fk_product > 0 AND fk_product IN (SELECT rowid FROM llx_product WHERE fk_product_type = 1);
update llx_facture_fourn_det set product_type = 0 where product_type = 1 AND fk_product > 0 AND fk_product IN (SELECT rowid FROM llx_product WHERE fk_product_type = 0);
update llx_facture_fourn_det set product_type = 1 where product_type = 0 AND fk_product > 0 AND fk_product IN (SELECT rowid FROM llx_product WHERE fk_product_type = 1);

View File

@@ -37,7 +37,7 @@ $versionfrom=GETPOST("versionfrom",'alpha',3)?GETPOST("versionfrom",'alpha',3):(
$versionto=GETPOST("versionto",'alpha',3)?GETPOST("versionto",'alpha',3):(empty($argv[2])?'':$argv[2]); $versionto=GETPOST("versionto",'alpha',3)?GETPOST("versionto",'alpha',3):(empty($argv[2])?'':$argv[2]);
$setuplang=GETPOST('selectlang','aZ09',3)?GETPOST('selectlang','aZ09',3):(empty($argv[3])?'auto':$argv[3]); $setuplang=GETPOST('selectlang','aZ09',3)?GETPOST('selectlang','aZ09',3):(empty($argv[3])?'auto':$argv[3]);
$langs->setDefaultLang($setuplang); $langs->setDefaultLang($setuplang);
$action=GETPOST('action','alpha')?GETPOST('action','alpha'):(empty($argv[4])?'auto':$argv[4]); $action=GETPOST('action','alpha')?GETPOST('action','alpha'):(empty($argv[4])?'':$argv[4]);
// Define targetversion used to update MAIN_VERSION_LAST_INSTALL for first install // Define targetversion used to update MAIN_VERSION_LAST_INSTALL for first install
// or MAIN_VERSION_LAST_UPGRADE for upgrade. // or MAIN_VERSION_LAST_UPGRADE for upgrade.

View File

@@ -132,7 +132,7 @@ foreach($object->fields as $key => $val)
if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
} }
// Extra fields // Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
{ {
foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{ {
@@ -439,9 +439,12 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line // Detect if we need a fetch on each output line
$needToFetchEachLine=0; $needToFetchEachLine=0;
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
{ {
if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
{
if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object
}
} }

View File

@@ -216,7 +216,13 @@ class FactureTest extends PHPUnit_Framework_TestCase
$newlocalobject=new Facture($this->savdb); $newlocalobject=new Facture($this->savdb);
$newlocalobject->initAsSpecimen(); $newlocalobject->initAsSpecimen();
$this->changeProperties($newlocalobject); $this->changeProperties($newlocalobject);
$this->assertEquals($this->objCompare($localobject,$newlocalobject,true,array('newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','ref','statut','paye','specimen','facnumber','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement','cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva','multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx')), array()); // Actual, Expected
// Hack to avoid test to be wrong when module sellyoursaas is on
unset($localobject->array_options['options_commission']);
unset($localobject->array_options['options_reseller']);
$arraywithdiff = $this->objCompare($localobject,$newlocalobject,true,array('newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','ref','statut','paye','specimen','facnumber','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement','cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva','multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx'));
$this->assertEquals($arraywithdiff, array()); // Actual, Expected
return $localobject; return $localobject;
} }