diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 55584df6445..1e757b72f63 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -50,7 +50,7 @@ llxHeader(); print load_fiche_titre($langs->trans("PerfDolibarr"),'','title_setup'); -print $langs->trans("YouMayFindPerfAdviceHere",'http://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' ('.$langs->trans("Reload").')
'; +print $langs->trans("YouMayFindPerfAdviceHere",'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' ('.$langs->trans("Reload").')
'; // Recupere la version de PHP $phpversion=version_php(); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 343bbbe6414..a06c1ccfa20 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2730,14 +2730,15 @@ class Facture extends CommonInvoice // 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. + if ($result > 0) { $this->db->commit(); - return $this->line->rowid; + return $this->line->id; } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); $this->db->rollback(); return -1; } @@ -4482,11 +4483,11 @@ class FactureLigne extends CommonInvoiceLine $resql=$this->db->query($sql); 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 { - $this->id=$this->rowid; $result=$this->insertExtraFields(); if ($result < 0) { @@ -4558,12 +4559,12 @@ class FactureLigne extends CommonInvoiceLine } $this->db->commit(); - return $this->rowid; + return $this->id; } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); $this->db->rollback(); return -2; } diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 713cab1dc13..e04f4d83ee8 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -369,7 +369,8 @@ if (! is_array($x_coll) || ! is_array($x_paye)) foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) { // 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 // was not saved. 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->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); 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 @@ -423,7 +424,7 @@ if (! is_array($x_coll) || ! is_array($x_paye)) $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 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) { // 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 // was not saved. 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->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); 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 @@ -595,7 +597,16 @@ if (! is_array($x_coll) || ! is_array($x_paye)) } else { $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 print_date_range($fields['ddate_start'],$fields['ddate_end']); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 103b52f48f1..82cc919346b 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -97,7 +97,7 @@ class Conf // First level object // TODO Remove this part. $this->expedition_bon = new stdClass(); - $this->livraison_bon = new stdClass(); + $this->livraison_bon = new stdClass(); $this->fournisseur = new stdClass(); $this->product = new stdClass(); $this->service = new stdClass(); @@ -107,12 +107,12 @@ class Conf $this->propal = new stdClass(); $this->facture = new stdClass(); $this->contrat = new stdClass(); - $this->usergroup = new stdClass(); + $this->usergroup = new stdClass(); $this->adherent = new stdClass(); $this->bank = new stdClass(); $this->notification = new stdClass(); $this->mailing = new stdClass(); - $this->expensereport = new stdClass(); + $this->expensereport = new stdClass(); $this->productbatch = new stdClass(); } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 50386e277a1..e64271b7c0e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -867,7 +867,7 @@ class FormFile } 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); } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 0dd843813e8..a73422a8499 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1266,8 +1266,11 @@ class FormMail extends Form $product = new Product($this->db); $product->fetch($line->fk_product, '', '', 1); $product->fetch_optionals(); - foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) { - $substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key]; + if (is_array($extrafieldstmp->attributes[$object->table_element]['label']) && count($extrafieldstmp->attributes[$object->table_element]['label']) > 0) + { + 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; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6732c358c99..171fa3f98c8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5792,7 +5792,7 @@ function dol_concatdesc($text1,$text2,$forxml=false) */ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null) { - global $db, $conf, $mysoc, $user; + global $db, $conf, $mysoc, $user, $extrafields; $substitutionarray=array(); @@ -5964,13 +5964,17 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob // Create dynamic tags for __EXTRAFIELD_FIELD__ if ($object->table_element && $object->id > 0) { - $extrafieldstmp = new ExtraFields($db); - $extralabels = $extrafieldstmp->fetch_name_optionals_label($object->table_element, true); - 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_object($extrafields)) $extrafields = new ExtraFields($db); + $extrafields->fetch_name_optionals_label($object->table_element, true); + + if ($object->fetch_optionals() > 0) + { + 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]; + } + } } } diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 26c31a4eee0..99737322267 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -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"; } - //print $sql.'
'; if (! $sql) return -1; if ($sql == 'TODO') return -2; if ($sql != 'TODO') diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 69cd2a3bc79..a641f0c724f 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -429,3 +429,11 @@ drop table tmp_bank_url_expense_user; -- 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) + +-- 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); + diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 9c2d8408a7d..79fead3c51d 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -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]); $setuplang=GETPOST('selectlang','aZ09',3)?GETPOST('selectlang','aZ09',3):(empty($argv[3])?'auto':$argv[3]); $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 // or MAIN_VERSION_LAST_UPGRADE for upgrade. diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 1ed34d5681c..5c3e5f2ae96 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -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']); } // 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) { @@ -439,9 +439,12 @@ print ''."\n"; // Detect if we need a fetch on each output line $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 + } } diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index d3e202f33c2..2fe0b751e1f 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -216,7 +216,13 @@ class FactureTest extends PHPUnit_Framework_TestCase $newlocalobject=new Facture($this->savdb); $newlocalobject->initAsSpecimen(); $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; }