########## accountancy/bookkeeping/list.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/accountancy/bookkeeping/list.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/accountancy/bookkeeping/list.php 2022-12-29 01:48:23.688100467 +0000
@@ -874,7 +874,7 @@
$buttonLabel = $langs->trans("ExportList");
}
-$parameters = array();
+$parameters = array('param' => $param);
$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
########## accountancy/bookkeeping/listbyaccount.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/accountancy/bookkeeping/listbyaccount.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/accountancy/bookkeeping/listbyaccount.php 2022-12-29 01:48:23.690662756 +0000
@@ -602,7 +602,7 @@
print ' ';
print ' ';
-$parameters = array();
+$parameters = array('param' => $param);
$reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
########## accountancy/journal/bankjournal.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/accountancy/journal/bankjournal.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/accountancy/journal/bankjournal.php 2022-12-29 01:48:23.876604621 +0000
@@ -1159,19 +1159,24 @@
//var_dump($tabpay[$key]);
print '';
print '
';
+
+ // Date
print "".$date." ";
- print "".$ref." ";
+
+ // Ref
+ print "".dol_escape_htmltag($ref)." ";
+
// Ledger account
- print "";
$account_ledger = $k;
// Try to force general ledger account depending on type
if ($tabtype[$key] == 'payment') {
@@ -1237,9 +1249,9 @@
if ($tabtype[$key] == 'unknown') {
// We will accept writing, but into a waiting account
if (empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) || $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE == '-1') {
- print ''.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').' ';
+ $accounttoshow = ''.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').' ';
} else {
- print ''.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).' '; // We will use a waiting account
+ $accounttoshow = ''.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).' '; // We will use a waiting account
}
} else {
// We will refuse writing
@@ -1262,15 +1274,15 @@
if ($tabtype[$key] == 'member') {
$errorstring = 'MainAccountForSubscriptionPaymentNotDefined';
}
- print ''.$langs->trans($errorstring).' ';
+ $accounttoshow = ''.$langs->trans($errorstring).' ';
}
- } else {
- print $accounttoshow;
}
+ print ' ';
+ print $accounttoshow;
print " ";
// Subledger account
- print "";
+ $accounttoshowsubledger = '';
if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payments that uses a subledger
$accounttoshowsubledger = length_accounta($k);
if ($accounttoshow != $accounttoshowsubledger) {
@@ -1282,18 +1294,20 @@
if (!empty($tabcompany[$key]['code_compta'])) {
if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) {
// For such case, if subledger is not defined, we won't use subledger accounts.
- print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").' ';
+ $accounttoshowsubledger = ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").' ';
} else {
- print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).' ';
+ $accounttoshowsubledger = ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).' ';
}
} else {
- print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").' ';
+ $accounttoshowsubledger = ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").' ';
}
- } else {
- print $accounttoshowsubledger;
}
+ } else {
+ $accounttoshowsubledger = '';
}
}
+ print ' ';
+ print $accounttoshowsubledger;
print " ";
print "".$reflabel." ";
########## adherents/class/api_members.class.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/adherents/class/api_members.class.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/adherents/class/api_members.class.php 2022-12-29 01:48:24.183346554 +0000
@@ -383,14 +383,18 @@
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- if (!$member->delete($member->id, DolibarrApiAccess::$user)) {
- throw new RestException(401, 'error when deleting member');
+
+ $res = $member->delete($member->id, DolibarrApiAccess::$user);
+ if ($res < 0) {
+ throw new RestException(500, "Can't delete, error occurs");
+ } elseif ($res == 0) {
+ throw new RestException(409, "Can't delete, that product is probably used");
}
return array(
'success' => array(
'code' => 200,
- 'message' => 'member deleted'
+ 'message' => 'Member deleted'
)
);
}
########## adherents/class/api_memberstypes.class.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/adherents/class/api_memberstypes.class.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/adherents/class/api_memberstypes.class.php 2022-12-29 01:48:24.190767835 +0000
@@ -229,14 +229,17 @@
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- if (!$membertype->delete()) {
- throw new RestException(401, 'error when deleting member type');
+ $res = $membertype->delete();
+ if ($res < 0) {
+ throw new RestException(500, "Can't delete, error occurs");
+ } elseif ($res == 0) {
+ throw new RestException(409, "Can't delete, that product is probably used");
}
return array(
'success' => array(
'code' => 200,
- 'message' => 'member type deleted'
+ 'message' => 'Member type deleted'
)
);
}
########## adherents/class/api_subscriptions.class.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/adherents/class/api_subscriptions.class.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/adherents/class/api_subscriptions.class.php 2022-12-29 01:48:24.222970857 +0000
@@ -215,14 +215,17 @@
throw new RestException(404, 'Subscription not found');
}
- if (!$subscription->delete(DolibarrApiAccess::$user)) {
- throw new RestException(401, 'error when deleting subscription');
+ $res = $subscription->delete(DolibarrApiAccess::$user);
+ if ($res < 0) {
+ throw new RestException(500, "Can't delete, error occurs");
+ } elseif ($res == 0) {
+ throw new RestException(409, "Can't delete, that product is probably used");
}
return array(
'success' => array(
'code' => 200,
- 'message' => 'subscription deleted'
+ 'message' => 'Subscription deleted'
)
);
}
########## adherents/subscription/card.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/adherents/subscription/card.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/adherents/subscription/card.php 2022-12-29 01:48:24.329263977 +0000
@@ -108,8 +108,9 @@
$object->dateh = dol_mktime(GETPOST('datesubhour', 'int'), GETPOST('datesubmin', 'int'), 0, GETPOST('datesubmonth', 'int'), GETPOST('datesubday', 'int'), GETPOST('datesubyear', 'int'));
$object->datef = dol_mktime(GETPOST('datesubendhour', 'int'), GETPOST('datesubendmin', 'int'), 0, GETPOST('datesubendmonth', 'int'), GETPOST('datesubendday', 'int'), GETPOST('datesubendyear', 'int'));
$object->fk_type = $typeid;
- $object->note = $note;
+ $object->note_public = $note;
$object->note_private = $note;
+
$object->amount = $amount;
$result = $object->update($user);
########## admin/dict.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/admin/dict.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/admin/dict.php 2022-12-29 01:48:24.529882794 +0000
@@ -1965,7 +1965,7 @@
$valuetoshow = ($key != "Country".strtoupper($obj->country_code) ? $obj->country_code." - ".$key : $obj->country);
}
} elseif ($value == 'recuperableonly' || $value == 'deductible' || $value == 'category_type') {
- $valuetoshow = yn($valuetoshow);
+ $valuetoshow = yn($valuetoshow ? 1 : 0);
$class = "center";
} elseif ($value == 'type_cdr') {
if (empty($valuetoshow)) {
########## admin/perms.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/admin/perms.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/admin/perms.php 2022-12-29 01:48:24.830810833 +0000
@@ -226,7 +226,7 @@
// Tick
if ($obj->bydefault == 1) {
print '';
- print '';
+ print ' ';
//print img_edit_remove();
print img_picto('', 'switch_on');
print ' ';
########## api/class/api_documents.class.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/api/class/api_documents.class.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/api/class/api_documents.class.php 2022-12-29 01:48:25.144136175 +0000
@@ -506,6 +506,11 @@
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
}
+ $objectType = $modulepart;
+ if (! empty($object->id) && ! empty($object->table_element)) {
+ $objectType = $object->table_element;
+ }
+
$filearray = dol_dir_list($upload_dir, $type, $recursive, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
if (empty($filearray)) {
throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->ref) ? ' or Ref '.$object->ref : '').' does not return any document.');
@@ -513,11 +518,14 @@
if (($object->id) > 0 && !empty($modulepart)) {
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile = new EcmFiles($this->db);
- $result = $ecmfile->fetchAll('', '', 0, 0, array('t.src_object_type' => $modulepart, 't.src_object_id' => $object->id));
+ $result = $ecmfile->fetchAll('', '', 0, 0, array('t.src_object_type' => $objectType, 't.src_object_id' => $object->id));
if ($result < 0) {
throw new RestException(503, 'Error when retrieve ecm list : '.$this->db->lasterror());
} elseif (is_array($ecmfile->lines) && count($ecmfile->lines) > 0) {
- $filearray['ecmfiles_infos'] = $ecmfile->lines;
+ $count = count($filearray);
+ for ($i = 0 ; $i < $count ; $i++) {
+ if ($filearray[$i]['name'] == $ecmfile->lines[$i]->filename) $filearray[$i] = array_merge($filearray[$i], (array) $ecmfile->lines[0]);
+ }
}
}
}
########## barcode/codeinit.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/barcode/codeinit.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/barcode/codeinit.php 2022-12-29 01:48:25.237382574 +0000
@@ -45,7 +45,7 @@
$modBarCodeProduct = '';
-$maxperinit = 1000;
+$maxperinit = empty($conf->global->BARCODE_INIT_MAX) ? 1000 : $conf->global->BARCODE_INIT_MAX;
/*
@@ -65,14 +65,16 @@
if (preg_match('/^mod_barcode_product_.*php$/', $file)) {
$file = substr($file, 0, dol_strlen($file) - 4);
- try {
- dol_include_once($dirroot.$file.'.php');
- } catch (Exception $e) {
- dol_syslog($e->getMessage(), LOG_ERR);
- }
+ if ($file == $conf->global->BARCODE_PRODUCT_ADDON_NUM) {
+ try {
+ dol_include_once($dirroot.$file.'.php');
+ } catch (Exception $e) {
+ dol_syslog($e->getMessage(), LOG_ERR);
+ }
- $modBarCodeProduct = new $file();
- break;
+ $modBarCodeProduct = new $file();
+ break;
+ }
}
}
closedir($handle);
########## comm/propal/class/propalestats.class.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/comm/propal/class/propalestats.class.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/comm/propal/class/propalestats.class.php 2022-12-29 01:48:25.666662580 +0000
@@ -93,9 +93,6 @@
}
//$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity;
$this->where .= ($this->where ? ' AND ' : '')."p.entity IN (".getEntity('propal').")";
- if (empty($user->rights->societe->client->voir) && !$this->socid) {
- $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- }
if ($this->socid) {
$this->where .= " AND p.fk_soc = ".((int) $this->socid);
}
@@ -130,7 +127,7 @@
$sql = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$user->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
@@ -155,7 +152,7 @@
$sql = "SELECT date_format(".$this->field_date.",'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$this->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
@@ -179,7 +176,7 @@
$sql = "SELECT date_format(".$this->field_date.",'%m') as dm, SUM(p.".$this->field.")";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$this->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
@@ -204,7 +201,7 @@
$sql = "SELECT date_format(".$this->field_date.",'%m') as dm, AVG(p.".$this->field.")";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$this->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
@@ -227,7 +224,7 @@
$sql = "SELECT date_format(".$this->field_date.",'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$this->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
@@ -253,7 +250,7 @@
$sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg";
$sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product";
if (empty($user->rights->societe->client->voir) && !$user->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
########## commande/class/commandestats.class.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/commande/class/commandestats.class.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/commande/class/commandestats.class.php 2022-12-29 01:48:25.845817406 +0000
@@ -93,9 +93,6 @@
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
$this->where .= ($this->where ? ' AND ' : '').'c.entity IN ('.getEntity('commande').')';
- if (empty($user->rights->societe->client->voir) && !$this->socid) {
- $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
- }
if ($this->socid) {
$this->where .= " AND c.fk_soc = ".((int) $this->socid);
}
@@ -129,7 +126,7 @@
$sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$this->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
@@ -154,7 +151,7 @@
$sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$this->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
@@ -178,7 +175,7 @@
$sql = "SELECT date_format(c.date_commande,'%m') as dm, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$this->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
@@ -203,7 +200,7 @@
$sql = "SELECT date_format(c.date_commande,'%m') as dm, AVG(c.".$this->field.")";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$this->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
@@ -226,7 +223,7 @@
$sql = "SELECT date_format(c.date_commande,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg";
$sql .= " FROM ".$this->from;
if (empty($user->rights->societe->client->voir) && !$this->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
@@ -250,7 +247,7 @@
$sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg";
$sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product";
if (empty($user->rights->societe->client->voir) && !$user->socid) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
$sql .= " WHERE ".$this->where;
########## compta/facture/card.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/compta/facture/card.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/compta/facture/card.php 2022-12-29 01:48:26.210962259 +0000
@@ -2985,6 +2985,11 @@
$remise_percent = (!empty($expesrc->remise_percent) ? $expesrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0));
$remise_absolue = (!empty($expesrc->remise_absolue) ? $expesrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
+ if (!empty($conf->multicurrency->enabled)) {
+ $currency_code = (!empty($expesrc->currency_code) ? $expesrc->currency_code : (!empty($soc->currency_code) ? $soc->currency_code : $objectsrc->multicurrency_code));
+ $currency_tx = (!empty($expesrc->currency_tx) ? $expesrc->currency_tx : (!empty($soc->currency_tx) ? $soc->currency_tx : $objectsrc->currency_tx));
+ }
+
//Replicate extrafields
$expesrc->fetch_optionals();
$object->array_options = $expesrc->array_options;
########## compta/facture/class/facture.class.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/compta/facture/class/facture.class.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/compta/facture/class/facture.class.php 2023-01-19 21:52:35.666739360 +0000
@@ -5680,6 +5680,180 @@
}
}
+ /** MODIF JOSE
+ * Send emails for invoices that are payed
+ * CAN BE A CRON TASK
+ *
+ * @param int $nbdays Delay after payed date (or before if delay is negative)
+ * @param string $paymentmode '' or 'all' by default (no filter), or 'LIQ', 'CHQ', CB', ...
+ * @param int|string $template Name (or id) of email template (Must be a template of type 'facture_send')
+ * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
+ */
+ public function sendEmailsRemindersOnInvoicePayed($nbdays = 0, $paymentmode = 'all', $template = '')
+ {
+ global $conf, $langs, $user;
+
+ $error = 0;
+ $this->output = '';
+ $this->error = '';
+ $nbMailSend = 0;
+ $errorsMsg = array();
+
+ $langs->load("bills");
+
+ if (empty($conf->facture->enabled)) { // Should not happen. If module disabled, cron job should not be visible.
+ $this->output .= $langs->trans('ModuleNotEnabled', $langs->transnoentitiesnoconv("Facture"));
+ return 0;
+ }
+ /*if (empty($conf->global->FACTURE_REMINDER_EMAIL)) {
+ $langs->load("bills");
+ $this->output .= $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Facture"));
+ return 0;
+ }
+ */
+
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
+ $formmail = new FormMail($this->db);
+
+ $now = dol_now();
+ $tmpidate = dol_get_first_hour(dol_time_plus_duree($now, $nbdays, 'd'), 'gmt');
+
+ $tmpinvoice = new Facture($this->db);
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
+ $this->db->begin();
+
+ //Select all action comm reminder
+ $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."facture as f";
+ if (!empty($paymentmode) && $paymentmode != 'all') {
+ $sql .= ", ".MAIN_DB_PREFIX."c_paiement as cp";
+ }
+ $sql .= " WHERE f.paye = 1"; //invoice payed
+ $sql .= " AND f.date_closing = '".$this->db->idate($tmpidate, 'gmt')."'";
+ $sql .= " AND f.entity IN (".getEntity('facture').")";
+ if (!empty($paymentmode) && $paymentmode != 'all') {
+ $sql .= " AND f.fk_mode_reglement = cp.id AND cp.code = '".$this->db->escape($paymentmode)."'";
+ }
+ // TODO Add filter to check there is no payment started
+ // $sql .= $this->db->order("date_lim_reglement", "ASC");
+print_r($sql);
+ $resql = $this->db->query($sql);
+
+ $stmpidate = dol_print_date($tmpidate, 'day', 'gmt');
+ $this->output .= $langs->transnoentitiesnoconv("SearchPaidInvoicesWithDate", $stmpidate);
+ if (!empty($paymentmode) && $paymentmode != 'all') {
+ $this->output .= ' ('.$langs->transnoentitiesnoconv("PaymentMode").' '.$paymentmode.')';
+ }
+ $this->output .= ' ';
+
+ if ($resql) {
+ while ($obj = $this->db->fetch_object($resql)) {
+ if (!$error) {
+ // Load event
+ $res = $tmpinvoice->fetch($obj->id);
+ if ($res > 0) {
+ $tmpinvoice->fetch_thirdparty();
+
+ $outputlangs = new Translate('', $conf);
+ if ($tmpinvoice->thirdparty->default_lang) {
+ $outputlangs->setDefaultLang($tmpinvoice->thirdparty->default_lang);
+ $outputlangs->loadLangs(array("main", "bills"));
+ } else {
+ $outputlangs = $langs;
+ }
+
+ // Select email template
+ $arraymessage = $formmail->getEMailTemplate($this->db, 'facture_send', $user, $outputlangs, (is_numeric($template) ? $template : 0), 1, (is_numeric($template) ? '' : $template));
+ if (is_numeric($arraymessage) && $arraymessage <= 0) {
+ $langs->load("errors");
+ $this->output .= $langs->trans('ErrorFailedToFindEmailTemplate', $template);
+ return 0;
+ }
+
+ // PREPARE EMAIL
+ $errormesg = '';
+
+ // Make substitution in email content
+ $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, '', $tmpinvoice);
+
+ complete_substitutions_array($substitutionarray, $outputlangs, $tmpinvoice);
+
+ // Topic
+ $sendTopic = make_substitutions(empty($arraymessage->topic) ? $outputlangs->transnoentitiesnoconv('InformationMessage') : $arraymessage->topic, $substitutionarray, $outputlangs, 1);
+
+ // Content
+ $content = $outputlangs->transnoentitiesnoconv($arraymessage->content);
+
+ $sendContent = make_substitutions($content, $substitutionarray, $outputlangs, 1);
+
+ // Recipient
+ $res = $tmpinvoice->fetch_thirdparty();
+ $recipient = $tmpinvoice->thirdparty;
+ if ($res > 0) {
+ if (!empty($recipient->email)) {
+ $to = $recipient->email;
+ } else {
+ $errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->fk_soc.". No email defined for user.";
+ $error++;
+ }
+ } else {
+ $errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->fk_soc;
+ $error++;
+ }
+
+ // Sender
+ $from = $conf->global->MAIN_MAIL_EMAIL_FROM;
+ if (empty($from)) {
+ $errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM";
+ $error++;
+ }
+
+ if (!$error) {
+ // Errors Recipient
+ $errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;
+
+ $trackid = 'inv'.$tmpinvoice->id;
+ // Mail Creation
+ $cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, array(), array(), array(), '', "", 0, 1, $errors_to, '', $trackid, '', '', '');
+
+ // Sending Mail
+ if ($cMailFile->sendfile()) {
+ $nbMailSend++;
+ } else {
+ $errormesg = $cMailFile->error.' : '.$to;
+ $error++;
+ }
+ }
+
+ if ($errormesg) {
+ $errorsMsg[] = $errormesg;
+ }
+ } else {
+ $errorsMsg[] = 'Failed to fetch record invoice with ID = '.$obj->id;
+ $error++;
+ }
+ }
+ }
+ } else {
+ $error++;
+ }
+
+ if (!$error) {
+ $this->output .= 'Nb of emails sent : '.$nbMailSend;
+ $this->db->commit();
+ return 0;
+ } else {
+ $this->db->commit(); // We commit also on error, to have the error message recorded.
+ $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error;
+ return $error;
+ }
+ }
+ // END MODIF JOSE
+
+
/**
* See if current invoice date is posterior to the last invoice date among validated invoices of same type.
*
########## compta/facture/list.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/compta/facture/list.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/compta/facture/list.php 2022-12-29 01:48:26.263517237 +0000
@@ -1789,7 +1789,7 @@
$remaintopay = 0;
$multicurrency_remaintopay = 0;
}
- if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consummed
+ if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consumed
$remaincreditnote = $discount->getAvailableDiscounts($companystatic, '', 'rc.fk_facture_source='.$facturestatic->id);
$remaintopay = -$remaincreditnote;
$totalpay = price2num($facturestatic->total_ttc - $remaintopay);
########## contrat/card.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/contrat/card.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/contrat/card.php 2022-12-29 01:48:26.926355628 +0000
@@ -496,6 +496,8 @@
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
+ $pu_ht = price2num($price_ht, 'MU');
+
// On reevalue prix selon taux tva car taux tva transaction peut etre different
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
if ($tmpvat != $tmpprodvat) {
@@ -521,7 +523,7 @@
$fk_unit = $prod->fk_unit;
} else {
- $pu_ht = GETPOST('price_ht');
+ $pu_ht = price2num($price_ht, 'MU');
$price_base_type = 'HT';
$tva_tx = GETPOST('tva_tx') ?str_replace('*', '', GETPOST('tva_tx')) : 0; // tva_tx field may be disabled, so we use vat rate 0
$tva_npr = preg_match('/\*/', GETPOST('tva_tx')) ? 1 : 0;
########## core/actions_massactions.inc.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/core/actions_massactions.inc.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/core/actions_massactions.inc.php 2022-12-29 01:48:26.993534619 +0000
@@ -1040,8 +1040,9 @@
}
if ($objectclass == 'Holiday' && ! in_array($objecttmp->statut, array(Holiday::STATUS_DRAFT, Holiday::STATUS_CANCELED, Holiday::STATUS_REFUSED))) {
+ $langs->load("errors");
$nbignored++;
- $resaction .= ''.$langs->trans('ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).'
';
+ $TMsg[] = ''.$langs->trans('ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref).'
';
continue;
}
@@ -1418,7 +1419,7 @@
// If no SQL error, we redirect to the request form
if (!$error) {
- // Calculcate number of days consummed
+ // Calculcate number of days consumed
$nbopenedday = num_open_day($objecttmp->date_debut_gmt, $objecttmp->date_fin_gmt, 0, 1, $objecttmp->halfday);
$soldeActuel = $objecttmp->getCpforUser($objecttmp->fk_user, $objecttmp->fk_type);
$newSolde = ($soldeActuel - $nbopenedday);
########## core/class/commonobject.class.php
--- /homez.786/ridinteadu/_serious_analysis/van_16.0.3/dolibarr-16.0.3/htdocs/core/class/commonobject.class.php 2022-11-29 17:31:43.000000000 +0000
+++ /homez.786/ridinteadu/serious/dolibarr/htdocs/core/class/commonobject.class.php 2022-12-29 01:48:27.349021301 +0000
@@ -8113,7 +8113,7 @@
if ($display_type == 'card') {
$out .= '