Skip to content

Commit

Permalink
Merge branch '20.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 Jul 2, 2024
2 parents 9ffa864 + 63f2631 commit 7a73231
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 106 deletions.
8 changes: 4 additions & 4 deletions htdocs/compta/prelevement/class/bonprelevement.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public function getErrorString($error)
*
* @param int $rowid Id of object to load
* @param string $ref Ref of direct debit
* @return int >0 if OK, <0 if KO
* @return int >0 if OK, 0=Not found, <0 if KO
*/
public function fetch($rowid, $ref = '')
{
Expand Down Expand Up @@ -448,11 +448,11 @@ public function fetch($rowid, $ref = '')

return 1;
} else {
dol_syslog(get_class($this) . "::Fetch Erreur aucune ligne retournee");
return -1;
dol_syslog(get_class($this) . "::Fetch no record found");
return 0;
}
} else {
return -2;
return -1;
}
}

Expand Down
168 changes: 86 additions & 82 deletions htdocs/compta/prelevement/factures.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,112 +94,116 @@
llxHeader('', $langs->trans("WithdrawalsReceipts"));

if ($id > 0 || $ref) {
if ($object->fetch($id, $ref) >= 0) {
$head = prelevement_prepare_head($object);
$object->fetch($id, $ref);
if (empty($object->id)) {
$langs->load('errors');
echo '<div class="error">'.$langs->trans("ErrorRecordNotFound").'</div>';
llxFooter();
exit;
}

print dol_get_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
$head = prelevement_prepare_head($object);

$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/orders_list.php?restore_lastsearch_values=1'.($object->type != 'bank-transfer' ? '' : '&type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
print dol_get_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment');

dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/orders_list.php?restore_lastsearch_values=1'.($object->type != 'bank-transfer' ? '' : '&type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';

print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'."\n";
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');

//print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
print '<tr><td class="titlefieldcreate">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount).'</span></td></tr>';
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'."\n";

if (!empty($object->date_trans)) {
$muser = new User($db);
$muser->fetch($object->user_trans);
//print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
print '<tr><td class="titlefieldcreate">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount).'</span></td></tr>';

print '<tr><td>'.$langs->trans("TransData").'</td><td>';
print dol_print_date($object->date_trans, 'day');
print ' &nbsp; <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getNomUrl(-1).'</td></tr>';
print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
print $object->methodes_trans[$object->method_trans];
print '</td></tr>';
}
if (!empty($object->date_credit)) {
print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
print dol_print_date($object->date_credit, 'day');
print '</td></tr>';
}
if (!empty($object->date_trans)) {
$muser = new User($db);
$muser->fetch($object->user_trans);

print '</table>';
print '<tr><td>'.$langs->trans("TransData").'</td><td>';
print dol_print_date($object->date_trans, 'day');
print ' &nbsp; <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getNomUrl(-1).'</td></tr>';
print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
print $object->methodes_trans[$object->method_trans];
print '</td></tr>';
}
if (!empty($object->date_credit)) {
print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
print dol_print_date($object->date_credit, 'day');
print '</td></tr>';
}

print '<br>';
print '</table>';

print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">';
print '<br>';

// Get bank account for the payment
$acc = new Account($db);
$fk_bank_account = $object->fk_bank_account;
if (empty($fk_bank_account)) {
$fk_bank_account = ($object->type == 'bank-transfer' ? getDolGlobalInt('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') : getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT'));
}
if ($fk_bank_account > 0) {
$result = $acc->fetch($fk_bank_account);
}
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">';

$labelofbankfield = "BankToReceiveWithdraw";
if ($object->type == 'bank-transfer') {
$labelofbankfield = 'BankToPayCreditTransfer';
}
// Get bank account for the payment
$acc = new Account($db);
$fk_bank_account = $object->fk_bank_account;
if (empty($fk_bank_account)) {
$fk_bank_account = ($object->type == 'bank-transfer' ? getDolGlobalInt('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') : getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT'));
}
if ($fk_bank_account > 0) {
$result = $acc->fetch($fk_bank_account);
}

print '<tr><td class="titlefieldcreate">';
print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
print '</td>';
$labelofbankfield = "BankToReceiveWithdraw";
if ($object->type == 'bank-transfer') {
$labelofbankfield = 'BankToPayCreditTransfer';
}

print '<td>';
if ($acc->id > 0) {
print $acc->getNomUrl(1);
}
print '</td>';
print '</tr>';
print '<tr><td class="titlefieldcreate">';
print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
print '</td>';

$modulepart = 'prelevement';
if ($object->type == 'bank-transfer') {
$modulepart = 'paymentbybanktransfer';
}
print '<td>';
if ($acc->id > 0) {
print $acc->getNomUrl(1);
}
print '</td>';
print '</tr>';

print '<tr><td class="titlefieldcreate">';
$labelfororderfield = 'WithdrawalFile';
if ($object->type == 'bank-transfer') {
$labelfororderfield = 'CreditTransferFile';
}
print $langs->trans($labelfororderfield).'</td><td>';
$modulepart = 'prelevement';
if ($object->type == 'bank-transfer') {
$modulepart = 'paymentbybanktransfer';
}

if (isModEnabled('multicompany')) {
$labelentity = $conf->entity;
$relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml';
print '<tr><td class="titlefieldcreate">';
$labelfororderfield = 'WithdrawalFile';
if ($object->type == 'bank-transfer') {
$labelfororderfield = 'CreditTransferFile';
}
print $langs->trans($labelfororderfield).'</td><td>';

if ($type != 'bank-transfer') {
$dir = $conf->prelevement->dir_output;
} else {
$dir = $conf->paymentbybanktransfer->dir_output;
}
if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility
$relativepath = 'receipts/'.$object->ref.'.xml';
}
if (isModEnabled('multicompany')) {
$labelentity = $conf->entity;
$relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml';

if ($type != 'bank-transfer') {
$dir = $conf->prelevement->dir_output;
} else {
$dir = $conf->paymentbybanktransfer->dir_output;
}
if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility
$relativepath = 'receipts/'.$object->ref.'.xml';
}
} else {
$relativepath = 'receipts/'.$object->ref.'.xml';
}

print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath;
print img_picto('', 'download', 'class="paddingleft"');
print '</a>';
print '</td></tr></table>';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath;
print img_picto('', 'download', 'class="paddingleft"');
print '</a>';
print '</td></tr></table>';

print '</div>';
print '</div>';

print dol_get_fiche_end();
} else {
dol_print_error($db);
}
print dol_get_fiche_end();
}


Expand Down
41 changes: 23 additions & 18 deletions htdocs/holiday/define_holiday.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,23 @@

$holiday = new Holiday($db);

$arrayfields = array(
'cp.rowid' => array('label' => $langs->trans("Employee"), 'checked' => 1, 'position' => 20),
'cp.fk_user' => array('label' => $langs->trans("Supervisor"), 'checked' => 1, 'position' => 30),
'cp.nbHoliday' => array('label' => $langs->trans("MenuConfCP"), 'checked' => 1, 'position' => 40),
'cp.note_public' => array('label' => $langs->trans("Note"), 'checked' => 1, 'position' => 50),
);

$permissiontoread = $user->hasRight('holiday', 'read');
$permissiontoreadall = $user->hasRight('holiday', 'readall');
$permissiontowrite = $user->hasRight('holiday', 'write');
$permissiontowriteall = $user->hasRight('holiday', 'writeall');
$permissiontodelete = $user->hasRight('holiday', 'delete');

$permissiontoapprove = $user->hasRight('holiday', 'approve');
$permissiontosetup = $user->hasRight('holiday', 'define_holiday');

if (empty($conf->holiday->enabled)) {
if (!isModEnabled('holiday')) {
accessforbidden('Module not enabled');
}

Expand All @@ -87,13 +102,6 @@
accessforbidden();
}

$arrayfields = array(
'cp.rowid' => array('label' => $langs->trans("Employee"), 'checked' => 1, 'position' => 20),
'cp.fk_user' => array('label' => $langs->trans("Supervisor"), 'checked' => 1, 'position' => 30),
'cp.nbHoliday' => array('label' => $langs->trans("MenuConfCP"), 'checked' => 1, 'position' => 40),
'cp.note_public' => array('label' => $langs->trans("Note"), 'checked' => 1, 'position' => 50),
);


/*
* Actions
Expand Down Expand Up @@ -128,14 +136,11 @@
// Mass actions
$objectclass = 'Holiday';
$objectlabel = 'Holiday';
$permissiontoread = $user->hasRight('holiday', 'read');
$permissiontodelete = $user->hasRight('holiday', 'delete');
$permissiontoapprove = $user->hasRight('holiday', 'approve');
$uploaddir = $conf->holiday->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';

// If there is an update action
if ($action == 'update' && GETPOSTISSET('update_cp')) {
if ($action == 'update' && GETPOSTISSET('update_cp') && $permissiontosetup) {
$error = 0;
$nbok = 0;

Expand Down Expand Up @@ -233,7 +238,7 @@
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
);
if ($user->hasRight("holiday", "approve")) {
if ($permissiontosetup) {
$arrayofmassactions['preincreaseholiday'] = img_picto('', 'add', 'class="pictofixedwidth"').$langs->trans("IncreaseHolidays");
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
Expand Down Expand Up @@ -294,7 +299,7 @@

// Filter on array of ids of all children
$userchilds = array();
if (!$user->hasRight('holiday', 'readall')) {
if (!$permissiontoreadall) {
$userchilds = $user->getAllChildIds(1);
$filters .= ' AND u.rowid IN ('.$db->sanitize(implode(', ', $userchilds)).')';
}
Expand Down Expand Up @@ -322,7 +327,7 @@
//print '</div>';
} else {
$canedit = 0;
if ($user->hasRight('holiday', 'define_holiday')) {
if ($permissiontosetup) {
$canedit = 1;
}

Expand Down Expand Up @@ -407,7 +412,7 @@
}
}
if (!empty($arrayfields['cp.note_public']['checked'])) {
print_liste_field_titre((!$user->hasRight('holiday', 'define_holiday') ? '' : 'Note'), $_SERVER["PHP_SELF"]);
print_liste_field_titre($permissiontosetup ? 'Note' : '', $_SERVER["PHP_SELF"]);
}
print_liste_field_titre('');
// Action column
Expand All @@ -421,7 +426,7 @@
$arrayofselected = is_array($toselect) ? $toselect : array();

// If user has not permission to edit/read all, we must see only subordinates
if (!$user->hasRight('holiday', 'readall')) {
if (!$permissiontoreadall) {
if (($users['rowid'] != $user->id) && (!in_array($users['rowid'], $userchilds))) {
continue; // This user is not into hierarchy of current user, we hide it.
}
Expand Down Expand Up @@ -506,7 +511,7 @@

// Button modify
print '<td class="center">';
if ($user->hasRight('holiday', 'define_holiday')) { // Allowed to set the balance of any user
if ($permissiontosetup) { // Allowed to set the balance of any user
print '<input type="submit" name="update_cp['.$users['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Save")).'" class="button smallpaddingimp"/>';
}
print '</td>'."\n";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/holiday/view_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
$arrayfields = array();
$arrayofmassactions = array();

if (empty($conf->holiday->enabled)) {
if (!isModEnabled('holiday')) {
accessforbidden('Module not enabled');
}

Expand Down
5 changes: 4 additions & 1 deletion htdocs/takepos/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,10 @@ function fail($message)
// If we add a line and no invoice yet, we create the invoice
if (($action == "addline" || $action == "freezone") && $placeid == 0 && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
$invoice->socid = getDolGlobalInt($constforcompanyid);
$invoice->date = dol_now('tzuserrel'); // We use the local date, only the day will be saved.

include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$invoice->date = dol_get_first_hour(dol_now('tzuserrel')); // Invoice::create() needs a date with no hours

$invoice->module_source = 'takepos';
$invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ;
$invoice->entity = !empty($_SESSION["takeposinvoiceentity"]) ? $_SESSION["takeposinvoiceentity"] : $conf->entity;
Expand Down

0 comments on commit 7a73231

Please sign in to comment.