diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index ad3e863cc8c..f1815386624 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -557,7 +557,7 @@ class AccountancyExport $Tab['signe_montant'] = '+'; // The amount must be in centimes without decimal points. - $Tab['montant'] = str_pad(abs(($data->debit - $abs->credit) * 100), 12, '0', STR_PAD_LEFT); + $Tab['montant'] = str_pad(abs(($data->debit - $data->credit) * 100), 12, '0', STR_PAD_LEFT); $Tab['contrepartie'] = str_repeat(' ', 8); // Force date format : %d%m%y diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index e540d561d04..9b380b676b4 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -189,7 +189,7 @@ foreach ($dirmodels as $reldir) { if ($conf->global->PAYMENT_ADDON == $file || $conf->global->PAYMENT_ADDON.'.php' == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').''; } print ''; diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 0e7f2abe76d..9051ebfa921 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -616,6 +616,10 @@ class AdvanceTargetingMailing extends CommonObject if ($arrayquery['options_'.$key] != '') { $sqlwhere[] = " (te.".$key." = ".((int) $arrayquery['options_'.$key]).")"; } + } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { + if ($arrayquery['options_'.$key] > 0) { + $sqlwhere[]= " (te.".$key." = ".((int) $arrayquery['options_'.$key]).")"; + } } else { if (is_array($arrayquery['options_'.$key])) { $sqlwhere[] = " (te.".$key." IN (".$this->db->sanitize("'".implode("','", $arrayquery['options_'.$key])."'", 1)."))"; @@ -642,7 +646,6 @@ class AdvanceTargetingMailing extends CommonObject if ($num) { while ($i < $num) { $obj = $this->db->fetch_object($resql); - $this->thirdparty_lines[$i] = $obj->rowid; $i++; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index d43e1a2c84b..3fe796adb96 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -110,27 +110,71 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture $db->commit(); // Loop on each invoice linked to this payment to rebuild PDF - $factures = array(); - foreach ($factures as $id) { - $fac = new Facture($db); - $fac->fetch($id); + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $outputlangs = $langs; + if (GETPOST('lang_id', 'aZ09')) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang(GETPOST('lang_id', 'aZ09')); + } - $outputlangs = $langs; - if (!empty($_REQUEST['lang_id'])) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $fac->generateDocument($fac->model_pdf, $outputlangs); - } + $hidedetails = ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0; + $hidedesc = ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0; + $hideref = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0; + + $sql = 'SELECT f.rowid as facid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf,'.MAIN_DB_PREFIX.'facture as f,'.MAIN_DB_PREFIX.'societe as s'; + $sql .= ' WHERE pf.fk_facture = f.rowid'; + $sql .= ' AND f.fk_soc = s.rowid'; + $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; + $sql .= ' AND pf.fk_paiement = '.$object->id; + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $num = $db->num_rows($resql); + + if ($num > 0) + { + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $invoice = new Facture($db); + + if ($invoice->fetch($objp->facid) <= 0) { + $errors++; + setEventMessages($invoice->error, $invoice->errors, 'errors'); + break; + } + + if ($invoice->generateDocument($invoice->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref) < 0) { + $errors++; + setEventMessages($invoice->error, $invoice->errors, 'errors'); + break; + } + + $i++; + } + } + + $db->free($resql); + } + else + { + $errors++; + setEventMessages($db->error, $db->errors, 'errors'); + } } - header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); - exit; + if (! $errors) { + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); + exit; + } } else { + $db->rollback(); + $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); - $db->rollback(); } } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 5647295d171..dff546fa827 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -413,8 +413,15 @@ class Paiement extends CommonObject $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } + + $hidedetails = ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0; + $hidedesc = ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0; + $hideref = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0; + $ret = $invoice->fetch($facid); // Reload to get new records - $result = $invoice->generateDocument($invoice->model_pdf, $outputlangs); + + $result = $invoice->generateDocument($invoice->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) { setEventMessages($invoice->error, $invoice->errors, 'errors'); $error++; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 168a1e499bd..e104b01a9ae 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -297,7 +297,7 @@ class FormFile $out .= "\n\n"; } - $parameters = array('socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'url'=>$url, 'perm'=>$perm); + $parameters = array('socid'=>(isset($GLOBALS['socid']) ? $GLOBALS['socid'] : ''), 'id'=>(isset($GLOBALS['id']) ? $GLOBALS['id'] : ''), 'url'=>$url, 'perm'=>$perm, 'options'=>$options); $res = $hookmanager->executeHooks('formattachOptions', $parameters, $object); if (empty($res)) { print '