Skip to content

Commit

Permalink
Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed May 11, 2023
2 parents 3b85aa7 + 2f6b95c commit c6cb293
Show file tree
Hide file tree
Showing 25 changed files with 218 additions and 76 deletions.
6 changes: 5 additions & 1 deletion htdocs/admin/translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,11 @@
} else {
// Now search into translation array
foreach ($newlang->tab_translate as $key => $val) {
if ($transkey && !preg_match('/'.preg_quote($transkey, '/').'/i', $key)) {
$newtranskey = preg_replace('/\$$/', '', preg_replace('/^\^/', '', $transkey));
$newtranskeystart = preg_match('/^\^/', $transkey);
$newtranskeyend = preg_match('/\$$/', $transkey);
$regexstring = ($newtranskeystart ? '^' : '').preg_quote($newtranskey, '/').($newtranskeyend ? '$' : '');
if ($transkey && !preg_match('/'.$regexstring.'/i', $key)) {
continue;
}
if ($transvalue && !preg_match('/'.preg_quote($transvalue, '/').'/i', $val)) {
Expand Down
6 changes: 3 additions & 3 deletions htdocs/comm/propal/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1889,7 +1889,7 @@
// Source / Channel - What trigger creation
print '<tr class="field_demand_reason_id"><td class="titlefieldcreate">'.$langs->trans('Source').'</td><td class="valuefieldcreate">';
print img_picto('', 'question', 'class="pictofixedwidth"');
$form->selectInputReason('', 'demand_reason_id', "SRC_PROP", 1, 'maxwidth200 widthcentpercentminusx');
$form->selectInputReason((GETPOSTISSET('demand_reason_id') ? GETPOST('demand_reason_id', 'int') : ''), 'demand_reason_id', "SRC_PROP", 1, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';

// Delivery delay
Expand All @@ -1899,7 +1899,7 @@
}
print '</td><td class="valuefieldcreate">';
print img_picto('', 'clock', 'class="pictofixedwidth"');
$form->selectAvailabilityDelay('', 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx');
$form->selectAvailabilityDelay((GETPOSTISSET('availability_id') ? GETPOST('availability_id', 'int') : ''), 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';

// Shipping Method
Expand All @@ -1909,7 +1909,7 @@
}
print '<tr class="field_shipping_method_id"><td class="titlefieldcreate">'.$langs->trans('SendingMethod').'</td><td class="valuefieldcreate">';
print img_picto('', 'dolly', 'class="pictofixedwidth"');
$form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx');
$form->selectShippingMethod((GETPOSTISSET('shipping_method_id') ? GETPOST('shipping_method_id', 'int') : $shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
}

Expand Down
19 changes: 10 additions & 9 deletions htdocs/commande/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1658,10 +1658,10 @@
if (!$remise_percent) {
$remise_percent = $soc->remise_percent;
}
if (!$dateorder) {
/*if (!$dateorder) {
// Do not set 0 here (0 for a date is 1970)
$dateorder = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE_ORDER) ?-1 : '') : $dateorder);
}
}*/
} else {
// For compatibility
if ($element == 'order' || $element == 'commande') {
Expand Down Expand Up @@ -1760,7 +1760,7 @@
print '<form name="crea_commande" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n";
print '<input type="hidden" name="changecompany" value="0">'; // will be set to 1 by javascript so we know post is done after a company change
print '<input type="hidden" name="remise_percent" value="'.$soc->remise_percent.'">';
print '<input type="hidden" name="origin" value="'.$origin.'">';
print '<input type="hidden" name="originid" value="'.$originid.'">';
Expand Down Expand Up @@ -1806,6 +1806,7 @@
var socid = $(this).val();
// reload page
$("input[name=action]").val("create");
$("input[name=changecompany]").val("1");
$("form[name=crea_commande]").submit();
});
});
Expand Down Expand Up @@ -1855,33 +1856,33 @@
// Delivery delay
print '<tr class="fielddeliverydelay"><td>'.$langs->trans('AvailabilityPeriod').'</td><td>';
print img_picto('', 'clock', 'class="pictofixedwidth"');
$form->selectAvailabilityDelay((GETPOSTISSET('availability_id')?GETPOST('availability_id'):$availability_id), 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx');
$form->selectAvailabilityDelay((GETPOSTISSET('availability_id') ? GETPOST('availability_id') : $availability_id), 'availability_id', '', 1, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';

// Terms of payment
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
print img_picto('', 'payment', 'class="pictofixedwidth"');
print $form->getSelectConditionsPaiements(((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0)?GETPOST('cond_reglement_id'):$cond_reglement_id), 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent);
print $form->getSelectConditionsPaiements(((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id', 'int') != 0) ? GETPOST('cond_reglement_id') : $cond_reglement_id), 'cond_reglement_id', 1, 1, 0, 'maxwidth200 widthcentpercentminusx', $deposit_percent);
print '</td></tr>';

// Payment mode
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
print img_picto('', 'bank', 'class="pictofixedwidth"');
print $form->select_types_paiements(((GETPOSTISSET('mode_reglement_id') && GETPOST('mode_reglement_id') != 0)?GETPOST('mode_reglement_id'):$mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1);
print $form->select_types_paiements(((GETPOSTISSET('mode_reglement_id') && GETPOST('mode_reglement_id', 'int') != 0) ? GETPOST('mode_reglement_id') : $mode_reglement_id), 'mode_reglement_id', 'CRDT', 0, 1, 0, 0, 1, 'maxwidth200 widthcentpercentminusx', 1);
print '</td></tr>';

// Bank Account
if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && isModEnabled("banque")) {
print '<tr><td>'.$langs->trans('BankAccount').'</td><td>';
print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes((GETPOSTISSET('fk_account')?GETPOST('fk_account'):$fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1);
print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes(((GETPOSTISSET('fk_account') && GETPOST('fk_account', 'int') != 0) ? GETPOST('fk_account') : $fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1);
print '</td></tr>';
}

// Shipping Method
if (isModEnabled('expedition')) {
print '<tr><td>'.$langs->trans('SendingMethod').'</td><td>';
print img_picto('', 'dolly', 'class="pictofixedwidth"');
$form->selectShippingMethod((GETPOSTISSET('shipping_method_id')?GETPOST('shipping_method_id'):$shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx');
print img_picto('', 'object_dolly', 'class="pictofixedwidth"');
$form->selectShippingMethod(((GETPOSTISSET('shipping_method_id') && GETPOST('shipping_method_id', 'int') != 0) ? GETPOST('shipping_method_id') : $shipping_method_id), 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx');
print '</td></tr>';
}

Expand Down
7 changes: 3 additions & 4 deletions htdocs/compta/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -2449,15 +2449,15 @@
print '<td class="right nowrap">'.price($marginInfo['pa_total'], 0, $langs, 1, -1, 'MT').'</td>';
if (!$i) {
$totalarray['nbfield']++;
$totalarray['pos'][$totalarray['nbfield']] = 'total_pa';
}
$totalarray['val']['total_pa'] += $marginInfo['pa_total'];
}
// Total margin
if (!empty($arrayfields['total_margin']['checked'])) {
print '<td class="right nowrap">'.price($marginInfo['total_margin'], 0, $langs, 1, -1, 'MT').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'total_margin';
}
$totalarray['val']['total_margin'] += $marginInfo['total_margin'];
Expand All @@ -2474,8 +2474,6 @@
print '<td class="right nowrap">'.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').'</td>';
if (!$i) {
$totalarray['nbfield']++;
}
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate';
}
if ($i >= $imaxinloop - 1) {
Expand Down Expand Up @@ -2589,6 +2587,7 @@
}

// Use correct digits number for totals
$totalarray['val']['total_pa'] = (isset($totalarray['val']['total_pa']) ? price2num($totalarray['val']['total_pa'], 'MT') : null);
$totalarray['val']['total_margin'] = (isset($totalarray['val']['total_margin']) ? price2num($totalarray['val']['total_margin'], 'MT') : null);

// Show total line
Expand Down
38 changes: 22 additions & 16 deletions htdocs/core/actions_massactions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@
$oneemailperrecipient = (GETPOST('oneemailperrecipient', 'int') ? 1 : 0);

if (!$error) {
$thirdparty = new Societe($db);

$objecttmp = new $objectclass($db);

// Define object $thirdparty (Societe or User, Adherent, ConferenceOrBoothAttendee...)
$thirdparty = new Societe($db);
if ($objecttmp->element == 'expensereport') {
$thirdparty = new User($db);
} elseif ($objecttmp->element == 'contact') {
Expand All @@ -99,28 +100,31 @@
$thirdparty = new Adherent($db);
} elseif ($objecttmp->element == 'holiday') {
$thirdparty = new User($db);
} elseif ($objecttmp->element == 'conferenceorboothattendee') {
$thirdparty = new ConferenceOrBoothAttendee($db);
}

foreach ($toselect as $toselectid) {
$objecttmp = new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use
$result = $objecttmp->fetch($toselectid);
if ($result > 0) {
$listofobjectid[$toselectid] = $toselectid;

$thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
$tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid);
if ($objecttmp->element == 'societe') {
$thirdpartyid = $objecttmp->id;
$tmpobjectid = $objecttmp->id;
} elseif ($objecttmp->element == 'contact') {
$thirdpartyid = $objecttmp->id;
$tmpobjectid = $objecttmp->id;
} elseif ($objecttmp->element == 'expensereport') {
$thirdpartyid = $objecttmp->fk_user_author;
$tmpobjectid = $objecttmp->fk_user_author;
} elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
$thirdpartyid = $objecttmp->fk_member;
$tmpobjectid = $objecttmp->fk_member;
} elseif ($objecttmp->element == 'holiday') {
$thirdpartyid = $objecttmp->fk_user;
$tmpobjectid = $objecttmp->fk_user;
} elseif ($objecttmp->element == 'conferenceorboothattendee') {
$tmpobjectid = $objecttmp->id;
}
if (empty($thirdpartyid)) {
$thirdpartyid = 0;
if (empty($tmpobjectid)) {
$tmpobjectid = 0;
}

if ($objectclass == 'Facture') {
Expand All @@ -141,8 +145,8 @@
}
}

$listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
$listofobjectref[$thirdpartyid][$toselectid] = $objecttmp;
$listofobjectthirdparties[$tmpobjectid] = $tmpobjectid;
$listofobjectref[$tmpobjectid][$toselectid] = $objecttmp;
}
}
}
Expand Down Expand Up @@ -174,7 +178,7 @@
$massaction = 'presend';
}

// Loop on each recipient/thirdparty
// Loop on each recipient (may be a thirdparty but also a user, a conferenceorboothattendee, ...)
if (!$error) {
foreach ($listofobjectthirdparties as $thirdpartyid) {
$result = $thirdparty->fetch($thirdpartyid);
Expand All @@ -186,7 +190,7 @@
$sendto = '';
$sendtocc = '';
$sendtobcc = '';
$sendtoid = array();
//$sendtoid = array();

// Define $sendto
$tmparray = array();
Expand All @@ -201,7 +205,7 @@
$tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>';
} elseif ($val && method_exists($thirdparty, 'contact_get_property')) { // Id of contact
$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
$sendtoid[] = $val;
//$sendtoid[] = $val;
}
}
}
Expand Down Expand Up @@ -305,6 +309,8 @@
if (count($emails_to_sends) > 0) {
$sendto = implode(',', $emails_to_sends);
}
} elseif ($objectobj->element == 'conferenceorboothattendee') {
$sendto = $objectobj->email;
} else {
$objectobj->fetch_thirdparty();
$sendto = $objectobj->thirdparty->email;
Expand Down
4 changes: 4 additions & 0 deletions htdocs/core/class/html.formmail.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,10 @@ public function get_form($addfileaction = 'addfile', $removefileaction = 'remove
$helpforsubstitution .= $langs->trans('AvailableVariables').' :<br><br><span class="small">'."\n";
}
foreach ($this->substit as $key => $val) {
// Do not show deprecated variables into the tooltip help of substitution variables
if (in_array($key, array('__NEWREF__', '__REFCLIENT__', '__REFSUPPLIER__', '__SUPPLIER_ORDER_DATE_DELIVERY__', '__SUPPLIER_ORDER_DELAY_DELIVERY__'))) {
continue;
}
$helpforsubstitution .= $key.' -> '.$langs->trans(dol_string_nohtmltag(dolGetFirstLineOfText($val))).'<br>';
}
if (is_array($this->substit) && count($this->substit)) {
Expand Down
3 changes: 2 additions & 1 deletion htdocs/core/class/html.formmargin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public function getMarginInfosArray($object, $force_price = false)
}

$pv = $line->total_ht;
$pa_ht = (($pv < 0 || ($pv == 0 && in_array($object->element, array('facture', 'facture_fourn')) && $object->type == $object::TYPE_CREDIT_NOTE)) ? -$line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign
// We choosed to have line->pa_ht always positive in database, so we guess the correct sign
$pa_ht = (($pv < 0 || ($pv == 0 && in_array($object->element, array('facture', 'facture_fourn')) && $object->type == $object::TYPE_CREDIT_NOTE)) ? -$line->pa_ht : $line->pa_ht);
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) { // Special case for old situation mode
if (($object->element == 'facture' && $object->type == $object::TYPE_SITUATION)
|| ($object->element == 'facture' && $object->type == $object::TYPE_CREDIT_NOTE && getDolGlobalInt('INVOICE_USE_SITUATION_CREDIT_NOTE') && $object->situation_counter > 0)) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/lib/admin.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function versiondolibarrarray()
* @param int $nocommentremoval Do no try to remove comments (in such a case, we consider that each line is a request, so use also $linelengthlimit=0)
* @param int $offsetforchartofaccount Offset to use to load chart of account table to update sql on the fly to add offset to rowid and account_parent value
* @param int $colspan 2=Add a colspan=2 on td
* @param int $onlysqltoimportwebsite Only sql resquests used to import a website template is allowed
* @param int $onlysqltoimportwebsite Only sql resquests used to import a website template are allowed
* @return int <=0 if KO, >0 if OK
*/
function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handler = '', $okerror = 'default', $linelengthlimit = 32768, $nocommentremoval = 0, $offsetforchartofaccount = 0, $colspan = 0, $onlysqltoimportwebsite = 0)
Expand Down
7 changes: 6 additions & 1 deletion htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -7869,7 +7869,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__DATE_DELIVERY_MM__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%M") : '');
$substitutionarray['__DATE_DELIVERY_SS__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, "%S") : '');

// For backward compatibility
// For backward compatibility (deprecated)
$substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));
$substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
$substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs) : '');
Expand Down Expand Up @@ -7963,6 +7963,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : '';
$substitutionarray['__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : '';
}
if (is_object($object) && $object->element == 'conferenceorboothattendee') {
$substitutionarray['__ATTENDEE_FULLNAME__'] = $object->getFullName($outputlangs);
$substitutionarray['__ATTENDEE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : '';
$substitutionarray['__ATTENDEE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : '';
}

if (is_object($object->project)) {
$substitutionarray['__PROJECT_ID__'] = (is_object($object->project) ? $object->project->id : '');
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/modules/DolibarrModules.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ public function insert_const()
$val = '';
}

$sql = "SELECT count(*)";
$sql = "SELECT count(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."const";
$sql .= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($name)."'";
$sql .= " AND entity = ".((int) $entity);
Expand All @@ -1771,7 +1771,7 @@ public function insert_const()
$err++;
}
} else {
dol_syslog(get_class($this)."::insert_const constant '".$name."' already exists", LOG_WARNING);
dol_syslog(get_class($this)."::insert_const constant '".$name."' already exists", LOG_DEBUG);
}
} else {
$err++;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/modAgenda.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct($db)
$this->numero = 2400;

$this->family = "projects";
$this->module_position = '15';
$this->module_position = '16';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Follow events or rendez-vous. Record manual events into Agendas or let application record automatic events for log tracking.";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/modCategorie.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct($db)
$this->numero = 1780;

$this->family = "technic";
$this->module_position = '20';
$this->module_position = '25';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Gestion des categories (produits, clients, fournisseurs...)";
Expand Down
Loading

0 comments on commit c6cb293

Please sign in to comment.