2
0
forked from Wavyzz/dolibarr

Merge branch '9.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/comm/card.php
	htdocs/core/modules/mailings/xinputfile.modules.php
	htdocs/fourn/facture/card.php
This commit is contained in:
Laurent Destailleur
2019-03-02 19:13:37 +01:00
10 changed files with 77 additions and 55 deletions

View File

@@ -2774,9 +2774,13 @@ class Adherent extends CommonObject
{ {
$adherent->fetch_thirdparty(); $adherent->fetch_thirdparty();
// Language code to use ($languagecodeformember) is default language of thirdparty, if no thirdparty, the language found from country of member then country of thirdparty, and if still not found we use the language of company.
$languagefromcountrycode = getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
$languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
// Send reminder email // Send reminder email
$outputlangs = new Translate('', $conf); $outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang); $outputlangs->setDefaultLang($languagecodeformember);
$outputlangs->loadLangs(array("main", "members")); $outputlangs->loadLangs(array("main", "members"));
dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang." mysoc->default_lang=".$mysoc->default_lang); dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang." mysoc->default_lang=".$mysoc->default_lang);

View File

@@ -378,38 +378,43 @@ if ($object->id > 0)
print '</tr>'; print '</tr>';
} }
// Relative discounts (Discounts-Drawbacks-Rebates) $isCustomer = ($object->client == 1 || $object->client == 3);
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans("CustomerRelativeDiscountShort");
print '<td><td class="right">';
if ($user->rights->societe->creer && !$user->societe_id > 0)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td><td>'.($object->remise_percent?'<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_percent.'%</a>':'').'</td>';
print '</tr>';
// Absolute discounts (Discounts-Drawbacks-Rebates) // Relative discounts (Discounts-Drawbacks-Rebates)
print '<tr><td class="nowrap">'; if ($isCustomer)
print '<table width="100%" class="nobordernopadding">';
print '<tr><td class="nowrap">';
print $langs->trans("CustomerAbsoluteDiscountShort");
print '<td><td class="right">';
if ($user->rights->societe->creer && !$user->societe_id > 0)
{ {
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.img_edit($langs->trans("Modify")).'</a>'; print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans("CustomerRelativeDiscountShort");
print '<td><td align="right">';
if ($user->rights->societe->creer && !$user->societe_id > 0)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td><td>'.($object->remise_percent?'<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_percent.'%</a>':'').'</td>';
print '</tr>';
// Absolute discounts (Discounts-Drawbacks-Rebates)
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding">';
print '<tr><td class="nowrap">';
print $langs->trans("CustomerAbsoluteDiscountShort");
print '<td><td align="right">';
if ($user->rights->societe->creer && !$user->societe_id > 0)
{
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td>';
print '<td>';
$amount_discount=$object->getAvailableDiscounts();
if ($amount_discount < 0) dol_print_error($db,$object->error);
if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).'</a>';
//else print $langs->trans("DiscountNone");
print '</td>';
print '</tr>';
} }
print '</td></tr></table>';
print '</td>';
print '<td>';
$amount_discount=$object->getAvailableDiscounts();
if ($amount_discount < 0) dol_print_error($db, $object->error);
if ($amount_discount > 0) print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?socid='.$object->id).'">'.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).'</a>';
//else print $langs->trans("DiscountNone");
print '</td>';
print '</tr>';
// Max outstanding bill // Max outstanding bill
if ($object->client) if ($object->client)

View File

@@ -106,7 +106,7 @@ if ($socid > 0)
$head = societe_prepare_head($object); $head = societe_prepare_head($object);
$isCustomer = $object->client == 1 || $object->client == 3; $isCustomer = ($object->client == 1 || $object->client == 3);
$isSupplier = $object->fournisseur == 1; $isSupplier = $object->fournisseur == 1;
print '<form method="POST" action="remise.php?id='.$object->id.'">'; print '<form method="POST" action="remise.php?id='.$object->id.'">';
@@ -122,7 +122,7 @@ if ($socid > 0)
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
if(! $isCustomer && ! $isSupplier) { if (! $isCustomer && ! $isSupplier) {
print '<p class="opacitymedium">'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'</p>'; print '<p class="opacitymedium">'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'</p>';
dol_fiche_end(); dol_fiche_end();
@@ -137,13 +137,13 @@ if ($socid > 0)
print '<table class="border centpercent">'; print '<table class="border centpercent">';
if($isCustomer) { if ($isCustomer) {
// Customer discount // Customer discount
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>"; print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>";
} }
if($isSupplier) { if ($isSupplier) {
// Supplier discount // Supplier discount
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans("SupplierRelativeDiscount").'</td><td>'.price2num($object->remise_supplier_percent)."%</td></tr>"; print $langs->trans("SupplierRelativeDiscount").'</td><td>'.price2num($object->remise_supplier_percent)."%</td></tr>";
@@ -156,21 +156,28 @@ if ($socid > 0)
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
if($isCustomer && ! $isSupplier) { /*if (! ($isCustomer && $isSupplier))
print '<input type="hidden" name="discount_type" value="0" />'; {
} if ($isCustomer && ! $isSupplier) {
print '<input type="hidden" name="discount_type" value="0" />';
if(! $isCustomer && $isSupplier) { }
print '<input type="hidden" name="discount_type" value="1" />'; if (! $isCustomer && $isSupplier) {
} print '<input type="hidden" name="discount_type" value="1" />';
}
}*/
print '<table class="border centpercent">'; print '<table class="border centpercent">';
if($isCustomer && $isSupplier) { if ($isCustomer || $isSupplier)
{
// Discount type // Discount type
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td>'; print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td><td>';
print '<td><input type="radio" name="discount_type" id="discount_type_0" selected value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>'; if ($isCustomer) {
print ' <input type="radio" name="discount_type" id="discount_type_1" selected value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>'; print '<input type="radio" name="discount_type" id="discount_type_0" checked value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>';
}
if ($isSupplier) {
print ' <input type="radio" name="discount_type" id="discount_type_1"'.($isCustomer?'':' checked').' value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>';
}
print '</td></tr>'; print '</td></tr>';
} }

View File

@@ -6831,7 +6831,8 @@ function picto_from_langcode($codelang, $moreatt = '')
} }
/** /**
* Return default language from country code * Return default language from country code.
* Return null if not found.
* *
* @param string $countrycode Country code like 'US', 'FR', 'CA', ... * @param string $countrycode Country code like 'US', 'FR', 'CA', ...
* @return string Value of locale like 'en_US', 'fr_FR', ... * @return string Value of locale like 'en_US', 'fr_FR', ...
@@ -6840,6 +6841,8 @@ function getLanguageCodeFromCountryCode($countrycode)
{ {
global $mysoc; global $mysoc;
if (empty($countrycode)) return null;
if (strtoupper($countrycode) == 'MQ') return 'fr_CA'; if (strtoupper($countrycode) == 'MQ') return 'fr_CA';
if (strtoupper($countrycode) == 'SE') return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country if (strtoupper($countrycode) == 'SE') return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country
if (strtoupper($countrycode) == 'CH') if (strtoupper($countrycode) == 'CH')

View File

@@ -200,8 +200,8 @@ class MailingTargets // This can't be abstract as it is used for some method
if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
// Si erreur autre que doublon // Si erreur autre que doublon
dol_syslog($this->db->error()); dol_syslog($this->db->error().' : '.$targetarray['email']);
$this->error=$this->db->error(); $this->error=$this->db->error().' : '.$targetarray['email'];
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }

View File

@@ -180,7 +180,9 @@ class mailing_xinputfile extends MailingTargets
{ {
$i++; $i++;
$langs->load("errors"); $langs->load("errors");
$this->error = $langs->trans("ErrorFoundBadEmailInFile", $i, $cpt, $email); $msg = $langs->trans("ErrorFoundBadEmailInFile", $i, $cpt, $email);
if (! empty($msg)) $this->error = $msg;
else $this->error = 'ErrorFoundBadEmailInFile '.$i.' '.$cpt.' '.$email; // We experience case where $langs->trans return an empty string.
} }
} }
} }

View File

@@ -398,7 +398,7 @@ class modAgenda extends DolibarrModules
$this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date", $this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date",
'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric", 'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric",
'ac.durationp'=>"Duree", 'ac.durationp'=>"Duree",
'cac.libelle'=>"List:c_actioncomm:libelle:id", 'cac.libelle'=>"List:c_actioncomm:libelle:libelle",
's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text', 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text',
'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text', 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text',
's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text'); 's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text');

View File

@@ -484,7 +484,7 @@ $sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " state.code_departement as state_code, state.nom as state_name,";
$sql.= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,"; $sql.= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,";
$sql.= ' cf.date_creation as date_creation, cf.tms as date_update,'; $sql.= ' cf.date_creation as date_creation, cf.tms as date_update,';
$sql.= " p.rowid as project_id, p.ref as project_ref,"; $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,";
$sql.= " u.firstname, u.lastname, u.photo, u.login"; $sql.= " u.firstname, u.lastname, u.photo, u.login";
// Add fields from extrafields // Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
@@ -972,6 +972,7 @@ if ($resql)
{ {
$projectstatic->id=$obj->project_id; $projectstatic->id=$obj->project_id;
$projectstatic->ref=$obj->project_ref; $projectstatic->ref=$obj->project_ref;
$projectstatic->title=$obj->project_title;
print '<td>'; print '<td>';
if ($obj->project_id > 0) print $projectstatic->getNomUrl(1); if ($obj->project_id > 0) print $projectstatic->getNomUrl(1);
print '</td>'; print '</td>';

View File

@@ -426,7 +426,7 @@ if (empty($reshook))
//var_dump($object->getRemainToPay(0)); //var_dump($object->getRemainToPay(0));
//var_dump($discount->amount_ttc);exit; //var_dump($discount->amount_ttc);exit;
if ($discount->amount_ttc > $object->getRemainToPay(0)) if (price2num($discount->amount_ttc) > price2num($object->getRemainToPay(0)))
{ {
// TODO Split the discount in 2 automatically // TODO Split the discount in 2 automatically
$error++; $error++;
@@ -776,7 +776,7 @@ if (empty($reshook))
$totaldeposits = $facture_source->getSumDepositsUsed(); $totaldeposits = $facture_source->getSumDepositsUsed();
$remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits); $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits);
$object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 1, 0, 0, 0, 0, 0, '', '', 'TTC'); $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 0, 0, 0, 1, 0, 0, '', '', 'TTC');
} }
} }
} }

View File

@@ -888,7 +888,7 @@ if ($action == 'create' || $action == 'adduserldap')
print '<td>'; print '<td>';
print $form->selectyesno('admin', GETPOST('admin'), 1); print $form->selectyesno('admin', GETPOST('admin'), 1);
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) if (! empty($conf->multicompany->enabled) && ! $user->entity)
{ {
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
@@ -2117,7 +2117,7 @@ else
{ {
print $form->selectyesno('admin', $object->admin, 1); print $form->selectyesno('admin', $object->admin, 1);
if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) if (! empty($conf->multicompany->enabled) && ! $user->entity)
{ {
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {