diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index 0ff56583c744b..f8b657edb41d5 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -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 = '')
{
@@ -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;
}
}
diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php
index 7839429149434..22436cf8702ca 100644
--- a/htdocs/compta/prelevement/factures.php
+++ b/htdocs/compta/prelevement/factures.php
@@ -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 '
'.$langs->trans("ErrorRecordNotFound").'
';
+ llxFooter();
+ exit;
+ }
- print dol_get_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
+ $head = prelevement_prepare_head($object);
- $linkback = ''.$langs->trans("BackToList").' ';
+ print dol_get_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
- dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
+ $linkback = ''.$langs->trans("BackToList").' ';
- print '';
- print '
';
- print '
'."\n";
+ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
- //print ''.$langs->trans("Ref").' '.$object->getNomUrl(1).' ';
- print ''.$langs->trans("Date").' '.dol_print_date($object->datec, 'day').' ';
- print ''.$langs->trans("Amount").' '.price($object->amount).' ';
+ print '';
+ print '
';
+ print '
'."\n";
- if (!empty($object->date_trans)) {
- $muser = new User($db);
- $muser->fetch($object->user_trans);
+ //print ''.$langs->trans("Ref").' '.$object->getNomUrl(1).' ';
+ print ''.$langs->trans("Date").' '.dol_print_date($object->datec, 'day').' ';
+ print ''.$langs->trans("Amount").' '.price($object->amount).' ';
- print ''.$langs->trans("TransData").' ';
- print dol_print_date($object->date_trans, 'day');
- print ' '.$langs->trans("By").' '.$muser->getNomUrl(-1).' ';
- print ''.$langs->trans("TransMetod").' ';
- print $object->methodes_trans[$object->method_trans];
- print ' ';
- }
- if (!empty($object->date_credit)) {
- print ''.$langs->trans('CreditDate').' ';
- print dol_print_date($object->date_credit, 'day');
- print ' ';
- }
+ if (!empty($object->date_trans)) {
+ $muser = new User($db);
+ $muser->fetch($object->user_trans);
- print '
';
+ print '
'.$langs->trans("TransData").' ';
+ print dol_print_date($object->date_trans, 'day');
+ print ' '.$langs->trans("By").' '.$muser->getNomUrl(-1).' ';
+ print '
'.$langs->trans("TransMetod").' ';
+ print $object->methodes_trans[$object->method_trans];
+ print ' ';
+ }
+ if (!empty($object->date_credit)) {
+ print '
'.$langs->trans('CreditDate').' ';
+ print dol_print_date($object->date_credit, 'day');
+ print ' ';
+ }
- print '
';
+ print '
';
- print '
';
- print '
';
+ print ' ';
- // 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 '
';
+ print '';
- $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 '';
- print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
- print ' ';
+ $labelofbankfield = "BankToReceiveWithdraw";
+ if ($object->type == 'bank-transfer') {
+ $labelofbankfield = 'BankToPayCreditTransfer';
+ }
- print '';
- if ($acc->id > 0) {
- print $acc->getNomUrl(1);
- }
- print ' ';
- print ' ';
+ print '';
+ print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
+ print ' ';
- $modulepart = 'prelevement';
- if ($object->type == 'bank-transfer') {
- $modulepart = 'paymentbybanktransfer';
- }
+ print '';
+ if ($acc->id > 0) {
+ print $acc->getNomUrl(1);
+ }
+ print ' ';
+ print ' ';
- print '';
- $labelfororderfield = 'WithdrawalFile';
- if ($object->type == 'bank-transfer') {
- $labelfororderfield = 'CreditTransferFile';
- }
- print $langs->trans($labelfororderfield).' ';
+ $modulepart = 'prelevement';
+ if ($object->type == 'bank-transfer') {
+ $modulepart = 'paymentbybanktransfer';
+ }
- if (isModEnabled('multicompany')) {
- $labelentity = $conf->entity;
- $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml';
+ print ' ';
+ $labelfororderfield = 'WithdrawalFile';
+ if ($object->type == 'bank-transfer') {
+ $labelfororderfield = 'CreditTransferFile';
+ }
+ print $langs->trans($labelfororderfield).' ';
- 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 ''.$relativepath;
- print img_picto('', 'download', 'class="paddingleft"');
- print ' ';
- print '
';
+ print ''.$relativepath;
+ print img_picto('', 'download', 'class="paddingleft"');
+ print ' ';
+ print '
';
- print '
';
+ print '';
- print dol_get_fiche_end();
- } else {
- dol_print_error($db);
- }
+ print dol_get_fiche_end();
}
diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php
index 8e0d49af54211..520b0a7155a83 100644
--- a/htdocs/holiday/define_holiday.php
+++ b/htdocs/holiday/define_holiday.php
@@ -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');
}
@@ -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
@@ -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;
@@ -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);
@@ -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)).')';
}
@@ -322,7 +327,7 @@
//print '';
} else {
$canedit = 0;
- if ($user->hasRight('holiday', 'define_holiday')) {
+ if ($permissiontosetup) {
$canedit = 1;
}
@@ -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
@@ -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.
}
@@ -506,7 +511,7 @@
// Button modify
print '';
- 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 ' ';
}
print ' '."\n";
diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php
index 4deca221612e0..f42a0a1fa0e8e 100644
--- a/htdocs/holiday/view_log.php
+++ b/htdocs/holiday/view_log.php
@@ -89,7 +89,7 @@
$arrayfields = array();
$arrayofmassactions = array();
-if (empty($conf->holiday->enabled)) {
+if (!isModEnabled('holiday')) {
accessforbidden('Module not enabled');
}
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index 3eb2184291be7..70321b5085011 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -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;