diff --git a/.gitignore b/.gitignore
index e4790fe7b4e..e935ec1bd59 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,6 +42,8 @@ htdocs/includes/sebastian/
htdocs/includes/squizlabs/
htdocs/includes/webmozart/
htdocs/.well-known/apple-developer-merchantid-domain-association
+/factory/
+/output/
# Node Modules
build/yarn-error.log
@@ -55,4 +57,3 @@ yarn.lock
package-lock.json
doc/install.lock
-/factory/
diff --git a/ChangeLog b/ChangeLog
index fcf5af4aef6..790d5b329b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -141,7 +141,7 @@ NEW: Added MMK currency (Myanmar Kyat)
Modules
NEW: Module Partnership Management
-NEW: Experimental Module Event Organization Management
+NEW: Module Event Organization Management
For developers or integrators:
diff --git a/build/docker/docker-run.sh b/build/docker/docker-run.sh
index e57d9adfad0..4e69ea4a3a2 100644
--- a/build/docker/docker-run.sh
+++ b/build/docker/docker-run.sh
@@ -1,4 +1,6 @@
#!/bin/bash
+# Script used by the Dockerfile.
+# See README.md to know how to create a Dolibarr env with docker
usermod -u ${HOST_USER_ID} www-data
groupmod -g ${HOST_USER_ID} www-data
diff --git a/dev/resources/iso-normes/vat_number_names.txt b/dev/resources/iso-normes/tax/vat_number_names.txt
similarity index 71%
rename from dev/resources/iso-normes/vat_number_names.txt
rename to dev/resources/iso-normes/tax/vat_number_names.txt
index b1e8d469ec8..77adda72e0d 100644
--- a/dev/resources/iso-normes/vat_number_names.txt
+++ b/dev/resources/iso-normes/tax/vat_number_names.txt
@@ -4,4 +4,5 @@ terms
(en) VAT = Value Added Tax
(fr) TVA = Taxe sur la Valeur Ajouté
(es) NIF / CIF
-(de) USt / MwSt
+(de) USt / MwSt = UmsatzSteuer / Mehrwertsteuer
+(it) IVA
diff --git a/dev/resources/iso-normes/tax/world_tax_rates.txt b/dev/resources/iso-normes/tax/world_tax_rates.txt
new file mode 100644
index 00000000000..0b3bc3f41e5
--- /dev/null
+++ b/dev/resources/iso-normes/tax/world_tax_rates.txt
@@ -0,0 +1,10 @@
+VAT Rates
+---------
+
+https://www.taxrates.cc/index.html
+https://en.wikipedia.org/wiki/List_of_countries_by_tax_rates
+
+For India: VAT=IGST / CGST=Localtax1 / SGST=Localtax2
+see:
+ https://cleartax.in/s/what-is-sgst-cgst-igst
+ https://www.mastersindia.co/blog/what-is-cgst-sgst-igst-and-ugst/
diff --git a/dev/resources/iso-normes/world_tax_rates.txt b/dev/resources/iso-normes/world_tax_rates.txt
deleted file mode 100644
index 508446b618a..00000000000
--- a/dev/resources/iso-normes/world_tax_rates.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-VAT Rates
----------
-
-http://www.taxrates.cc/index.html
-https://en.wikipedia.org/wiki/List_of_countries_by_tax_rates
-
-For India: VAT=IGST/CGST=Localtax1/SGST=Localtax2: https://cleartax.in/s/what-is-sgst-cgst-igst
-
diff --git a/dev/tools/detectnotabfiles.sh b/dev/tools/detectnotabfiles.sh
index c89b999b03d..ed4df5e50d8 100755
--- a/dev/tools/detectnotabfiles.sh
+++ b/dev/tools/detectnotabfiles.sh
@@ -10,6 +10,7 @@
# Syntax
if [ "x$1" != "xlist" -a "x$1" != "xfix" ]
then
+ echo "Detect .sh and .spec files that does not contains any tab inside"
echo "Usage: fixnotabfiles.sh [list|fix]"
fi
diff --git a/dev/tools/fixdosfiles.sh b/dev/tools/fixdosfiles.sh
index 4be867aea98..e5e5d97b554 100755
--- a/dev/tools/fixdosfiles.sh
+++ b/dev/tools/fixdosfiles.sh
@@ -17,14 +17,14 @@ fi
# To detec
if [ "x$1" = "xlist" ]
then
- find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep CRLF
-# find . \( -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" \) -exec file "{}" + | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep -v 'htdocs\/includes' | grep CRLF
+ find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep -v "CRLF" | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep CRLF
+# find . \( -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" \) -exec file "{}" + | grep -v "CRLF" | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep -v 'htdocs\/includes' | grep CRLF
fi
# To convert
if [ "x$1" = "xfix" ]
then
- for fic in `find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep CRLF | awk -F':' '{ print $1 }' `
+ for fic in `find . \( -iname "functions" -o -iname "*.md" -o -iname "*.html" -o -iname "*.htm" -o -iname "*.php" -o -iname "*.sh" -o -iname "*.cml" -o -iname "*.css" -o -iname "*.js" -o -iname "*.lang" -o -iname "*.pl" -o -iname "*.sql" -o -iname "*.txt" -o -iname "*.xml" -o -iname "*.pml" \) -exec file "{}" + | grep -v "CRLF" | grep -v 'custom\/' | grep -v 'documents\/website' | grep -v 'documents\/medias' | grep -v 'documents\/sellyoursaas' | grep CRLF | awk -F':' '{ print $1 }' `
do
echo "Fix file $fic"
dos2unix "$fic"
diff --git a/dev/tools/optimize_images.sh b/dev/tools/optimize_images.sh
index dd538c5e1aa..89717063006 100755
--- a/dev/tools/optimize_images.sh
+++ b/dev/tools/optimize_images.sh
@@ -39,13 +39,14 @@ optimize_image()
max_input_size=$(expr $max_input_size + $input_file_size)
if [ "${1##*.}" = "png" ]; then
- #optipng -o1 -clobber -quiet $1 -out $2.firstpass
- optipng -o1 -quiet $1 -out $2.firstpass
- pngcrush -q -rem alla -reduce $2.firstpass $2 >/dev/null
- rm -fr $2.firstpass
+ #optipng -o1 -clobber -quiet "$1" -out "$2.firstpass"
+ echo optipng -o1 -quiet "$1" -out "$2.firstpass"
+ optipng -o1 -quiet "$1" -out "$2.firstpass"
+ pngcrush -q -rem alla -reduce "$2.firstpass" "$2" >/dev/null
+ rm -fr "$2.firstpass"
fi
if [ "${1##*.}" = "jpg" -o "${1##*.}" = "jpeg" ]; then
- jpegtran -copy none -progressive $1 > $2
+ jpegtran -copy none -progressive "$1" > $2
fi
output_file_size=$(stat -c%s "$2")
@@ -120,8 +121,8 @@ main()
# Search of all jpg/jpeg/png in $INPUT
# We remove images from $OUTPUT if $OUTPUT is a subdirectory of $INPUT
- echo "Scan $INPUT to find images"
- IMAGES=$(find $INPUT -regextype posix-extended -regex '.*\.(jpg|jpeg|png)' | grep -v $OUTPUT)
+ echo "Scan $INPUT to find images with find $INPUT -regextype posix-extended -regex '.*\.(jpg|jpeg|png)' | grep -v '/gource/' | grep -v '/includes/' | grep -v '/custom/' | grep -v $OUTPUT"
+ IMAGES=$(find $INPUT -regextype posix-extended -regex '.*\.(jpg|jpeg|png)' | grep -v '/gource/' | grep -v '/includes/' | grep -v '/custom/' | grep -v '/documents/' | grep -v $OUTPUT)
if [ "$QUIET" == "0" ]; then
echo --- Optimizing $INPUT ---
@@ -135,11 +136,11 @@ main()
printf '%*.*s' 0 $((linelength - ${#filename} - ${#sDone} )) "$pad"
fi
- optimize_image $CURRENT_IMAGE $OUTPUT/$filename
+ optimize_image "$CURRENT_IMAGE" "$OUTPUT/$filename"
# Replace file
if [[ "$INPLACE" == "1" ]]; then
- mv $OUTPUT/$filename $CURRENT_IMAGE
+ mv "$OUTPUT/$filename" "$CURRENT_IMAGE"
fi
if [ "$QUIET" == "0" ]; then
diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php
index 4d74237e2e4..f818e9a0a1a 100644
--- a/htdocs/accountancy/admin/account.php
+++ b/htdocs/accountancy/admin/account.php
@@ -52,8 +52,8 @@ $confirm = GETPOST('confirm', 'alpha');
$chartofaccounts = GETPOST('chartofaccounts', 'int');
-$permissiontoadd = !empty($user->rights->accounting->chartofaccount);
-$permissiontodelete = !empty($user->rights->accounting->chartofaccount);
+$permissiontoadd = $user->hasRight('accounting', 'chartofaccount');
+$permissiontodelete = $user->hasRight('accounting', 'chartofaccount');
// Security check
if ($user->socid > 0) {
@@ -294,7 +294,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
}
// List of mass actions available
-if ($user->rights->accounting->chartofaccount) {
+if ($user->hasRight('accounting', 'chartofaccount')) {
$arrayofmassactions['predelete'] = ''.$langs->trans("Delete");
}
if (in_array($massaction, array('presend', 'predelete', 'closed'))) {
@@ -590,7 +590,7 @@ if ($resql) {
// Action
print '
';
- if ($user->rights->accounting->chartofaccount) {
+ if ($user->hasRight('accounting', 'chartofaccount')) {
print '';
print img_edit();
print '';
diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php
index 02b95cfd043..5c1044380f9 100644
--- a/htdocs/accountancy/admin/card.php
+++ b/htdocs/accountancy/admin/card.php
@@ -66,7 +66,7 @@ if (GETPOST('cancel', 'alpha')) {
exit;
}
-if ($action == 'add' && $user->rights->accounting->chartofaccount) {
+if ($action == 'add' && $user->hasRight('accounting', 'chartofaccount')) {
if (!$cancel) {
if (!$account_number) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors');
@@ -127,7 +127,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) {
}
}
}
-} elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) {
+} elseif ($action == 'edit' && $user->hasRight('accounting', 'chartofaccount')) {
if (!$cancel) {
if (!$account_number) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors');
@@ -184,7 +184,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) {
header("Location: ".$urltogo);
exit();
}
-} elseif ($action == 'delete' && $user->rights->accounting->chartofaccount) {
+} elseif ($action == 'delete' && $user->hasRight('accounting', 'chartofaccount')) {
$result = $object->fetch($id);
if (!empty($object->id)) {
@@ -419,13 +419,13 @@ if ($action == 'create') {
*/
print '';
- if (!empty($user->rights->accounting->chartofaccount)) {
+ if ($user->hasRight('accounting', 'chartofaccount')) {
print ' id.'">'.$langs->trans('Modify').'';
} else {
print ' '.$langs->trans('Modify').'';
}
- if (!empty($user->rights->accounting->chartofaccount)) {
+ if ($user->hasRight('accounting', 'chartofaccount')) {
print ' id.'">'.$langs->trans('Delete').'';
} else {
print ' '.$langs->trans('Delete').'';
diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php
index 2eb77815b60..6a6135dad40 100644
--- a/htdocs/accountancy/admin/fiscalyear.php
+++ b/htdocs/accountancy/admin/fiscalyear.php
@@ -121,7 +121,7 @@ if ($result) {
$i = 0;
- $addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write);
+ $addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->hasRight('accounting', 'fiscalyear', 'write'));
$title = $langs->trans('AccountingPeriods');
diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php
index 2aa33f21645..f6e765caf13 100644
--- a/htdocs/accountancy/admin/fiscalyear_card.php
+++ b/htdocs/accountancy/admin/fiscalyear_card.php
@@ -299,7 +299,7 @@ if ($action == 'create') {
/*
* Action bar
*/
- if (!empty($user->rights->accounting->fiscalyear->write)) {
+ if ($user->hasRight('accounting', 'fiscalyear', 'write')) {
print ' ';
print ' '.$langs->trans('Modify').'';
diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php
index c8cb62cd7e0..d520c82bf35 100644
--- a/htdocs/accountancy/admin/productaccount.php
+++ b/htdocs/accountancy/admin/productaccount.php
@@ -522,7 +522,7 @@ if ($resql) {
// Filter on categories
$moreforfilter = '';
- if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
+ if (!empty($conf->categorie->enabled) && $user->hasRight('categorie', 'lire')) {
$moreforfilter .= ' ';
$moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"');
$categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1);
diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php
index d805838566f..c8948b05012 100644
--- a/htdocs/accountancy/class/accountingjournal.class.php
+++ b/htdocs/accountancy/class/accountingjournal.class.php
@@ -281,7 +281,7 @@ class AccountingJournal extends CommonObject
}
$label_link = $this->code;
- if ($withlabel) {
+ if ($withlabel && !empty($this->label)) {
$label_link .= ' - '.($nourl ? ' ' : '').$langs->transnoentities($this->label).($nourl ? '' : '');
}
diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php
index a1d75440b56..999e2ce5bd1 100644
--- a/htdocs/accountancy/closure/index.php
+++ b/htdocs/accountancy/closure/index.php
@@ -75,7 +75,7 @@ if (empty($user->rights->accounting->fiscalyear->write)) {
$now = dol_now();
-if ($action == 'validate_movements_confirm' && !empty($user->rights->accounting->fiscalyear->write)) {
+if ($action == 'validate_movements_confirm' && $user->hasRight('accounting', 'fiscalyear', 'write')) {
$date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php
index 926097c1509..f6f86461d9b 100644
--- a/htdocs/accountancy/index.php
+++ b/htdocs/accountancy/index.php
@@ -49,7 +49,7 @@ if (empty($user->rights->accounting->mouvements->lire)) {
if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled) && empty($conf->asset->enabled) && empty($conf->intracommreport->enabled)) {
accessforbidden();
}
-if (empty($user->hasRight('compta', 'resultat', 'lire')) && empty($user->hasRight('accounting', 'comptarapport', 'lire')) && empty($user->hasRight('accounting', 'mouvements', 'lire')) && empty($user->hasRight('asset', 'read')) && empty($user->hasRight('intracommreport', 'read'))) {
+if (!$user->hasRight('compta', 'resultat', 'lire') && !$user->hasRight('accounting', 'comptarapport', 'lire') && !$user->hasRight('accounting', 'mouvements', 'lire') && !$user->hasRight('asset', 'read') && !$user->hasRight('intracommreport', 'read')) {
accessforbidden();
}
diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index fbc3eefd641..c311bf80d1d 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -583,9 +583,8 @@ if (empty($reshook)) {
} else {
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
-
}
-
+
// Auto-create thirdparty on member creation
if (!empty($conf->global->ADHERENT_DEFAULT_CREATE_THIRDPARTY)) {
if ($result > 0) {
@@ -1540,7 +1539,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Create form popup
$formquestion = array();
if ($object->email) {
- $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL ?true:false));
+ $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? true : false));
}
if (!empty($conf->mailman->enabled) && !empty($conf->global->ADHERENT_USE_MAILMAN)) {
$formquestion[] = array('type'=>'other', 'label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"), 'value'=>'');
@@ -1571,7 +1570,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$outputlangs->loadLangs(array("main", "members"));
// Get email content from template
$arraydefaultmessage = null;
- $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
+ $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_CANCELATION');
if (!empty($labeltouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 318dc4ac794..36efd3bc7d1 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -972,10 +972,10 @@ class Adherent extends CommonObject
}
/**
- * Fonction qui supprime l'adherent et les donnees associees
+ * Fonction to delete a member and its data
*
* @param int $rowid Id of member to delete
- * @param User $user User object
+ * @param User $user User object
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, 0=nothing to do, >0 if OK
*/
@@ -1826,7 +1826,7 @@ class Adherent extends CommonObject
if (!$error) {
// Create payment line for invoice
$paiement_id = $paiement->create($user);
- if (!$paiement_id > 0) {
+ if (!($paiement_id > 0)) {
$this->error = $paiement->error;
$this->errors = $paiement->errors;
$error++;
diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php
index 86ec35139e1..12735e70211 100644
--- a/htdocs/adherents/class/adherent_type.class.php
+++ b/htdocs/adherents/class/adherent_type.class.php
@@ -440,6 +440,7 @@ class AdherentType extends CommonObject
/**
* Function to delete the member's status
+ * TODO Add param "User $user"
*
* @return int > 0 if OK, 0 if not found, < 0 if KO
*/
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index e37d52480fa..b40d7772e99 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -41,6 +41,7 @@ $langs->load("members");
$rowid = GETPOST('rowid', 'int');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
+$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
$sall = GETPOST("sall", "alpha");
@@ -202,7 +203,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) {
exit;
}
-if ($action == 'confirm_delete' && $user->rights->adherent->configurer) {
+if ($action == 'confirm_delete' && !empty($user->rights->adherent->configurer)) {
$object->fetch($rowid);
$res = $object->delete();
@@ -448,7 +449,7 @@ if ($rowid > 0) {
print ' ';
print ' ';
- print ' ';
+ print '';
// Morphy
print '| '.$langs->trans("MembersNature").' | '.$object->getmorphylib($object->morphy).' | ';
@@ -682,20 +683,23 @@ if ($rowid > 0) {
print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
print " \n";
- while ($i < $num && $i < $conf->liste_limit) {
+ $adh = new Adherent($db);
+
+ $imaxinloop = ($limit ? min($num, $limit) : $num);
+ while ($i < $imaxinloop) {
$objp = $db->fetch_object($resql);
$datefin = $db->jdate($objp->datefin);
- $adh = new Adherent($db);
$adh->lastname = $objp->lastname;
$adh->firstname = $objp->firstname;
$adh->datefin = $datefin;
$adh->need_subscription = $objp->subscription;
$adh->statut = $objp->status;
- // Lastname
print '';
+
+ // Lastname
if ($objp->company != '') {
print '| '.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->company, 12).' | '."\n";
} else {
@@ -703,7 +707,7 @@ if ($rowid > 0) {
}
// Login
- print "".$objp->login." | \n";
+ print "".dol_escape_htmltag($objp->login)." | \n";
// Type
/*print '';
@@ -760,11 +764,15 @@ if ($rowid > 0) {
$i++;
}
+ if ($i == 0) {
+ print ' | | '.$langs->trans("None").' | ';
+ }
+
print " \n";
print '';
print '';
- if ($num > $conf->liste_limit) {
+ if ($num > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
}
} else {
diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php
index 72976d4e65f..d7d062a1e5f 100644
--- a/htdocs/adherents/type_translation.php
+++ b/htdocs/adherents/type_translation.php
@@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
// Load translation files required by the page
$langs->loadLangs(array('members', 'languages'));
-$id = GETPOST('rowid', 'int');
+$id = GETPOST('rowid', 'int') ? GETPOST('rowid', 'int') : GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$ref = GETPOST('ref', 'alphanohtml');
@@ -61,7 +61,12 @@ if ($cancel == $langs->trans("Cancel")) {
if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) {
$object = new AdherentType($db);
$object->fetch($id);
- $object->delMultiLangs(GETPOST('langtodelete', 'alpha'), $user);
+ $result = $object->delMultiLangs(GETPOST('langtodelete', 'alpha'), $user);
+ if ($result > 0) {
+ setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
+ header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id);
+ exit;
+ }
}
// Add translation
diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php
index 5567e741272..6e0a6e9085f 100644
--- a/htdocs/admin/agenda_extsites.php
+++ b/htdocs/admin/agenda_extsites.php
@@ -66,7 +66,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) {
$value = (GETPOST($code) ? GETPOST($code) : 1);
$res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
- if (!$res > 0) {
+ if (!($res > 0)) {
$error++;
$errors[] = $db->lasterror();
}
@@ -86,7 +86,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) {
$code = $reg[1];
$res = dolibarr_del_const($db, $code, $conf->entity);
- if (!$res > 0) {
+ if (!($res > 0)) {
$error++;
$errors[] = $db->lasterror();
}
diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php
index a2db7bf8fcf..31d0776da6b 100644
--- a/htdocs/admin/contract.php
+++ b/htdocs/admin/contract.php
@@ -142,7 +142,7 @@ if ($action == 'updateMask') {
$value = GETPOST('activate_hideClosedServiceByDefault', 'alpha');
$res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity);
- if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) {
+ if (!($res1 > 0) || !($res2 > 0) || !($res3 > 0)) {
$error++;
}
diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php
index 8195683c5ab..6672f04a1af 100644
--- a/htdocs/admin/debugbar.php
+++ b/htdocs/admin/debugbar.php
@@ -90,12 +90,12 @@ print '';
print '';
print '';
print '| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' | ';
-print ' | ';
+print ' | ';
print " \n";
print '| '.$langs->trans("DEBUGBAR_USE_LOG_FILE").' | ';
print '';
-print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1);
+print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', !empty($conf->global->DEBUGBAR_USE_LOG_FILE), 1);
print ' | ';
print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower").'';
print ' | ';
diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php
index 05df4187130..66c6cc9a204 100644
--- a/htdocs/admin/eventorganization.php
+++ b/htdocs/admin/eventorganization.php
@@ -228,14 +228,14 @@ if ($action == 'edit') {
if ($val['type'] == 'textarea') {
print '\n";
} elseif ($val['type']== 'html') {
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
- $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
+ $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
$doleditor->Create();
} elseif ($val['type'] == 'yesno') {
- print $form->selectyesno($constname, $conf->global->{$constname}, 1);
+ print $form->selectyesno($constname, getDolGlobalString($constname), 1);
} elseif (preg_match('/emailtemplate:/', $val['type'])) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
@@ -255,7 +255,7 @@ if ($action == 'edit') {
$arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel;
}
}
- print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
+ print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
} elseif (preg_match('/category:/', $val['type'])) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@@ -263,13 +263,13 @@ if ($action == 'edit') {
$tmp = explode(':', $val['type']);
print img_picto('', 'category', 'class="pictofixedwidth"');
- print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
+ print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
} elseif (preg_match('/thirdparty_type/', $val['type'])) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$formcompany = new FormCompany($db);
- print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname, 'customerorprospect', 'form', '', 1);
+ print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname, 'customerorprospect', 'form', '', 1);
} elseif ($val['type'] == 'securekey') {
- print '';
+ print '';
if (!empty($conf->use_javascript_ajax)) {
print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
}
@@ -283,7 +283,7 @@ if ($action == 'edit') {
$form->select_produits($selected, $constname, '', 0);
}
} else {
- print '';
+ print '';
}
print '';
}
@@ -309,28 +309,28 @@ if ($action == 'edit') {
print '';
if ($val['type'] == 'textarea') {
- print dol_nl2br($conf->global->{$constname});
+ print dol_nl2br(getDolGlobalString($constname));
} elseif ($val['type']== 'html') {
- print $conf->global->{$constname};
+ print getDolGlobalString($constname);
} elseif ($val['type'] == 'yesno') {
print ajax_constantonoff($constname);
} elseif (preg_match('/emailtemplate:/', $val['type'])) {
- if (!empty($conf->global->{$constname})) {
+ if (getDolGlobalString($constname)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$tmp = explode(':', $val['type']);
- $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
+ $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
if ($template < 0) {
setEventMessages(null, $formmail->errors, 'errors');
}
print $langs->trans($template->label);
}
} elseif (preg_match('/category:/', $val['type'])) {
- if (!empty($conf->global->{$constname})) {
+ if (getDolGlobalString($constname)) {
$c = new Categorie($db);
- $result = $c->fetch($conf->global->{$constname});
+ $result = $c->fetch(getDolGlobalString($constname));
if ($result < 0) {
setEventMessages(null, $c->errors, 'errors');
}
@@ -342,25 +342,25 @@ if ($action == 'edit') {
print '' . implode(' ', $toprint) . ' ';
}
} elseif (preg_match('/thirdparty_type/', $val['type'])) {
- if ($conf->global->{$constname}==2) {
+ if (getDolGlobalString($constname)==2) {
print $langs->trans("Prospect");
- } elseif ($conf->global->{$constname}==3) {
+ } elseif (getDolGlobalString($constname)==3) {
print $langs->trans("ProspectCustomer");
- } elseif ($conf->global->{$constname}==1) {
+ } elseif (getDolGlobalString($constname)==1) {
print $langs->trans("Customer");
- } elseif ($conf->global->{$constname}==0) {
+ } elseif (getDolGlobalString($constname)==0) {
print $langs->trans("NorProspectNorCustomer");
}
} elseif ($val['type'] == 'product') {
$product = new Product($db);
- $resprod = $product->fetch($conf->global->{$constname});
+ $resprod = $product->fetch(getDolGlobalString($constname));
if ($resprod > 0) {
print $product->getNomUrl(1);
} elseif ($resprod < 0) {
- setEventMessages(null, $object->errors, "errors");
+ setEventMessages($product->error, $product->errors, "errors");
}
} else {
- print $conf->global->{$constname};
+ print getDolGlobalString($constname);
}
print ' | ';
}
diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php
index e662c0576a2..c002c9059d7 100644
--- a/htdocs/admin/geoipmaxmind.php
+++ b/htdocs/admin/geoipmaxmind.php
@@ -59,12 +59,12 @@ if ($action == 'set') {
if (!$error) {
$res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity);
- if (!$res1 > 0) {
+ if (!($res1 > 0)) {
$error++;
}
$res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity);
- if (!$res2 > 0) {
+ if (!($res2 > 0)) {
$error++;
}
diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php
index c3c58984dc0..5902402674d 100644
--- a/htdocs/admin/holiday.php
+++ b/htdocs/admin/holiday.php
@@ -141,7 +141,7 @@ if ($action == 'updateMask') {
$draft = GETPOST('HOLIDAY_DRAFT_WATERMARK', 'alpha');
$res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
- if (!$res1 > 0 || !$res2 > 0) {
+ if (!($res1 > 0) || !($res2 > 0)) {
$error++;
}
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index 6d461b525bc..0c12ba1a3a0 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -178,63 +178,63 @@ $elementList = array();
$elementList['all'] = '-- '.dol_escape_htmltag($langs->trans("All")).' --';
$elementList['none'] = '-- '.dol_escape_htmltag($langs->trans("None")).' --';
-$elementList['user'] = img_picto('', 'user', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToUser'));
+$elementList['user'] = img_picto('', 'user', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToUser'));
if (!empty($conf->adherent->enabled) && !empty($user->rights->adherent->lire)) {
- $elementList['member'] = img_picto('', 'object_member', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToMember'));
+ $elementList['member'] = img_picto('', 'object_member', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToMember'));
}
if (!empty($conf->recruitment->enabled) && !empty($user->rights->recruitment->recruitmentjobposition->read)) {
- $elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="paddingright"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures'));
+ $elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures'));
}
if (!empty($conf->societe->enabled) && !empty($user->rights->societe->lire)) {
- $elementList['thirdparty'] = img_picto('', 'company', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToThirdparty'));
+ $elementList['thirdparty'] = img_picto('', 'company', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToThirdparty'));
}
if (!empty($conf->project->enabled)) {
- $elementList['project'] = img_picto('', 'project', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToProject'));
+ $elementList['project'] = img_picto('', 'project', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToProject'));
}
if (!empty($conf->propal->enabled) && !empty($user->rights->propal->lire)) {
- $elementList['propal_send'] = img_picto('', 'propal', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendProposal'));
+ $elementList['propal_send'] = img_picto('', 'propal', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendProposal'));
}
if (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) {
- $elementList['order_send'] = img_picto('', 'order', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendOrder'));
+ $elementList['order_send'] = img_picto('', 'order', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendOrder'));
}
if (isModEnabled('facture') && !empty($user->rights->facture->lire)) {
- $elementList['facture_send'] = img_picto('', 'bill', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendInvoice'));
+ $elementList['facture_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendInvoice'));
}
if (!empty($conf->expedition->enabled)) {
- $elementList['shipping_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendShipment'));
+ $elementList['shipping_send'] = img_picto('', 'dolly', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendShipment'));
}
if (!empty($conf->reception->enabled)) {
- $elementList['reception_send'] = img_picto('', 'dollyrevert', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendReception'));
+ $elementList['reception_send'] = img_picto('', 'dollyrevert', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendReception'));
}
if (!empty($conf->ficheinter->enabled)) {
- $elementList['fichinter_send'] = img_picto('', 'intervention', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendIntervention'));
+ $elementList['fichinter_send'] = img_picto('', 'intervention', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendIntervention'));
}
if (!empty($conf->supplier_proposal->enabled)) {
- $elementList['supplier_proposal_send'] = img_picto('', 'propal', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierRequestForQuotation'));
+ $elementList['supplier_proposal_send'] = img_picto('', 'propal', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierRequestForQuotation'));
}
if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->commande->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire))) {
- $elementList['order_supplier_send'] = img_picto('', 'order', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierOrder'));
+ $elementList['order_supplier_send'] = img_picto('', 'order', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierOrder'));
}
if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire))) {
- $elementList['invoice_supplier_send'] = img_picto('', 'bill', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierInvoice'));
+ $elementList['invoice_supplier_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierInvoice'));
}
if (!empty($conf->contrat->enabled) && !empty($user->rights->contrat->lire)) {
- $elementList['contract'] = img_picto('', 'contract', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendContract'));
+ $elementList['contract'] = img_picto('', 'contract', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendContract'));
}
if (!empty($conf->ticket->enabled) && !empty($user->rights->ticket->read)) {
- $elementList['ticket_send'] = img_picto('', 'ticket', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToTicket'));
+ $elementList['ticket_send'] = img_picto('', 'ticket', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToTicket'));
}
if (!empty($conf->expensereport->enabled) && !empty($user->rights->expensereport->lire)) {
- $elementList['expensereport_send'] = img_picto('', 'trip', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToTExpenseReport'));
+ $elementList['expensereport_send'] = img_picto('', 'trip', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToExpenseReport'));
}
if (isModEnabled('agenda')) {
- $elementList['actioncomm_send'] = img_picto('', 'action', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendEventPush'));
+ $elementList['actioncomm_send'] = img_picto('', 'action', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendEventPush'));
}
if (!empty($conf->eventorganization->enabled) && !empty($user->rights->eventorganization->read)) {
- $elementList['conferenceorbooth'] = img_picto('', 'action', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendEventOrganization'));
+ $elementList['conferenceorbooth'] = img_picto('', 'action', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendEventOrganization'));
}
if (!empty($conf->partnership->enabled) && !empty($user->rights->partnership->read)) {
- $elementList['partnership_send'] = img_picto('', 'partnership', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToPartnership'));
+ $elementList['partnership_send'] = img_picto('', 'partnership', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToPartnership'));
}
$parameters = array('elementList'=>$elementList);
diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php
index 00daaf01e27..f9b5b37ec4d 100644
--- a/htdocs/admin/oauthlogintokens.php
+++ b/htdocs/admin/oauthlogintokens.php
@@ -77,7 +77,7 @@ if ($action == 'setconst' && $user->admin) {
$constnote = dol_escape_htmltag($setupconst['note']);
$result = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
- if (!$result > 0) {
+ if (!($result > 0)) {
$error++;
}
}
@@ -96,7 +96,7 @@ if ($action == 'setvalue' && $user->admin) {
$db->begin();
$result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity);
- if (!$result > 0) {
+ if (!($result > 0)) {
$error++;
}
diff --git a/htdocs/admin/stocktransfer.php b/htdocs/admin/stocktransfer.php
index 0e504ec26f1..099312ef491 100644
--- a/htdocs/admin/stocktransfer.php
+++ b/htdocs/admin/stocktransfer.php
@@ -78,9 +78,10 @@ if ($action == 'updateMask') {
$maskconststocktransfer = GETPOST('maskconststocktransfer', 'alpha');
$maskstocktransfer = GETPOST('maskStockTransfer', 'alpha');
- if ($maskconststocktransfer) $res = dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer, 'chaine', 0, '', $conf->entity);
-
- if (!$res > 0) $error++;
+ if ($maskconststocktransfer) {
+ $res = dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer, 'chaine', 0, '', $conf->entity);
+ if ($res <= 0) $error++;
+ }
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php
index ea5069cb840..37db04868cb 100644
--- a/htdocs/blockedlog/class/blockedlog.class.php
+++ b/htdocs/blockedlog/class/blockedlog.class.php
@@ -361,11 +361,11 @@ class BlockedLog
$this->amounts = $amounts;
// date
if ($object->element == 'payment' || $object->element == 'payment_supplier') {
- $this->date_object = $object->datepaye;
+ $this->date_object = empty($object->datepaye) ? $object->date : $object->datepaye;
} elseif ($object->element == 'payment_salary') {
$this->date_object = $object->datev;
} elseif ($object->element == 'payment_donation' || $object->element == 'payment_various') {
- $this->date_object = $object->datepaid ? $object->datepaid : $object->datep;
+ $this->date_object = empty($object->datepaid) ? $object->datep : $object->datepaid;
} elseif ($object->element == 'subscription') {
$this->date_object = $object->dateh;
} elseif ($object->element == 'cashcontrol') {
@@ -527,7 +527,7 @@ class BlockedLog
$totalamount = 0;
- // Loop on each invoice payment amount
+ // Loop on each invoice payment amount (payment_part)
if (is_array($object->amounts) && !empty($object->amounts)) {
$paymentpartnumber = 0;
foreach ($object->amounts as $objid => $amount) {
diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php
index db62dfe6a9f..75cbefec3ec 100644
--- a/htdocs/comm/action/class/cactioncomm.class.php
+++ b/htdocs/comm/action/class/cactioncomm.class.php
@@ -216,7 +216,9 @@ class CActionComm
if ($obj->module == 'shipping' && !empty($conf->expedition->enabled) && !empty($user->rights->expedition->lire)) {
$qualified = 1;
}
- if (preg_split("/@/", $obj->module, -1)[1] == 'eventorganization' && !empty($conf->eventorganization->enabled)) {
+ // For case module = 'myobject@eventorganization'
+ $tmparray = preg_split("/@/", $obj->module, -1);
+ if (count($tmparray) > 1 && $tmparray[1] == 'eventorganization' && !empty($conf->eventorganization->enabled)) {
$qualified = 1;
}
// For the generic case with type = 'module...' and module = 'myobject@mymodule'
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 0521d203331..f4e1866613e 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2014 Laurent Destailleur
+/* Copyright (C) 2001-2007 Rodolphe Quiedeville
+ * Copyright (C) 2004-2022 Laurent Destailleur
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2005 Marc Barilley / Ocebo
* Copyright (C) 2005-2012 Regis Houssin
@@ -9,12 +9,12 @@
* Copyright (C) 2010-2021 Philippe Grand
* Copyright (C) 2012-2013 Christophe Battarel
* Copyright (C) 2012 Cedric Salvador
- * Copyright (C) 2013-2014 Florian Henry
- * Copyright (C) 2014 Ferran Marcet
- * Copyright (C) 2016 Marcos García
- * Copyright (C) 2018-2021 Frédéric France
- * Copyright (C) 2020 Nicolas ZABOURI
- * Copyright (C) 2022 Gauthier VERDOL
+ * Copyright (C) 2013-2014 Florian Henry
+ * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2016 Marcos García
+ * Copyright (C) 2018-2021 Frédéric France
+ * Copyright (C) 2020 Nicolas ZABOURI
+ * Copyright (C) 2022 Gauthier VERDOL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -88,9 +88,6 @@ $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') :
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
-// Nombre de ligne pour choix de produit/service predefinis
-$NBLINES = 4;
-
$object = new Propal($db);
$extrafields = new ExtraFields($db);
@@ -120,6 +117,7 @@ $usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreat
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->send)));
+$usermustrespectpricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
$usercancreateorder = $user->hasRight('commande', 'creer');
$usercancreateinvoice = $user->hasRight('facture', 'creer');
$usercancreatecontract = $user->hasRight('contrat', 'creer');
@@ -898,6 +896,9 @@ if (empty($reshook)) {
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
+ $price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
+ $price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
+
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free') {
$idprod = 0;
@@ -956,6 +957,7 @@ if (empty($reshook)) {
$pu_ht = 0;
$pu_ttc = 0;
$price_min = 0;
+ $price_min_ttc = 0;
$price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
$db->begin();
@@ -983,6 +985,7 @@ if (empty($reshook)) {
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_min = $prod->price_min;
+ $price_min_ttc = $prod->price_min_ttc;
$price_base_type = $prod->price_base_type;
// If price per segment
@@ -990,6 +993,7 @@ if (empty($reshook)) {
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
+ $price_min_ttc = $prod->multiprices_min_ttc[$object->thirdparty->price_level];
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility
if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) {
@@ -1014,6 +1018,7 @@ if (empty($reshook)) {
$pu_ht = price($prodcustprice->lines[0]->price);
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
$price_min = price($prodcustprice->lines[0]->price_min);
+ $price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
$price_base_type = $prodcustprice->lines[0]->price_base_type;
$tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx);
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
@@ -1119,18 +1124,6 @@ if (empty($reshook)) {
$desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
}
- // Add dimensions into product description
- /*if (empty($conf->global->MAIN_PRODUCT_DISABLE_AUTOADD_DIM))
- {
- $text='';
- if ($prod->weight) $text.=($text?"\n":"").$outputlangs->trans("Weight").': '.$prod->weight.' '.$prod->weight_units;
- if ($prod->length) $text.=($text?"\n":"").$outputlangs->trans("Length").': '.$prod->length.' '.$prod->length_units;
- if ($prod->surface) $text.=($text?"\n":"").$outputlangs->trans("Surface").': '.$prod->surface.' '.$prod->surface_units;
- if ($prod->volume) $text.=($text?"\n":"").$outputlangs->trans("Volume").': '.$prod->volume.' '.$prod->volume_units;
-
- $desc = dol_concatdesc($desc, $text);
- }*/
-
// Add custom code and origin country into description
if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
$tmptxt = '(';
@@ -1186,6 +1179,7 @@ if (empty($reshook)) {
$fk_unit = GETPOST('units', 'alpha');
$pu_ht_devise = price2num($price_ht_devise, 'MU');
+ $pu_ttc_devise = price2num($price_ttc_devise, 'MU');
}
// Margin
@@ -1204,10 +1198,22 @@ if (empty($reshook)) {
$info_bits |= 0x01;
}
- if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) {
- $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
- setEventMessages($mesg, null, 'errors');
- } else {
+ //var_dump(price2num($price_min)); var_dump(price2num($pu_ht)); var_dump($remise_percent);
+ //var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
+
+ if ($usermustrespectpricemin) {
+ if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ }
+ }
+
+ if (!$error) {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise);
@@ -1285,12 +1291,14 @@ if (empty($reshook)) {
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
+ $pu_ttc = price2num(GETPOST('price_ttc'), '', 2);
// Add buying price
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
+ //$pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2);
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
@@ -1321,16 +1329,32 @@ if (empty($reshook)) {
$res = $product->fetch($productid);
$type = $product->type;
+ $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
$price_min = $product->price_min;
if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
- $price_min = $product->multiprices_min [$object->thirdparty->price_level];
+ $price_min = $product->multiprices_min[$object->thirdparty->price_level];
+ }
+ $price_min_ttc = $product->price_min_ttc;
+ if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
+ $price_min_ttc = $product->multiprices_min_ttc[$object->thirdparty->price_level];
}
- $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
- if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - $remise_percent / 100) < price2num($price_min)))) {
- setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
- $error++;
+ //var_dump(price2num($price_min)); var_dump(price2num($pu_ht)); var_dump($remise_percent);
+ //var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
+
+ if ($usermustrespectpricemin) {
+ if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ $action = 'editline';
+ } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ $action = 'editline';
+ }
}
} else {
$type = GETPOST('type');
@@ -2675,6 +2699,11 @@ if ($action == 'create') {
// Show object lines
$result = $object->getLinesArray();
+ // Add products/services form
+ //$forceall = 1;
+ global $inputalsopricewithtax;
+ $inputalsopricewithtax = 1;
+
print ' |