diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index cf8015dbd45..c372ab72026 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -5230,6 +5230,7 @@ if ($action == 'create') {
print '
'.$langs->trans('ListOfSituationInvoices').' | ';
print ' | ';
print ''.$langs->trans('Situation').' | ';
+
if (isModEnabled("bank")) {
print ' | ';
}
@@ -5321,7 +5322,9 @@ if ($action == 'create') {
$total_next_ht = $total_next_ttc = 0;
foreach ($object->tab_next_situation_invoice as $next_invoice) {
- $totalpaid = $next_invoice->getSommePaiement();
+ $next_invoice_total_paid = $next_invoice->getSommePaiement(0);
+ $next_invoice_totalcreditnotes = $next_invoice->getSumCreditNotesUsed(0);
+ $next_invoice_totaldeposits = $next_invoice->getSumDepositsUsed(0);
$total_next_ht += $next_invoice->total_ht;
$total_next_ttc += $next_invoice->total_ttc;
@@ -5334,7 +5337,7 @@ if ($action == 'create') {
}
print ''.price($next_invoice->total_ht).' | ';
print ''.price($next_invoice->total_ttc).' | ';
- print ''.$next_invoice->getLibStatut(3, $totalpaid).' | ';
+ print ''.$next_invoice->getLibStatut(3, $next_invoice_total_paid + $next_invoice_totalcreditnotes + $next_invoice_totaldeposits).' | ';
print '';
}
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index db74a72f94f..73dc5f02d5e 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -68,9 +68,9 @@ if (!$sortfield) {
}
$object = new Facture($db);
-if ($object->fetch($id, $ref)) {
+if ($object->fetch($id, $ref) > 0) {
$object->fetch_thirdparty();
- $upload_dir = $conf->facture->dir_output."/".dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->facture->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
}
$permissiontoadd = $user->hasRight('facture', 'creer');
@@ -119,7 +119,6 @@ if ($id > 0 || !empty($ref)) {
if ($object->fetch($id, $ref) > 0) {
$object->fetch_thirdparty();
- $upload_dir = $conf->facture->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$head = facture_prepare_head($object);
print dol_get_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill');
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index 7eecd6b0131..e57595dee6f 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -109,6 +109,9 @@ function facture_prepare_head($object)
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->facture->dir_output."/".dol_sanitizeFileName($object->ref);
+ if (!empty($conf->facture->multidir_output[$object->entity])) {
+ $upload_dir = $conf->facture->multidir_output[$object->entity]."/".dol_sanitizeFileName($object->ref);
+ }
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?id='.$object->id;
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index ecbeda58328..4865a6cde75 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -889,8 +889,11 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
if ($feature == 'project') {
$feature = 'projet';
}
- if ($feature == 'task') {
- $feature = 'projet_task';
+ if ($feature == 'projet' && !empty($feature2) && is_array($feature2) && !empty(array_intersect(array('project_task', 'projet_task'), $feature2))) {
+ $feature = 'project_task';
+ }
+ if ($feature == 'task' || $feature == 'projet_task') {
+ $feature = 'project_task';
}
if ($feature == 'eventorganization') {
$feature = 'agenda';
@@ -911,7 +914,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$checksoc = array('societe'); // Test for object Societe
$checkparentsoc = array('agenda', 'contact', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...).
$checkproject = array('projet', 'project'); // Test for project object
- $checktask = array('projet_task'); // Test for task object
+ $checktask = array('projet_task', 'project_task'); // Test for task object
$checkhierarchy = array('expensereport', 'holiday', 'hrm'); // check permission among the hierarchy of user
$checkuser = array('bookmark'); // check permission among the fk_user (must be myself or null)
$nocheck = array('barcode', 'stock'); // No test
@@ -1051,6 +1054,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
return false;
}
} else {
+ $sharedelement = 'project'; // for multicompany compatibility
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")";
diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php
index 5f291b9e5bd..ff6502de684 100644
--- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php
+++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php
@@ -556,7 +556,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if (isModEnabled('contract') && isModEnabled('ticket') && isModEnabled('workflow') && getDolGlobalString('WORKFLOW_TICKET_LINK_CONTRACT') && getDolGlobalString('TICKET_PRODUCT_CATEGORY') && !empty($object->fk_soc)) {
$societe = new Societe($this->db);
$company_ids = (!getDolGlobalString('WORKFLOW_TICKET_USE_PARENT_COMPANY_CONTRACTS')) ? [$object->fk_soc] : $societe->getParentsForCompany($object->fk_soc, [$object->fk_soc]);
-
+ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$contrat = new Contrat($this->db);
$number_contracts_found = 0;
foreach ($company_ids as $company_id) {
diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php
index 27e9d867b96..607374972cd 100644
--- a/htdocs/emailcollector/class/emailcollector.class.php
+++ b/htdocs/emailcollector/class/emailcollector.class.php
@@ -845,10 +845,9 @@ class EmailCollector extends CommonObject
{
global $user;
- $nberror = 0;
+ $nbErrors = 0;
$arrayofcollectors = $this->fetchAll($user, 1);
-
// Loop on each collector
foreach ($arrayofcollectors as $emailcollector) {
$result = $emailcollector->doCollectOneCollector(0);
@@ -857,11 +856,12 @@ class EmailCollector extends CommonObject
$this->error .= 'EmailCollector ID '.$emailcollector->id.':'.$emailcollector->error.'
';
if (!empty($emailcollector->errors)) {
$this->error .= implode('
', $emailcollector->errors);
+ $nbErrors++;
}
$this->output .= 'EmailCollector ID '.$emailcollector->id.': '.$emailcollector->lastresult.'
';
}
- return $nberror;
+ return $nbErrors;
}
/**
@@ -1907,7 +1907,11 @@ class EmailCollector extends CommonObject
$attachments = [];
}
} else {
- $this->getmsg($connection, $imapemail); // This set global var $charset, $htmlmsg, $plainmsg, $attachments
+ $getMsg = $this->getmsg($connection, $imapemail); // This set global var $charset, $htmlmsg, $plainmsg, $attachments
+ if ($getMsg < 0) {
+ $this->errors = array_merge($this->errors, [$this->error]);
+ return $getMsg;
+ }
}
'@phan-var-force Webklex\PHPIMAP\Attachment[] $attachments';
@@ -3217,7 +3221,11 @@ class EmailCollector extends CommonObject
$this->saveAttachment($destdir, $filename, $content);
}
} else {
- $this->getmsg($connection, $imapemail, $destdir);
+ $getMsg = $this->getmsg($connection, $imapemail, $destdir);
+ if ($getMsg < 0) {
+ $this->errors = array_merge($this->errors, [$this->error]);
+ return $getMsg;
+ }
}
$operationslog .= '
Project created with attachments -> id='.dol_escape_htmltag($projecttocreate->id);
@@ -3373,7 +3381,11 @@ class EmailCollector extends CommonObject
$this->saveAttachment($destdir, $filename, $content);
}
} else {
- $this->getmsg($connection, $imapemail, $destdir);
+ $getMsg = $this->getmsg($connection, $imapemail, $destdir);
+ if ($getMsg < 0) {
+ $this->errors = array_merge($this->errors, [$this->error]);
+ return $getMsg;
+ }
}
$operationslog .= '
Ticket created with attachments -> id='.dol_escape_htmltag($tickettocreate->id);
@@ -3701,9 +3713,9 @@ class EmailCollector extends CommonObject
* @param Object $mbox Structure
* @param string $mid UID email
* @param string $destdir Target dir for attachments. Leave blank to parse without writing to disk.
- * @return void
+ * @return int
*/
- private function getmsg($mbox, $mid, $destdir = '')
+ private function getmsg($mbox, $mid, $destdir = ''): int
{
// input $mbox = IMAP stream, $mid = message id
// output all the following:
@@ -3717,9 +3729,12 @@ class EmailCollector extends CommonObject
// BODY @phan-suppress-next-line PhanTypeMismatchArgumentInternal
$s = imap_fetchstructure($mbox, $mid, FT_UID);
+ if ($s === false) {
+ $this->errors = array_merge($this->errors, [imap_last_error()]);
+ return -1;
+ }
-
- if (!$s->parts) {
+ if (empty($s->parts)) {
// simple
$this->getpart($mbox, $mid, $s, 0); // pass 0 as part-number
} else {
@@ -3728,6 +3743,8 @@ class EmailCollector extends CommonObject
$this->getpart($mbox, $mid, $p, $partno0 + 1, $destdir);
}
}
+
+ return 1;
}
/* partno string
diff --git a/htdocs/emailcollector/lib/emailcollector.lib.php b/htdocs/emailcollector/lib/emailcollector.lib.php
index befbbef16b2..da502ac7361 100644
--- a/htdocs/emailcollector/lib/emailcollector.lib.php
+++ b/htdocs/emailcollector/lib/emailcollector.lib.php
@@ -122,8 +122,10 @@ function getAttachments($jk, $mbox)
$fpos = 2;
$attachments = array();
- $nb = count($parts);
- if ($nb && !empty($parts)) {
+
+ if (!empty($parts)) {
+ $nb = count($parts);
+
for ($i = 1; $i < $nb; $i++) {
$part = $parts[$i];
@@ -140,6 +142,7 @@ function getAttachments($jk, $mbox)
$fpos++;
}
}
+
return $attachments;
}
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index e24d17b13e1..c93eba28f8b 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -1951,9 +1951,10 @@ if ($action == 'create') {
print '';
// List of payments already done
+ $canSeeBankAccount = isModEnabled('bank') && $user->hasRight('banque', 'lire');
$nbcols = 3;
$nbrows = 0;
- if (isModEnabled("bank")) {
+ if ($canSeeBankAccount) {
$nbrows++;
$nbcols++;
}
@@ -1964,7 +1965,7 @@ if ($action == 'create') {
print ''.$langs->trans('Payments').' | ';
print ''.$langs->trans('Date').' | ';
print ''.$langs->trans('Type').' | ';
- if (isModEnabled("bank")) {
+ if ($canSeeBankAccount) {
print ''.$langs->trans('BankAccount').' | ';
}
print ''.$langs->trans('Amount').' | ';
@@ -2007,7 +2008,7 @@ if ($action == 'create') {
$labeltype = $langs->trans("PaymentType".$objp->payment_code) != "PaymentType".$objp->payment_code ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_type;
print "".$labeltype.' '.$objp->num_payment." | \n";
// Bank account
- if (isModEnabled("bank")) {
+ if ($canSeeBankAccount) {
$bankaccountstatic->id = $objp->baid;
$bankaccountstatic->ref = $objp->baref;
$bankaccountstatic->label = $objp->baref;
diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php
index c98e4a7a751..4951737228a 100644
--- a/htdocs/takepos/index.php
+++ b/htdocs/takepos/index.php
@@ -472,7 +472,7 @@ function MoreProducts(moreorless) {
var nb_cat_shown = $('.div5 div.wrapper2[data-iscat=1]').length;
var offset = * pageproducts - nb_cat_shown;
// Only show products for sale (tosell=1)
- $.getJSON('/takepos/ajax/ajax.php?action=getProducts&token=&category='+currentcat+'&tosell=1&limit='+limit+'&offset='+offset, function(data) {
+ $.getJSON('/takepos/ajax/ajax.php?action=getProducts&token=&thirdpartyid=' + jQuery('#thirdpartyid').val() + '&category='+currentcat+'&tosell=1&limit='+limit+'&offset='+offset, function(data) {
console.log("Call ajax.php (in MoreProducts) to get Products of category "+currentcat);
if (typeof (data[0]) == "undefined" && moreorless=="more"){ // Return if no more pages