diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index e4f9fa1dd90..32995bce38f 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -379,7 +379,7 @@ $tabrowid[9] = "code_iso"; $tabrowid[10]= ""; $tabrowid[11]= "rowid"; $tabrowid[12]= ""; -$tabrowid[13]= ""; +$tabrowid[13]= "id"; $tabrowid[14]= ""; $tabrowid[15]= ""; $tabrowid[16]= "code"; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index af7d29c0fd6..c63ff44c32b 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -556,7 +556,7 @@ foreach ($fieldsforcontent as $tmpfieldlist) print ''; } else if ($tmpfieldlist == 'joinfiles') { - print ''; + print ''; } else { diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 79b9d30d948..c361d275882 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1327,7 +1327,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day); $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0 - $nextindextouse=count($colorindexused); // At first run this is 0, so first user has 0, next 1, ... + $nextindextouse=is_array($colorindexused)?count($colorindexused):0; // At first run this is 0, so fist user has 0, next 1, ... //var_dump($colorindexused); foreach ($eventarray as $daykey => $notused) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d5835f96781..45e94d1e5d3 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4730,7 +4730,7 @@ else if ($id > 0 || ! empty($ref)) } // For situation invoice with excess received - if ($object->statut == Facture::STATUS_VALIDATED + if ($object->statut > Facture::STATUS_DRAFT && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0 && $user->rights->facture->creer && !$objectidnext @@ -4748,7 +4748,7 @@ else if ($id > 0 || ! empty($ref)) } // remove situation from cycle - if ($object->statut == Facture::STATUS_VALIDATED + if ($object->statut > Facture::STATUS_DRAFT && $object->type == Facture::TYPE_SITUATION && $user->rights->facture->creer && !$objectidnext diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 71123d1c6e2..a82f06ad851 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -984,6 +984,7 @@ class FactureRec extends CommonInvoice $error=0; $langs->load("bills"); + $langs->load('main'); $nb_create=0; @@ -1060,6 +1061,8 @@ class FactureRec extends CommonInvoice } if (! $error && $facturerec->generate_pdf) { + // We refresh the object in order to have all necessary data (like date_lim_reglement) + $facture->fetch($facture->id); $result = $facture->generateDocument($facturerec->modelpdf, $langs); if ($result <= 0) { diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 59a901ccdf8..ebaef08c7b5 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -838,7 +838,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) $reshook=$hookmanager->executeHooks('printFieldListWhereCustomerUnpaid',$parameters); $sql.=$hookmanager->resPrint; - $sql.= " GROUP BY f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; + $sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code"; $sql.= " ORDER BY f.datef ASC, f.facnumber ASC"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4f62e40a0d5..81a51983daf 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3327,21 +3327,21 @@ class Form if ($resql && $this->db->num_rows($resql) > 0) { // Last seen cycle $ref = 0; - while ($res = $this->db->fetch_array($resql, MYSQL_NUM)) { + while ($obj = $this->db->fetch_object($resql)){ //Same company ? - if ($socid == $res[5]) { + if ($socid == $obj->fk_soc) { //Same cycle ? - if ($res[2] != $ref) { + if ($obj->situation_cycle_ref != $ref) { // Just seen this cycle - $ref = $res[2]; + $ref = $obj->situation_cycle_ref; //not final ? - if ($res[4] != 1) { + if ($obj->situation_final != 1) { //Not prov? - if (substr($res[1], 1, 4) != 'PROV') { - if ($selected == $res[0]) { - $opt .= ''; + if (substr($obj->facnumber, 1, 4) != 'PROV') { + if ($selected == $obj->situation_final) { + $opt .= ''; } else { - $opt .= ''; + $opt .= ''; } } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 485560a60d1..7fb0c645081 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -487,10 +487,10 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; } elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; } elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } - elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } + elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); } elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; } - elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } + elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; } elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); } elseif ($reg[1] == 'MYCOMPANY_COUNTRY_ID' || $reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID') { @@ -5520,7 +5520,7 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UT function dol_string_onlythesehtmltags($stringtoclean) { $allowed_tags = array( - "html", "head", "meta", "body", "b", "br", "div", "em", "font", "img", "ins", "hr", "i", "li", "link", + "html", "head", "meta", "body", "article", "a", "b", "br", "div", "em", "font", "img", "ins", "hr", "i", "li", "link", "ol", "p", "s", "section", "span", "strong", "title", "table", "tr", "th", "td", "u", "ul" ); @@ -6139,9 +6139,9 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); - $tmp3=dol_get_prev_month($tmp['mday'], $tmp['mon'], $tmp['year']); + $tmp3=dol_get_prev_month($tmp['mon'], $tmp['year']); $tmp4=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); - $tmp5=dol_get_next_month($tmp['mday'], $tmp['mon'], $tmp['year']); + $tmp5=dol_get_next_month($tmp['mon'], $tmp['year']); $substitutionarray=array_merge($substitutionarray, array( '__DAY__' => (string) $tmp['mday'], diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 68a2a8706b5..9294ff1a47e 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -550,7 +550,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($object->lines[$i]->remise_percent) { $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); - $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent."%", 0, 'R'); + $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R'); } // Total HT line diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index e57452ef8d3..b6f11828ffe 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -193,6 +193,21 @@ if ($action == 'presend') ); complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters); + // Find the good contact adress + $custcontact = ''; + $contactarr = array(); + $contactarr = $object->liste_contact(- 1, 'external'); + + if (is_array($contactarr) && count($contactarr) > 0) { + require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + $contactstatic = new Contact($db); + + foreach ($contactarr as $contact) { + $contactstatic->fetch($contact['id']); + $substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($langs, 1); + } + } + // Tableau des substitutions $formmail->substit = $substitutionarray; diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 4da1c8cf408..8710b340622 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -51,6 +51,9 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename, ent DROP TABLE llx_c_accountancy_category; DROP TABLE llx_c_accountingaccount; +-- drop old postgresql unique key +-- VPGSQL8.2 DROP INDEX llx_usergroup_rights_fk_usergroup_fk_id_key + update llx_propal set fk_statut = 1 where fk_statut = -1; ALTER TABLE llx_inventory ADD COLUMN fk_user_creat integer; diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 0c3edfaebd3..c51f8c8d1b1 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1078,15 +1078,28 @@ if ($ok && GETPOST('force_utf8_on_tables','alpha')) if ($db->type == "mysql" || $db->type == "mysqli") { - $listoftables = $db->DDLListTables($db->database_name); + $force_utf8_on_tables = GETPOST('force_utf8_on_tables','alpha'); + + $listoftables = $db->DDLListTables($db->database_name); + + // Disable foreign key checking for avoid errors + if ($force_utf8_on_tables == 'confirmed') + { + $sql='SET FOREIGN_KEY_CHECKS=0'; + print ''; + $resql = $db->query($sql); + } foreach($listoftables as $table) { + // do not convert llx_const if mysql encrypt/decrypt is used + if ($conf->db->dolibarr_main_db_encryption != 0 && preg_match('/\_const$/', $table)) continue; + print '