diff --git a/.travis.yml b/.travis.yml
index d5583ef6ff2..3a996915ca7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -347,7 +347,7 @@ script:
mysql -e 'DROP DATABASE IF EXISTS travis;'
mysql -e 'CREATE DATABASE IF NOT EXISTS travis;'
mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;'
- mysql -e 'FLUSH PRIVILEGES;'
+ mysql -e 'FLUSH PRIVILEGES;'
mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
fi
if [ "$DB" = 'postgresql' ]; then
@@ -362,7 +362,7 @@ script:
#echo 'ALTER TABLE "llx_accounting_account" DROP CONSTRAINT "idx_16390_primary"' | psql travis
fi
echo
-
+
- |
echo "Upgrading Dolibarr"
# Ensure we catch errors. Set this to +e if you want to go to the end to see log files.
diff --git a/ChangeLog b/ChangeLog
index c6b3ee2d89b..d028491db42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,7 +30,7 @@ Following changes may create regressions for some external modules, but were nec
***** ChangeLog for 10.0.3 compared to 10.0.2 *****
IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card.
The unit were not saved correctly in database making calculation on shipments wrong.
-Update to this version must be done if you use them and have installed version 10.0.0, 10.0.1 or 10.0.2 and set some products after installing or upgrading to this version.
+Update to this version must be done if you use them and have installed version 10.0.0, 10.0.1 or 10.0.2 and set some products after installing or upgrading to one of this version.
Once update is done you must then edit (manually) the product that has bad unit to set the correct unit to have features restored.
FIX: #11702
@@ -92,6 +92,9 @@ FIX: Update of leave request when CSRF with token is on
FIX: Var not enough sanitized
FIX: wrong test
FIX: XSS
+FIX: Payment from POS ware not recorded.
+FIX: Can validate invoice with amount including tax of zero for the case of having a final invoice with
+ VAT that includes a deposit without vat.
***** ChangeLog for 10.0.2 compared to 10.0.1 *****
FIX: #10460 compatibility with MariaDB 10.4
diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php
index 4cf2401d51b..0460f31af30 100644
--- a/htdocs/accountancy/admin/index.php
+++ b/htdocs/accountancy/admin/index.php
@@ -88,11 +88,11 @@ if ($action == 'setlistsorttodo') {
if (! $res > 0)
$error ++;
- if (! $error) {
- setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
- } else {
- setEventMessages($langs->trans("Error"), null, 'mesgs');
- }
+ if (! $error) {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ } else {
+ setEventMessages($langs->trans("Error"), null, 'mesgs');
+ }
}
if ($action == 'setlistsortdone') {
@@ -100,11 +100,11 @@ if ($action == 'setlistsortdone') {
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
- if (! $error) {
- setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
- } else {
- setEventMessages($langs->trans("Error"), null, 'mesgs');
- }
+ if (! $error) {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ } else {
+ setEventMessages($langs->trans("Error"), null, 'mesgs');
+ }
}
if ($action == 'setmanagezero') {
@@ -112,11 +112,11 @@ if ($action == 'setmanagezero') {
$res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
- if (! $error) {
- setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
- } else {
- setEventMessages($langs->trans("Error"), null, 'mesgs');
- }
+ if (! $error) {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ } else {
+ setEventMessages($langs->trans("Error"), null, 'mesgs');
+ }
}
if ($action == 'setdisabledirectinput') {
@@ -124,11 +124,11 @@ if ($action == 'setdisabledirectinput') {
$res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
- if (! $error) {
- setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
- } else {
- setEventMessages($langs->trans("Error"), null, 'mesgs');
- }
+ if (! $error) {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ } else {
+ setEventMessages($langs->trans("Error"), null, 'mesgs');
+ }
}
if ($action == 'setenabledraftexport') {
@@ -136,11 +136,11 @@ if ($action == 'setenabledraftexport') {
$res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity);
if (! $res > 0)
$error ++;
- if (! $error) {
- setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
- } else {
- setEventMessages($langs->trans("Error"), null, 'mesgs');
- }
+ if (! $error) {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ } else {
+ setEventMessages($langs->trans("Error"), null, 'mesgs');
+ }
}
if ($action == 'setenablesubsidiarylist') {
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index 96520c4756c..c15ace96ffc 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -180,8 +180,6 @@ if ($massaction == 'ventil') {
}
$msg.='';
$msg.= '
';
}
@@ -512,8 +514,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
If not used by a module, I still need to understand in which case user may need this now we can set rule on product page.
if ($conf->global->PRODUIT_SOUSPRODUITS)
{
-
-
print '
-
- element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines
- {
- $coldisplay++;
- ?>
-
-
-
- info_bits & 2) != 2) {
- // I comment this because it shows info even when not required
- // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated
- // must also not be output for most entities (proposal, intervention, ...)
- //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
- print '';
- }
- ?>
-
-
fk_product > 0) {
+ $tmpproduct = new Product($object->db);
+ $tmpproduct->fetch($line->fk_product);
+ print $tmpproduct->getNomUrl(1);
+}
+
+if (is_object($hookmanager))
+{
+ $fk_parent_line = (GETPOST('fk_parent_line') ? GETPOST('fk_parent_line') : $line->fk_parent_line);
+ $parameters=array('line'=>$line,'fk_parent_line'=>$fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer);
+ $reshook=$hookmanager->executeHooks('formEditProductOptions', $parameters, $this, $action);
+}
+
+print '';
+
+/*if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines
+{
+ $coldisplay++;
+?>
+
+';
+if (($line->info_bits & 2) != 2) {
+ // I comment this because it shows info even when not required
+ // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated
+ // must also not be output for most entities (proposal, intervention, ...)
+ //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." ";
+ print '';
+}
+print '';
+
+if ($conf->global->PRODUCT_USE_UNITS)
+{
+ $coldisplay++;
+ print '
';
+$coldisplay++;
+echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price
+print '
\n";
}
-?>
-
+echo "\n";
diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php
index 583d7426757..cbecd9cbc05 100644
--- a/htdocs/compta/accounting-files.php
+++ b/htdocs/compta/accounting-files.php
@@ -294,7 +294,18 @@ if ($result && $action == "dl" && ! $error)
dol_mkdir($dirfortmpfile);
- $log=$langs->transnoentitiesnoconv("Type").','.$langs->transnoentitiesnoconv("Date").','.$langs->transnoentitiesnoconv("Ref").','.$langs->transnoentitiesnoconv("TotalHT").','.$langs->transnoentitiesnoconv("TotalTTC").','.$langs->transnoentitiesnoconv("TotalVAT").','.$langs->transnoentitiesnoconv("Paid").',filename,item_id,'.$langs->transnoentitiesnoconv("ThirdParty").','.$langs->transnoentitiesnoconv("Code").','.$langs->transnoentitiesnoconv("Country").','.$langs->transnoentitiesnoconv("VATIntra")."\n";
+ $log = $langs->transnoentitiesnoconv("Type");
+ $log .= ',' . $langs->transnoentitiesnoconv("Date");
+ $log .= ',' . $langs->transnoentitiesnoconv("Ref");
+ $log .= ',' . $langs->transnoentitiesnoconv("TotalHT");
+ $log .= ',' . $langs->transnoentitiesnoconv("TotalTTC");
+ $log .= ',' . $langs->transnoentitiesnoconv("TotalVAT");
+ $log .= ',' . $langs->transnoentitiesnoconv("Paid");
+ $log .= ',filename,item_id';
+ $log .= ',' . $langs->transnoentitiesnoconv("ThirdParty");
+ $log .= ',' . $langs->transnoentitiesnoconv("Code");
+ $log .= ',' . $langs->transnoentitiesnoconv("Country");
+ $log .= ',' . $langs->transnoentitiesnoconv("VATIntra")."\n";
$zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip';
dol_delete_file($zipname);
@@ -305,8 +316,20 @@ if ($result && $action == "dl" && ! $error)
{
foreach ($filesarray as $key => $file)
{
- if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); //
- $log.=$file['item'].','.dol_print_date($file['date'], 'dayrfc').','.$file['ref'].','.$file['amount_ht'].','.$file['amount_ttc'].','.$file['amount_vat'].','.$file['paid'].','.$file["name"].','.$file['fk'].','.$file['thirdparty_name'].','.$file['thirdparty_code'].','.$file['country_code'].',"'.$file['vatnum'].'"'."\n";
+ if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]);
+ $log .= $file['item'];
+ $log .= ',' . dol_print_date($file['date'], 'dayrfc');
+ $log .= ',' . $file['ref'];
+ $log .= ',' . $file['amount_ht'];
+ $log .= ',' . $file['amount_ttc'];
+ $log .= ',' . $file['amount_vat'];
+ $log .= ',' . $file['paid'];
+ $log .= ',' . $file["name"];
+ $log .= ',' . $file['fk'];
+ $log .= ',' . $file['thirdparty_name'];
+ $log .= ',' . $file['thirdparty_code'];
+ $log .= ',' . $file['country_code'];
+ $log .= ',"' . $file['vatnum'].'"'."\n";
}
$zip->addFromString('transactions.csv', $log);
$zip->close();
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index f264bb074b3..cabd2c75fa4 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -278,8 +278,11 @@ if (empty($reshook))
$action = '';
}
} else {
- // Si non avoir, le signe doit etre positif
- if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ht < 0) {
+ // If not a credit note, amount with tax must be positive or nul.
+ // Note that amount excluding tax can be negative because you can have a invoice of 100 with vat of 20 that
+ // consumes a credit note of 100 with vat 0 (total with tax is 0 but without tax is -20).
+ // For some cases, credit notes can have a vat of 0 (for example when selling goods in France).
+ if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ttc < 0) {
setEventMessages($langs->trans("ErrorInvoiceOfThisTypeMustBePositive"), null, 'errors');
$action = '';
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 84835fa9608..0cb6921a6f3 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -2702,45 +2702,74 @@ class Facture extends CommonInvoice
/**
- * Add an invoice line into database (linked to product/service or not).
- * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
- * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
- * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
- * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
+ * Add an invoice line into database (linked to product/service or not).
+ * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
+ * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
+ * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
+ * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
*
- * @param string $desc Description of line
- * @param double $pu_ht Unit price without tax (> 0 even for credit note)
- * @param double $qty Quantity
- * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)')
- * @param double $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside)
- * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside)
- * @param int $fk_product Id of predefined product/service
- * @param double $remise_percent Percent of discount on line
- * @param int $date_start Date start of service
- * @param int $date_end Date end of service
- * @param int $ventil Code of dispatching into accountancy
- * @param int $info_bits Bits of type of lines
- * @param int $fk_remise_except Id discount used
- * @param string $price_base_type 'HT' or 'TTC'
- * @param double $pu_ttc Unit price with tax (> 0 even for credit note)
- * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used.
- * @param int $rang Position of line
- * @param int $special_code Special code (also used by externals modules!)
- * @param string $origin 'order', ...
- * @param int $origin_id Id of origin object
- * @param int $fk_parent_line Id of parent line
- * @param int $fk_fournprice Supplier price id (to calculate margin) or ''
- * @param int $pa_ht Buying price of line (to calculate margin) or ''
- * @param string $label Label of the line (deprecated, do not use)
- * @param array $array_options extrafields array
- * @param int $situation_percent Situation advance percentage
- * @param int $fk_prev_id Previous situation line id reference
- * @param string $fk_unit Code of the unit to use. Null to use the default one
- * @param double $pu_ht_devise Unit price in currency
- * @return int <0 if KO, Id of line if OK
+ * @param string $desc Description of line
+ * @param double $pu_ht Unit price without tax (> 0 even for credit note)
+ * @param double $qty Quantity
+ * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)')
+ * @param double $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside)
+ * @param double $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside)
+ * @param int $fk_product Id of predefined product/service
+ * @param double $remise_percent Percent of discount on line
+ * @param int $date_start Date start of service
+ * @param int $date_end Date end of service
+ * @param int $ventil Code of dispatching into accountancy
+ * @param int $info_bits Bits of type of lines
+ * @param int $fk_remise_except Id discount used
+ * @param string $price_base_type 'HT' or 'TTC'
+ * @param double $pu_ttc Unit price with tax (> 0 even for credit note)
+ * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used.
+ * @param int $rang Position of line
+ * @param int $special_code Special code (also used by externals modules!)
+ * @param string $origin 'order', ...
+ * @param int $origin_id Id of origin object
+ * @param int $fk_parent_line Id of parent line
+ * @param int $fk_fournprice Supplier price id (to calculate margin) or ''
+ * @param int $pa_ht Buying price of line (to calculate margin) or ''
+ * @param string $label Label of the line (deprecated, do not use)
+ * @param array $array_options extrafields array
+ * @param int $situation_percent Situation advance percentage
+ * @param int $fk_prev_id Previous situation line id reference
+ * @param string $fk_unit Code of the unit to use. Null to use the default one
+ * @param double $pu_ht_devise Unit price in currency
+ * @return int <0 if KO, Id of line if OK
*/
- public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = 0, $fk_remise_except = '', $price_base_type = 'HT', $pu_ttc = 0, $type = self::TYPE_STANDARD, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0)
- {
+ public function addline(
+ $desc,
+ $pu_ht,
+ $qty,
+ $txtva,
+ $txlocaltax1 = 0,
+ $txlocaltax2 = 0,
+ $fk_product = 0,
+ $remise_percent = 0,
+ $date_start = '',
+ $date_end = '',
+ $ventil = 0,
+ $info_bits = 0,
+ $fk_remise_except = '',
+ $price_base_type = 'HT',
+ $pu_ttc = 0,
+ $type = self::TYPE_STANDARD,
+ $rang = -1,
+ $special_code = 0,
+ $origin = '',
+ $origin_id = 0,
+ $fk_parent_line = 0,
+ $fk_fournprice = null,
+ $pa_ht = 0,
+ $label = '',
+ $array_options = 0,
+ $situation_percent = 100,
+ $fk_prev_id = 0,
+ $fk_unit = null,
+ $pu_ht_devise = 0
+ ) {
// Deprecation warning
if ($label) {
dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING);
diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php
index 46cd0e281a5..d26d8954cc4 100644
--- a/htdocs/compta/tva/document.php
+++ b/htdocs/compta/tva/document.php
@@ -114,7 +114,7 @@ if ($object->id)
$morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
$morehtmlref.='
';
- $linkback = '' . $langs->trans("BackToList") . '';
+ $linkback = '' . $langs->trans("BackToList") . '';
$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 6fe136cc3bb..cf6af3c5926 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -672,7 +672,7 @@ class Contact extends CommonObject
if ($this->birthday_alert)
{
//check existing
- $sql_check = "SELECT * FROM ".MAIN_DB_PREFIX."user_alert WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id;
+ $sql_check = "SELECT rowid FROM ".MAIN_DB_PREFIX."user_alert WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id;
$result_check = $this->db->query($sql_check);
if (! $result_check || ($this->db->num_rows($result_check)<1))
{
diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php
index f1f42266735..d6a2ba77f05 100644
--- a/htdocs/core/ajax/ajaxdirpreview.php
+++ b/htdocs/core/ajax/ajaxdirpreview.php
@@ -155,8 +155,8 @@ $type='directory';
// This test if file exists should be useless. We keep it to find bug more easily
if (! dol_is_dir($upload_dir))
{
-// dol_mkdir($upload_dir);
-/* $langs->load("install");
+ //dol_mkdir($upload_dir);
+ /*$langs->load("install");
dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir));
exit;*/
}
diff --git a/htdocs/core/ajax/box.php b/htdocs/core/ajax/box.php
index d37374e45a5..200c6208896 100644
--- a/htdocs/core/ajax/box.php
+++ b/htdocs/core/ajax/box.php
@@ -73,7 +73,7 @@ if ($boxorder && $zone != '' && $userid > 0)
$langs->load("boxes");
if (! GETPOST('closing'))
{
- setEventMessages($langs->trans("BoxAdded"), null);
+ setEventMessages($langs->trans("BoxAdded"), null);
}
}
}
diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php
index a66b775155c..23c4cc368cf 100644
--- a/htdocs/core/boxes/box_produits.php
+++ b/htdocs/core/boxes/box_produits.php
@@ -144,7 +144,8 @@ class box_produits extends ModeleBoxes
'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"',
'text' => $objp->label,
);
-
+ $price = '';
+ $price_base_type = '';
if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) {
$price_base_type=$langs->trans($objp->price_base_type);
$price=($objp->price_base_type == 'HT')?price($objp->price):$price=price($objp->price_ttc);
diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php
index eb53e327e93..d834fcfe943 100644
--- a/htdocs/core/class/commoninvoice.class.php
+++ b/htdocs/core/class/commoninvoice.class.php
@@ -219,9 +219,9 @@ abstract class CommonInvoice extends CommonObject
}
/**
- * Renvoie tableau des ids de facture avoir issus de la facture
+ * Returns array of credit note ids from the invoice
*
- * @return array Tableau d'id de factures avoirs
+ * @return array Array of credit note ids
*/
public function getListIdAvoirFromInvoice()
{
@@ -251,10 +251,10 @@ abstract class CommonInvoice extends CommonObject
}
/**
- * Renvoie l'id de la facture qui la remplace
+ * Returns the id of the invoice that replaces it
*
- * @param string $option filtre sur statut ('', 'validated', ...)
- * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon
+ * @param string $option status filter ('', 'validated', ...)
+ * @return int <0 si KO, 0 if no invoice replaces it, id of invoice otherwise
*/
public function getIdReplacingInvoice($option = '')
{
@@ -264,10 +264,10 @@ abstract class CommonInvoice extends CommonObject
$sql.= ' AND type < 2';
if ($option == 'validated') $sql.= ' AND fk_statut = 1';
// PROTECTION BAD DATA
- // Au cas ou base corrompue et qu'il y a une facture de remplacement validee
- // et une autre non, on donne priorite a la validee.
- // Ne devrait pas arriver (sauf si acces concurrentiel et que 2 personnes
- // ont cree en meme temps une facture de remplacement pour la meme facture)
+ // In case the database is corrupted and there is a valid replectement invoice
+ // and another no, priority is given to the valid one.
+ // Should not happen (unless concurrent access and 2 people have created a
+ // replacement invoice for the same invoice at the same time)
$sql.= ' ORDER BY fk_statut DESC';
$resql=$this->db->query($sql);
@@ -276,12 +276,12 @@ abstract class CommonInvoice extends CommonObject
$obj = $this->db->fetch_object($resql);
if ($obj)
{
- // Si il y en a
+ // If there is any
return $obj->rowid;
}
else
{
- // Si aucune facture ne remplace
+ // If no invoice replaces it
return 0;
}
}
@@ -544,8 +544,8 @@ abstract class CommonInvoice extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Renvoi une date limite de reglement de facture en fonction des
- * conditions de reglements de la facture et date de facturation.
+ * Returns an invoice payment deadline based on the invoice settlement
+ * conditions and billing date.
*
* @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition.
* @return integer Date limite de reglement si ok, <0 si ko
@@ -589,14 +589,14 @@ abstract class CommonInvoice extends CommonObject
/* Definition de la date limite */
- // 0 : ajout du nombre de jours
+ // 0 : adding the number of days
if ($cdr_type == 0)
{
$datelim = $this->date + ($cdr_nbjour * 3600 * 24);
$datelim += ($cdr_decalage * 3600 * 24);
}
- // 1 : application de la regle "fin de mois"
+ // 1 : application of the "end of the month" rule
elseif ($cdr_type == 1)
{
$datelim = $this->date + ($cdr_nbjour * 3600 * 24);
@@ -612,13 +612,13 @@ abstract class CommonInvoice extends CommonObject
{
$mois += 1;
}
- // On se deplace au debut du mois suivant, et on retire un jour
+ // We move at the beginning of the next month, and we take a day off
$datelim=dol_mktime(12, 0, 0, $mois, 1, $annee);
$datelim -= (3600 * 24);
$datelim += ($cdr_decalage * 3600 * 24);
}
- // 2 : application de la règle, le N du mois courant ou suivant
+ // 2 : application of the rule, the N of the current or next month
elseif ($cdr_type == 2 && !empty($cdr_decalage))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@@ -733,7 +733,7 @@ abstract class CommonInvoiceLine extends CommonObjectLine
public $total_ttc;
/**
- * Liste d'options cumulables:
+ * List of cumulative options:
* Bit 0: 0 si TVA normal - 1 si TVA NPR
* Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except)
* @var int
diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php
index ab1448bc412..71c0566f352 100644
--- a/htdocs/core/class/discount.class.php
+++ b/htdocs/core/class/discount.class.php
@@ -91,13 +91,15 @@ class DiscountAbsolute
public $fk_facture;
/**
- * @var int ID credit note having caused the discount
+ * @var int ID credit note or deposit used to create the discount
*/
public $fk_facture_source;
+ public $ref_facture_source; // Ref credit note or deposit used to create the discount
+ public $type_facture_source;
- public $ref_facture_source; // Ref credit note having caused the discount
-
- public $ref_invoice_supplier_source;
+ public $fk_invoice_supplier_source;
+ public $ref_invoice_supplier_source; // Ref credit note or deposit used to create the discount
+ public $type_invoice_supplier_source;
/**
* Constructor
@@ -135,11 +137,12 @@ class DiscountAbsolute
$sql.= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,";
$sql.= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,";
$sql.= " sr.datec,";
- $sql.= " f.ref as ref_facture_source, fsup.ref as ref_invoice_supplier_source";
+ $sql.= " f.ref as ref_facture_source, f.type as type_facture_source,";
+ $sql.= " fsup.ref as ref_invoice_supplier_source, fsup.type as type_invoice_supplier_source";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid";
- $sql.= " WHERE sr.entity IN (".getEntity('invoice').")";
+ $sql.= " WHERE sr.entity IN (".getEntity('invoice').")";
if ($rowid) $sql.= " AND sr.rowid=".$rowid;
if ($fk_facture_source) $sql.= " AND sr.fk_facture_source=".$fk_facture_source;
if ($fk_invoice_supplier_source) $sql.= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source;
@@ -168,12 +171,14 @@ class DiscountAbsolute
$this->fk_user = $obj->fk_user;
$this->fk_facture_line = $obj->fk_facture_line;
$this->fk_facture = $obj->fk_facture;
- $this->fk_facture_source = $obj->fk_facture_source; // Id avoir source
- $this->ref_facture_source = $obj->ref_facture_source; // Ref avoir source
+ $this->fk_facture_source = $obj->fk_facture_source; // Id credit note or deposit source
+ $this->ref_facture_source = $obj->ref_facture_source; // Ref credit note or deposit source
+ $this->type_facture_source = $obj->type_facture_source; // Type credit note or deposit source
$this->fk_invoice_supplier_line = $obj->fk_invoice_supplier_line;
$this->fk_invoice_supplier = $obj->fk_invoice_supplier;
- $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source; // Id avoir source
- $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source; // Ref avoir source
+ $this->fk_invoice_supplier_source = $obj->fk_invoice_supplier_source; // Id credit note or deposit source
+ $this->ref_invoice_supplier_source = $obj->ref_invoice_supplier_source; // Ref credit note or deposit source
+ $this->type_invoice_supplier_source = $obj->type_invoice_supplier_source; // Type credit note or deposit source
$this->description = $obj->description;
$this->datec = $this->db->jdate($obj->datec);
@@ -688,7 +693,7 @@ class DiscountAbsolute
if ($option == 'invoice') {
$facid=! empty($this->discount_type)?$this->fk_invoice_supplier_source:$this->fk_facture_source;
$link=! empty($this->discount_type)?'/fourn/facture/card.php':'/compta/facture/card.php';
- $label=$langs->trans("ShowDiscount").': '.$this->ref_facture_source;
+ $label=$langs->trans("ShowSourceInvoice").': '.$this->ref_facture_source;
$link = '';
$linkend='';
$ref=! empty($this->discount_type)?$this->ref_invoice_supplier_source:$this->ref_facture_source;
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index e6a6a077cf8..61558434105 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -7129,8 +7129,8 @@ class Form
// Left part of banner
if ($morehtmlleft)
{
- if ($conf->browser->layout == 'phone') $ret.='
'.$morehtmlleft.'
'; // class="center" to have photo in middle
- else $ret.='
'.$morehtmlleft.'
';
+ if ($conf->browser->layout == 'phone') $ret.='
'.$morehtmlleft.'
'; // class="center" to have photo in middle
+ else $ret.='
'.$morehtmlleft.'
';
}
//if ($conf->browser->layout == 'phone') $ret.='';
diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php
index 42fec36ef6a..0277630ae78 100644
--- a/htdocs/core/class/html.formcron.class.php
+++ b/htdocs/core/class/html.formcron.class.php
@@ -77,23 +77,23 @@ class FormCron extends Form
$out.='';
}
} else {
- $out='';
+ $out='';
- if ($selected=='command') {
- $selected_attr=' selected ';
- } else {
- $selected_attr='';
- }
- $out.= '';
+ if ($selected=='command') {
+ $selected_attr=' selected ';
+ } else {
+ $selected_attr='';
+ }
+ $out.= '';
- if ($selected=='method') {
- $selected_attr=' selected ';
- } else {
- $selected_attr='';
- }
- $out.= '';
+ if ($selected=='method') {
+ $selected_attr=' selected ';
+ } else {
+ $selected_attr='';
+ }
+ $out.= '';
- $out.='';
+ $out.='';
}
return $out;
diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php
index b845f799bb6..cd6f64c3242 100644
--- a/htdocs/core/class/smtps.class.php
+++ b/htdocs/core/class/smtps.class.php
@@ -496,17 +496,31 @@ class SMTPs
return $_retVal;
}
}
+
+ // Default authentication method is LOGIN
+ if (empty($conf->global->MAIL_SMTP_AUTH_TYPE)) $conf->global->MAIL_SMTP_AUTH_TYPE = 'LOGIN';
+
// Send Authentication to Server
// Check for errors along the way
- $this->socket_send_str('AUTH LOGIN', '334');
-
- // User name will not return any error, server will take anything we give it.
- $this->socket_send_str(base64_encode($this->_smtpsID), '334');
-
- // The error here just means the ID/password combo doesn't work.
- // There is not a method to determine which is the problem, ID or password
- if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') )
- $this->_setErr(130, 'Invalid Authentication Credentials.');
+ switch ($conf->global->MAIL_SMTP_AUTH_TYPE) {
+ case 'PLAIN':
+ $this->socket_send_str('AUTH PLAIN', '334');
+ // The error here just means the ID/password combo doesn't work.
+ $_retVal = $this->socket_send_str(base64_encode("\0" . $this->_smtpsID . "\0" . $this->_smtpsPW), '235');
+ break;
+ case 'LOGIN':
+ default:
+ $this->socket_send_str('AUTH LOGIN', '334');
+ // User name will not return any error, server will take anything we give it.
+ $this->socket_send_str(base64_encode($this->_smtpsID), '334');
+ // The error here just means the ID/password combo doesn't work.
+ // There is not a method to determine which is the problem, ID or password
+ $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235');
+ break;
+ }
+ if (! $_retVal) {
+ $this->_setErr(130, 'Invalid Authentication Credentials.');
+ }
}
else
{
diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php
index cb4e7ef9e5a..3b381bc5796 100644
--- a/htdocs/core/class/utils.class.php
+++ b/htdocs/core/class/utils.class.php
@@ -1004,7 +1004,7 @@ class Utils
if (GETPOST("nobin_disable_fk")) fwrite($handle, "ALTER TABLE `".$table."` DISABLE KEYS;\n");
else fwrite($handle, "/*!40000 ALTER TABLE `".$table."` DISABLE KEYS */;\n");
- $sql='SELECT * FROM '.$table;
+ $sql='SELECT * FROM '.$table; // Here SELECT * is allowed because we don't have definition of columns to take
$result = $db->query($sql);
while($row = $db->fetch_row($result))
{
diff --git a/htdocs/core/filemanagerdol/connectors/php/commands.php b/htdocs/core/filemanagerdol/connectors/php/commands.php
index 9e26e1583a6..2f6dbf16943 100644
--- a/htdocs/core/filemanagerdol/connectors/php/commands.php
+++ b/htdocs/core/filemanagerdol/connectors/php/commands.php
@@ -318,7 +318,7 @@ function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '')
else
{
//issue the CKEditor Callback
-SendCKEditorResults(
+ SendCKEditorResults(
$CKEcallback,
$sFileUrl,
($sErrorNumber != 0 ? 'Error '. $sErrorNumber. ' upload failed.' : 'Upload Successful')
diff --git a/htdocs/core/filemanagerdol/connectors/php/io.php b/htdocs/core/filemanagerdol/connectors/php/io.php
index 17f847b9a37..b66f2abcd8b 100644
--- a/htdocs/core/filemanagerdol/connectors/php/io.php
+++ b/htdocs/core/filemanagerdol/connectors/php/io.php
@@ -401,11 +401,11 @@ EOF;
*/
function SendCKEditorResults($callback, $sFileUrl, $customMsg = '')
{
- echo '';
+ echo '';
}
diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php
index c35318dc7ae..54c0f02abde 100644
--- a/htdocs/core/js/lib_head.js.php
+++ b/htdocs/core/js/lib_head.js.php
@@ -1039,16 +1039,16 @@ function price2numjs(amount) {
if (amount == '') return '';
transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") {
- $dec = $langs->transnoentitiesnoconv("SeparatorDecimal");
- }
- if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") {
- $thousand = $langs->transnoentitiesnoconv("SeparatorThousand");
- }
- if ($thousand == 'Space') $thousand=' ';
- print "var dec='" . dol_escape_js($dec) . "'; var thousand='" . dol_escape_js($thousand) . "';\n"; // Set var in javascript
+ $dec = ',';
+ $thousand = ' ';
+ if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") {
+ $dec = $langs->transnoentitiesnoconv("SeparatorDecimal");
+ }
+ if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") {
+ $thousand = $langs->transnoentitiesnoconv("SeparatorThousand");
+ }
+ if ($thousand == 'Space') $thousand=' ';
+ print "var dec='" . dol_escape_js($dec) . "'; var thousand='" . dol_escape_js($thousand) . "';\n"; // Set var in javascript
?>
var main_max_dec_shown = global->MAIN_MAX_DECIMALS_SHOWN); ?>;
diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php
index 6c7f3e2c35c..cb8a80bbd78 100644
--- a/htdocs/core/js/lib_notification.js.php
+++ b/htdocs/core/js/lib_notification.js.php
@@ -140,5 +140,5 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H
time_js_next_test += time_auto_update;
console.log('Updated time_js_next_test. New value is '+time_js_next_test);
}
-id=$obj->id;
print '
'.$staticaction->getNomUrl(1, 34).'
';
- // print '
'.dol_trunc($obj->label,22).'
';
+ // print '
'.dol_trunc($obj->label,22).'
';
print '
';
if ($obj->rowid > 0)
@@ -414,10 +414,10 @@ function agenda_prepare_head()
if ($conf->global->MAIN_FEATURES_LEVEL > 0)
{
- $head[$h][0] = DOL_URL_ROOT."/admin/agenda_reminder.php";
- $head[$h][1] = $langs->trans("Reminders");
- $head[$h][2] = 'reminders';
- $h++;
+ $head[$h][0] = DOL_URL_ROOT."/admin/agenda_reminder.php";
+ $head[$h][1] = $langs->trans("Reminders");
+ $head[$h][2] = 'reminders';
+ $h++;
}
$head[$h][0] = DOL_URL_ROOT."/admin/agenda_xcal.php";
diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php
index 2230bfac5a1..91e0b719734 100644
--- a/htdocs/core/lib/bank.lib.php
+++ b/htdocs/core/lib/bank.lib.php
@@ -47,13 +47,13 @@ function bank_prepare_head(Account $object)
$head[$h][2] = 'journal';
$h++;
-// if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
-// {
+ // if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
+ // {
$head[$h][0] = DOL_URL_ROOT . "/compta/bank/treso.php?account=" . $object->id;
$head[$h][1] = $langs->trans("PlannedTransactions");
$head[$h][2] = 'cash';
$h++;
-// }
+ // }
$head[$h][0] = DOL_URL_ROOT . "/compta/bank/annuel.php?account=" . $object->id;
$head[$h][1] = $langs->trans("IOMonthlyReporting");
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 1730d51383d..f1fd6ed220f 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -624,7 +624,7 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask
if (empty($arrayreplacementisregex))
{
- $content = make_substitutions($content, $arrayreplacement, null);
+ $content = make_substitutions($content, $arrayreplacement, null);
}
else
{
@@ -1044,8 +1044,8 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
$checkvirusarray=dolCheckVirus($src_file);
if (count($checkvirusarray))
{
- dol_syslog('Files.lib::dol_move_uploaded_file File "'.$src_file.'" (target name "'.$dest_file.'") KO with antivirus: errors='.join(',', $checkvirusarray), LOG_WARNING);
- return 'ErrorFileIsInfectedWithAVirus: '.join(',', $checkvirusarray);
+ dol_syslog('Files.lib::dol_move_uploaded_file File "'.$src_file.'" (target name "'.$dest_file.'") KO with antivirus: errors='.join(',', $checkvirusarray), LOG_WARNING);
+ return 'ErrorFileIsInfectedWithAVirus: '.join(',', $checkvirusarray);
}
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index caa0915b91a..b36733a91f2 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -45,9 +45,9 @@ include_once DOL_DOCUMENT_ROOT .'/core/lib/json.lib.php';
*
* @param string $type Type of database (mysql, pgsql...)
* @param string $host Address of database server
- * @param string $user Nom de l'utilisateur autorise
- * @param string $pass Mot de passe
- * @param string $name Nom de la database
+ * @param string $user Authorized username
+ * @param string $pass Password
+ * @param string $name Name of database
* @param int $port Port of database server
* @return DoliDB A DoliDB instance
*/
@@ -464,36 +464,36 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti
$maxloop=20; $loopnb=0; // Protection against infinite loop
while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side.
{
- $loopnb++; $newout = '';
+ $loopnb++; $newout = '';
- if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; }
- elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; }
- elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; }
- elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; }
- elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; }
- elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); }
- elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; }
- elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; }
- elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); }
- elseif ($reg[1] == 'MYCOMPANY_COUNTRY_ID' || $reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID')
- {
- $newout = $mysoc->country_id;
- }
- elseif ($reg[1] == 'USER_ID' || $reg[1] == 'USERID')
- {
- $newout = $user->id;
- }
- elseif ($reg[1] == 'USER_SUPERVISOR_ID' || $reg[1] == 'SUPERVISOR_ID' || $reg[1] == 'SUPERVISORID')
- {
- $newout = $user->fk_user;
- }
- elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID')
- {
- $newout = $conf->entity;
- }
- else $newout = ''; // Key not found, we replace with empty string
- //var_dump('__'.$reg[1].'__ -> '.$newout);
- $out = preg_replace('/__'.preg_quote($reg[1], '/').'__/', $newout, $out);
+ if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; }
+ elseif ($reg[1] == 'MONTH') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mon']; }
+ elseif ($reg[1] == 'YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['year']; }
+ elseif ($reg[1] == 'PREVIOUS_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; }
+ elseif ($reg[1] == 'PREVIOUS_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_prev_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; }
+ elseif ($reg[1] == 'PREVIOUS_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] - 1); }
+ elseif ($reg[1] == 'NEXT_DAY') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']); $newout = $tmp2['day']; }
+ elseif ($reg[1] == 'NEXT_MONTH') { $tmp=dol_getdate(dol_now(), true); $tmp2=dol_get_next_month($tmp['mon'], $tmp['year']); $newout = $tmp2['month']; }
+ elseif ($reg[1] == 'NEXT_YEAR') { $tmp=dol_getdate(dol_now(), true); $newout = ($tmp['year'] + 1); }
+ elseif ($reg[1] == 'MYCOMPANY_COUNTRY_ID' || $reg[1] == 'MYCOUNTRY_ID' || $reg[1] == 'MYCOUNTRYID')
+ {
+ $newout = $mysoc->country_id;
+ }
+ elseif ($reg[1] == 'USER_ID' || $reg[1] == 'USERID')
+ {
+ $newout = $user->id;
+ }
+ elseif ($reg[1] == 'USER_SUPERVISOR_ID' || $reg[1] == 'SUPERVISOR_ID' || $reg[1] == 'SUPERVISORID')
+ {
+ $newout = $user->fk_user;
+ }
+ elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID')
+ {
+ $newout = $conf->entity;
+ }
+ else $newout = ''; // Key not found, we replace with empty string
+ //var_dump('__'.$reg[1].'__ -> '.$newout);
+ $out = preg_replace('/__'.preg_quote($reg[1], '/').'__/', $newout, $out);
}
}
@@ -876,7 +876,7 @@ function dol_string_unaccent($str)
else
{
// See http://www.ascii-code.com/
-$string = strtr(
+ $string = strtr(
$str,
"\xC0\xC1\xC2\xC3\xC4\xC5\xC7
\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1
@@ -3418,7 +3418,7 @@ function img_edit_remove($titlealt = 'default', $other = '')
* Show logo editer/modifier fiche
*
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
- * @param integer $float Si il faut y mettre le style "float: right"
+ * @param integer $float If you have to put the style "float: right"
* @param string $other Add more attributes on img
* @return string Return tag img
*/
@@ -3435,7 +3435,7 @@ function img_edit($titlealt = 'default', $float = 0, $other = '')
* Show logo view card
*
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
- * @param integer $float Si il faut y mettre le style "float: right"
+ * @param integer $float If you have to put the style "float: right"
* @param string $other Add more attributes on img
* @return string Return tag img
*/
@@ -3793,10 +3793,9 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss
/**
- * Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remontee des bugs.
- * On doit appeler cette fonction quand une erreur technique bloquante est rencontree.
- * Toutefois, il faut essayer de ne l'appeler qu'au sein de pages php, les classes devant
- * renvoyer leur erreur par l'intermediaire de leur propriete "error".
+ * Displays error message system with all the information to facilitate the diagnosis and the escalation of the bugs.
+ * This function must be called when a blocking technical error is encountered.
+ * However, one must try to call it only within php pages, classes must return their error through their property "error".
*
* @param DoliDB $db Database handler
* @param mixed $error String or array of errors strings to show
@@ -3857,7 +3856,7 @@ function dol_print_error($db = '', $error = '', $errors = null)
if (! empty($conf->modules))
{
- $out.="".$langs->trans("Modules").": ".join(', ', $conf->modules)." \n";
+ $out.="".$langs->trans("Modules").": ".join(', ', $conf->modules)." \n";
}
if (is_object($db))
@@ -5895,7 +5894,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
// Add SIGNATURE into substitutionarray first, so, when we will make the substitution,
// this will include signature content first and then replace var found into content of signature
$signature = $user->signature;
-$substitutionarray=array_merge($substitutionarray, array(
+ $substitutionarray=array_merge($substitutionarray, array(
'__USER_SIGNATURE__' => (string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($signature), 30) : $signature) : '')
)
);
@@ -5905,7 +5904,7 @@ $substitutionarray=array_merge($substitutionarray, array(
$substitutionarray['__SIGNATURE__'] = (string) (($signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? ($onlykey == 2 ? dol_trunc(dol_string_nohtmltag($signature), 30) : $signature) : '');
}
-$substitutionarray=array_merge($substitutionarray, array(
+ $substitutionarray=array_merge($substitutionarray, array(
'__USER_ID__' => (string) $user->id,
'__USER_LOGIN__' => (string) $user->login,
'__USER_LASTNAME__' => (string) $user->lastname,
@@ -5918,7 +5917,7 @@ $substitutionarray=array_merge($substitutionarray, array(
}
if ((empty($exclude) || ! in_array('mycompany', $exclude)) && is_object($mysoc))
{
-$substitutionarray=array_merge($substitutionarray, array(
+ $substitutionarray=array_merge($substitutionarray, array(
'__MYCOMPANY_NAME__' => $mysoc->name,
'__MYCOMPANY_EMAIL__' => $mysoc->email,
'__MYCOMPANY_PROFID1__' => $mysoc->idprof1,
@@ -6416,11 +6415,11 @@ function dolGetFirstLastname($firstname, $lastname, $nameorder = -1)
}
elseif ($nameorder == 2 || $nameorder == 3)
{
- $ret.=$firstname;
- if (empty($ret) && $nameorder == 3)
- {
- $ret.=$lastname;
- }
+ $ret.=$firstname;
+ if (empty($ret) && $nameorder == 3)
+ {
+ $ret.=$lastname;
+ }
}
else
{
@@ -7956,7 +7955,7 @@ function getDictvalue($tablename, $field, $id, $checkentity = false, $rowidfield
if (!isset($dictvalues[$tablename]))
{
$dictvalues[$tablename] = array();
- $sql = 'SELECT * FROM '.$tablename.' WHERE 1';
+ $sql = 'SELECT * FROM '.$tablename.' WHERE 1'; // Here select * is allowed as it is generic code and we don't have list of fields
if ($checkentity) $sql.= ' AND entity IN (0,'.getEntity($tablename).')';
$resql = $db->query($sql);
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index 6543b659a88..7780c7d3b12 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -505,14 +505,7 @@ function dolAddEmailTrackId($email, $trackingid)
function isValidMailDomain($mail)
{
list($user, $domain) = explode("@", $mail, 2);
- if (checkdnsrr($domain, "MX"))
- {
- return true;
- }
- else
- {
- return false;
- }
+ return checkdnsrr($domain, "MX");
}
/**
diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php
index 5eb45b261a0..8c97bbb348f 100644
--- a/htdocs/core/lib/json.lib.php
+++ b/htdocs/core/lib/json.lib.php
@@ -317,19 +317,19 @@ function utf162utf8($utf16)
switch(true) {
case ((0x7F & $bytes) == $bytes):
- // this case should never be reached, because we are in ASCII range
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ // this case should never be reached, because we are in ASCII range
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr($bytes);
case (0x07FF & $bytes) == $bytes:
- // return a 2-byte UTF-8 character
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ // return a 2-byte UTF-8 character
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xC0 | (($bytes >> 6) & 0x1F))
. chr(0x80 | ($bytes & 0x3F));
case (0xFFFF & $bytes) == $bytes:
- // return a 3-byte UTF-8 character
- // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ // return a 3-byte UTF-8 character
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xE0 | (($bytes >> 12) & 0x0F))
. chr(0x80 | (($bytes >> 6) & 0x3F))
. chr(0x80 | ($bytes & 0x3F));
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index d6dc59d1dcc..106ce8336a8 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -780,171 +780,171 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
//if ($lines[$i]->fk_task_parent == $parent)
//{
- // If we want all or we have a role on task, we show it
- if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
+ // If we want all or we have a role on task, we show it
+ if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
+ {
+ //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
+
+ // Break on a new project
+ if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
- //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
-
- // Break on a new project
- if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
+ $lastprojectid=$lines[$i]->fk_project;
+ if ($preselectedday)
{
- $lastprojectid=$lines[$i]->fk_project;
- if ($preselectedday)
- {
- $projectstatic->id = $lines[$i]->fk_project;
- }
+ $projectstatic->id = $lines[$i]->fk_project;
}
-
- if (empty($workloadforid[$projectstatic->id]))
- {
- if ($preselectedday)
- {
- $projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
- $workloadforid[$projectstatic->id]=1;
- }
- }
-
- $projectstatic->id=$lines[$i]->fk_project;
- $projectstatic->ref=$lines[$i]->project_ref;
- $projectstatic->title=$lines[$i]->project_label;
- $projectstatic->public=$lines[$i]->public;
-
- $taskstatic->id=$lines[$i]->task_id;
- $taskstatic->ref=($lines[$i]->task_ref?$lines[$i]->task_ref:$lines[$i]->task_id);
- $taskstatic->label=$lines[$i]->task_label;
- $taskstatic->date_start=$lines[$i]->date_start;
- $taskstatic->date_end=$lines[$i]->date_end;
-
- $thirdpartystatic->id=$lines[$i]->socid;
- $thirdpartystatic->name=$lines[$i]->thirdparty_name;
- $thirdpartystatic->email=$lines[$i]->thirdparty_email;
-
- if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id))
- {
- print '
';
-
- $disabledproject=1;$disabledtask=1;
- //print "x".$lines[$i]->fk_project;
- //var_dump($lines[$i]);
- //var_dump($projectsrole[$lines[$i]->fk_project]);
- // If at least one role for project
- if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
- {
- $disabledproject=0;
- $disabledtask=0;
- }
- // If $restricteditformytask is on and I have no role on task, i disable edit
- if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
- {
- $disabledtask=1;
- }
-
- // Hour
- print '
';
+
+ $disabledproject=1;$disabledtask=1;
+ //print "x".$lines[$i]->fk_project;
+ //var_dump($lines[$i]);
+ //var_dump($projectsrole[$lines[$i]->fk_project]);
+ // If at least one role for project
+ if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
+ {
+ $disabledproject=0;
+ $disabledtask=0;
+ }
+ // If $restricteditformytask is on and I have no role on task, i disable edit
+ if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
+ {
+ $disabledtask=1;
+ }
+
+ // Hour
+ print '
';
diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php
index 0727e4df4e2..d5196867b67 100644
--- a/htdocs/core/modules/facture/mod_facture_terre.php
+++ b/htdocs/core/modules/facture/mod_facture_terre.php
@@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/facture/modules_facture.php';
/**
* \class mod_facture_terre
- * \brief Classe du modele de numerotation de reference de facture Terre
+ * \brief Class of numbering module Terre for invoices
*/
class mod_facture_terre extends ModeleNumRefFactures
{
@@ -189,7 +189,7 @@ class mod_facture_terre extends ModeleNumRefFactures
if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
elseif ($invoice->type == 3) $prefix=$this->prefixdeposit;
else $prefix=$this->prefixinvoice;
- // D'abord on recupere la valeur max
+ // First we get the max value
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php
index a2bd576bdcd..ba65eeeca9c 100644
--- a/htdocs/core/modules/facture/modules_facture.php
+++ b/htdocs/core/modules/facture/modules_facture.php
@@ -23,13 +23,13 @@
/**
* \file htdocs/core/modules/facture/modules_facture.php
* \ingroup facture
- * \brief Fichier contenant la classe mere de generation des factures en PDF
- * et la classe mere de numerotation des factures
+ * \brief File that contains parent class for invoices models
+ * and parent class for invoices numbering models
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required because used in classes that inherit
/**
@@ -66,7 +66,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator
}
/**
- * Classe mere des modeles de numerotation des references de facture
+ * Parent class of invoice reference numbering templates
*/
abstract class ModeleNumRefFactures
{
diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php
index 5b116aa8d93..4ed16dc69a3 100644
--- a/htdocs/core/modules/modExpenseReport.class.php
+++ b/htdocs/core/modules/modExpenseReport.class.php
@@ -182,7 +182,9 @@ class modExpenseReport extends DolibarrModules
$this->export_permission[$r]=array(array("expensereport","export"));
$this->export_fields_array[$r]=array(
'd.rowid'=>"TripId",'d.ref'=>'Ref','d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.date_create'=>'DateCreation','d.date_approve'=>'DateApprove',
- 'd.total_ht'=>"TotalHT",'d.total_tva'=>'TotalVAT','d.total_ttc'=>'TotalTTC','d.note_private'=>'NotePrivate','d.note_public'=>'NotePublic',
+ 'd.total_ht'=>"TotalHT",'d.total_tva'=>'TotalVAT','d.total_ttc'=>'TotalTTC',
+ 'd.fk_statut'=>'Status','d.paid'=>'Paid',
+ 'd.note_private'=>'NotePrivate','d.note_public'=>'NotePublic','d.detail_cancel'=>'MOTIF_CANCEL','d.detail_refuse'=>'MOTIF_REFUS',
'u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'ed.rowid'=>'LineId','tf.code'=>'Type','ed.date'=>'Date','ed.tva_tx'=>'VATRate',
'ed.total_ht'=>'TotalHT','ed.total_tva'=>'TotalVAT','ed.total_ttc'=>'TotalTTC','ed.comments'=>'Comment','p.rowid'=>'ProjectId','p.ref'=>'Ref',
'user_rib.iban_prefix' => 'IBAN', 'user_rib.bic' => 'BIC', 'user_rib.code_banque' => 'BankCode', 'user_rib.bank' => 'BankName', 'user_rib.proprio' => 'BankAccountOwner',
@@ -190,7 +192,9 @@ class modExpenseReport extends DolibarrModules
);
$this->export_TypeFields_array[$r]=array(
'd.rowid'=>"Numeric",'d.ref'=>'Text','d.date_debut'=>'Date','d.date_fin'=>'Date','d.date_create'=>'Date','d.date_approve'=>'Date',
- 'd.total_ht'=>"Numeric",'d.total_tva'=>'Numeric','d.total_ttc'=>'Numeric','d.note_private'=>'Text','d.note_public'=>'Text',
+ 'd.total_ht'=>"Numeric",'d.total_tva'=>'Numeric','d.total_ttc'=>'Numeric',
+ 'd.fk_statut'=>"Numeric",'d.paid'=>'Numeric',
+ 'd.note_private'=>'Text','d.note_public'=>'Text','d.detail_cancel'=>'Text','d.detail_refuse'=>'Text',
'u.lastname'=>'Text','u.firstname'=>'Text','u.login'=>"Text",'ed.rowid'=>'Numeric','tf.code'=>'Code','ed.date'=>'Date','ed.tva_tx'=>'Numeric',
'ed.total_ht'=>'Numeric','ed.total_tva'=>'Numeric','ed.total_ttc'=>'Numeric','ed.comments'=>'Text','p.rowid'=>'Numeric','p.ref'=>'Text',
'user_rib.iban_prefix' => 'Text', 'user_rib.bic' => 'Text', 'user_rib.code_banque' => 'Text', 'user_rib.bank' => 'Text', 'user_rib.proprio' => 'Text',
diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php
index a3e3e539468..1db0db2e6f5 100644
--- a/htdocs/core/modules/modProduct.class.php
+++ b/htdocs/core/modules/modProduct.class.php
@@ -390,7 +390,7 @@ class modProduct extends DolibarrModules
'p.length' => "Length",
'p.length_units' => "LengthUnit",
'p.width' => "Width",
- 'p.width_units' => "VolumeUnits",
+ 'p.width_units' => "WidthUnits",
'p.height' => "Height",
'p.height_units' => "HeightUnit",
'p.surface' => "Surface",
diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php
index a1c14d65c90..780a9078f2b 100644
--- a/htdocs/core/modules/modService.class.php
+++ b/htdocs/core/modules/modService.class.php
@@ -360,7 +360,7 @@ class modService extends DolibarrModules
'p.length' => "Length",
'p.length_units' => "LengthUnit",
'p.width' => "Width",
- 'p.width_units' => "VolumeUnits",
+ 'p.width_units' => "WidthUnits",
'p.height' => "Height",
'p.height_units' => "HeightUnit",
'p.surface' => "Surface",
diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php
index 6be5e3904ab..93d1b37c690 100644
--- a/htdocs/core/triggers/interface_20_all_Logevents.class.php
+++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php
@@ -177,13 +177,13 @@ class InterfaceLogevents extends DolibarrTriggers
}
// If not found
-/*
+ /*
else
{
dol_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action.");
return 0;
}
-*/
+ */
// Add more information into desc from the context property
if (! empty($desc) && ! empty($object->context['audit'])) $desc.=' - '.$object->context['audit'];
diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
index 5676bb82cfb..e72da40d6b0 100644
--- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
+++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
@@ -251,7 +251,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
}
elseif ($action == 'BILL_UNVALIDATE')
{
- // Load translation files required by the page
+ // Load translation files required by the page
$langs->loadLangs(array("agenda","other","bills"));
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr", $object->ref);
@@ -808,9 +808,9 @@ class InterfaceActionsAuto extends DolibarrTriggers
$object->actionmsg=$langs->transnoentities("TICKET_ASSIGNEDInDolibarr", $object->ref);
if ($object->oldcopy->fk_user_assign > 0)
{
- $tmpuser=new User($this->db);
- $tmpuser->fetch($object->oldcopy->fk_user_assign);
- $object->actionmsg.="\n".$langs->transnoentities("OldUser").': '.$tmpuser->getFullName($langs);
+ $tmpuser=new User($this->db);
+ $tmpuser->fetch($object->oldcopy->fk_user_assign);
+ $object->actionmsg.="\n".$langs->transnoentities("OldUser").': '.$tmpuser->getFullName($langs);
}
else
{
diff --git a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php
index 301d565c2ba..b9dbd340d88 100644
--- a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php
+++ b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php
@@ -181,7 +181,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers
case 'CONTACT_MODIFY':
case 'CONTACT_DELETE':
case 'CONTACT_ENABLEDISABLE':
-
+ break;
// Products
// case 'PRODUCT_CREATE':
// case 'PRODUCT_MODIFY':
@@ -221,7 +221,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers
case 'LINEORDER_INSERT':
case 'LINEORDER_UPDATE':
case 'LINEORDER_DELETE':
-
+ break;
// Supplier orders
// case 'ORDER_SUPPLIER_CREATE':
// case 'ORDER_SUPPLIER_CLONE':
diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php
index 14ee77f0146..d83e6f4e258 100644
--- a/htdocs/cron/list.php
+++ b/htdocs/cron/list.php
@@ -561,8 +561,15 @@ if ($num > 0)
}
if ($user->rights->cron->execute)
{
- if (!empty($obj->status)) print 'rowid.'&action=execute'.(empty($conf->global->CRON_KEY)?'':'&securitykey='.$conf->global->CRON_KEY).($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'), "play").'';
- else print ''.img_picto($langs->trans('JobDisabled'), "playdisabled").'';
+ if (!empty($obj->status)) {
+ print 'rowid.'&action=execute';
+ print (empty($conf->global->CRON_KEY)?'':'&securitykey='.$conf->global->CRON_KEY);
+ print ($sortfield?'&sortfield='.$sortfield:'');
+ print ($sortorder?'&sortorder='.$sortorder:'');
+ print $param."\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'), "play").'';
+ } else {
+ print ''.img_picto($langs->trans('JobDisabled'), "playdisabled").'';
+ }
} else {
print ''.img_picto($langs->trans('NotEnoughPermissions'), "playdisabled").'';
}
diff --git a/htdocs/don/card.php b/htdocs/don/card.php
index 4db968b13b4..d3f37771dd7 100644
--- a/htdocs/don/card.php
+++ b/htdocs/don/card.php
@@ -500,7 +500,7 @@ if (! empty($id) && $action == 'edit')
print '';
- dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'invoicing');
+ dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
print '
';
diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php
index 527b9062c2e..70fabfcdc29 100644
--- a/htdocs/don/class/don.class.php
+++ b/htdocs/don/class/don.class.php
@@ -58,12 +58,16 @@ class Don extends CommonObject
public $ismultientitymanaged = 1;
/**
- * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ * @var string String with name of icon for object don. Must be the part after the 'object_' into object_myobject.png
*/
public $picto = 'generic';
public $date;
public $amount;
+
+ /**
+ * @var string Thirdparty name
+ */
public $societe;
/**
@@ -71,18 +75,29 @@ class Don extends CommonObject
*/
public $address;
+ /**
+ * @var string Zipcode
+ */
public $zip;
+
+ /**
+ * @var string Town
+ */
public $town;
+
+ /**
+ * @var string Email
+ */
public $email;
public $public;
/**
- * @var int ID
+ * @var int project ID
*/
public $fk_project;
/**
- * @var int ID
+ * @var int type payment ID
*/
public $fk_typepayment;
@@ -90,7 +105,14 @@ class Don extends CommonObject
public $date_valid;
public $modepaymentid = 0;
+ /**
+ * @var array Array of status label
+ */
public $labelstatut;
+
+ /**
+ * @var array Array of status label short
+ */
public $labelstatutshort;
/**
diff --git a/htdocs/expensereport/export_csv.php b/htdocs/expensereport/export_csv.php
deleted file mode 100644
index d3f2518a53c..00000000000
--- a/htdocs/expensereport/export_csv.php
+++ /dev/null
@@ -1,195 +0,0 @@
-
- * Copyright (C) 2018 Frédéric France
- *
- * 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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/expensereport/index.php
- * \ingroup expensereport
- * \brief Page list of expenses
- */
-
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
-require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
-
-// Load translation files required by the page
-$langs->loadlangs(array('users', 'trips'));
-
-if(!$user->rights->expensereport->export_csv) {
- accessforbidden();
- exit();
-}
-
-// Security check
-$socid = $_GET["socid"]?$_GET["socid"]:'';
-if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'expensereport', '', '');
-
-$req = "SELECT * FROM ".MAIN_DB_PREFIX."rights_def WHERE id = '178'";
-$result = $db->query($req);
-$num = $db->num_rows($result);
-
-if($num < 1) {
- $insert = "INSERT INTO ".MAIN_DB_PREFIX."rights_def (";
- $insert.= "`id` ,";
- $insert.= "`libelle` ,";
- $insert.= "`module` ,";
- $insert.= "`entity` ,";
- $insert.= "`perms` ,";
- $insert.= "`subperms` ,";
- $insert.= "`type` ,";
- $insert.= "`bydefault`";
- $insert.= ")";
- $insert.= "VALUES (";
- $insert.= "'178', 'Exporter les notes de frais au format CSV', 'expensereport', '1', 'export_csv', NULL , 'r', '0'";
- $insert.= ")";
-
- $req = $db->query($insert);
-}
-
-
-/*
- * View
- */
-
-llxHeader();
-
-print load_fiche_titre($langs->trans("ExportTripCSV"));
-
-print '
';
-
-print '
';
-print '';
-print '
Choisir le mois à exporter : ';
-
-$year = date('Y', time());
-$month = date('m', time());
-
-print ' ';
-
-print ' ';
-
-print '';
-print '
';
-
-// End of page
-llxFooter();
-$db->close();
diff --git a/htdocs/install/lib/repair.lib.php b/htdocs/install/lib/repair.lib.php
index 98eac2437fa..dc6544fc2be 100644
--- a/htdocs/install/lib/repair.lib.php
+++ b/htdocs/install/lib/repair.lib.php
@@ -72,7 +72,7 @@ function checkLinkedElements($sourcetype, $targettype)
$out = $langs->trans('SourceType').': '.$sourcetype.' => '.$langs->trans('TargetType').': '.$targettype.' ';
- $sql = 'SELECT * FROM '.MAIN_DB_PREFIX .'element_element';
+ $sql = 'SELECT rowid, fk_source, fk_target FROM '.MAIN_DB_PREFIX .'element_element';
$sql.= ' WHERE sourcetype="'.$sourcetype.'" AND targettype="'.$targettype.'"';
$resql=$db->query($sql);
if ($resql)
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 484ad5f7867..0acd25ec536 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -151,7 +151,7 @@ ErrorBillNotFound=Invoice %s does not exist
ErrorInvoiceAlreadyReplaced=Error, you tried to validate an invoice to replace invoice %s. But this one has already been replaced by invoice %s.
ErrorDiscountAlreadyUsed=Error, discount already used
ErrorInvoiceAvoirMustBeNegative=Error, correct invoice must have a negative amount
-ErrorInvoiceOfThisTypeMustBePositive=Error, this type of invoice must have a positive amount
+ErrorInvoiceOfThisTypeMustBePositive=Error, this type of invoice must have an amount excluding tax positive (or null)
ErrorCantCancelIfReplacementInvoiceNotValidated=Error, can't cancel an invoice that has been replaced by another invoice that is still in draft status
ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved=This part or another is already used so discount series cannot be removed.
BillFrom=From
@@ -295,7 +295,8 @@ AddGlobalDiscount=Create absolute discount
EditGlobalDiscounts=Edit absolute discounts
AddCreditNote=Create credit note
ShowDiscount=Show discount
-ShowReduc=Show the deduction
+ShowReduc=Show the discount
+ShowSourceInvoice=Show the source invoice
RelativeDiscount=Relative discount
GlobalDiscount=Global discount
CreditNote=Credit note
diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang
index 34590a924be..6e9b6d66f32 100644
--- a/htdocs/langs/en_US/other.lang
+++ b/htdocs/langs/en_US/other.lang
@@ -252,6 +252,7 @@ ThirdPartyCreatedByEmailCollector=Third party created by email collector from em
ContactCreatedByEmailCollector=Contact/address created by email collector from email MSGID %s
ProjectCreatedByEmailCollector=Project created by email collector from email MSGID %s
TicketCreatedByEmailCollector=Ticket created by email collector from email MSGID %s
+OpeningHoursFormatDesc=Use a - to separate opening and closing hours. Use a space to enter different ranges. Example: 8-12 14-18
##### Export #####
ExportsArea=Exports area
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 4fc94feb1f4..f522ad29fa8 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -1625,16 +1625,16 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead
if (!empty($conf->global->MAIN_USE_TOP_MENU_SEARCH_DROPDOWN)){
// Add search dropdown
- $toprightmenu.= top_menu_search($user, $langs);
+ $toprightmenu.= top_menu_search();
}
if (!empty($conf->global->MAIN_USE_TOP_MENU_BOOKMARK_DROPDOWN)) {
// Add bookmark dropdown
- $toprightmenu .= top_menu_bookmark($user, $langs);
+ $toprightmenu .= top_menu_bookmark();
}
// Add user dropdown
- $toprightmenu.= top_menu_user($user, $langs);
+ $toprightmenu.= top_menu_user();
$toprightmenu.='';
@@ -1747,11 +1747,9 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead
/**
* Build the tooltip on user login
*
- * @param user $user User object
- * @param Translate $langs Language object
* @return string HTML content
*/
-function top_menu_user(User $user, Translate $langs)
+function top_menu_user()
{
global $langs, $conf, $db, $hookmanager, $user;
global $dolibarr_main_authentication, $dolibarr_main_demo;
@@ -1916,15 +1914,13 @@ function top_menu_user(User $user, Translate $langs)
/**
* Build the tooltip on top menu bookmark
*
- * @param user $user User object
- * @param Translate $langs Language object
* @return string HTML content
*/
-function top_menu_bookmark(User $user, Translate $langs)
+function top_menu_bookmark()
{
- global $langs, $conf, $db, $hookmanager, $user;
- global $menumanager;
- $html = '';
+ global $langs, $conf, $db, $user;
+
+ $html = '';
// Define $bookmarks
if (! empty($conf->bookmark->enabled) && $user->rights->bookmark->lire)
@@ -1938,7 +1934,7 @@ function top_menu_bookmark(User $user, Translate $langs)
';
$html .= $langs->trans("NoDraftProposals");
diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php
index 81e2659d918..d6066b1a03a 100644
--- a/htdocs/product/class/api_products.class.php
+++ b/htdocs/product/class/api_products.class.php
@@ -1,5 +1,6 @@
+ * Copyright (C) 2019 Cedric Ancelin
*
* 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
@@ -59,15 +60,11 @@ class Products extends DolibarrApi
}
/**
- * Get properties of a product object (from its ID, Ref, Ref_ext or Barcode)
+ * Get properties of a product object by id
*
* Return an array with product information.
- * TODO implement getting a product by ref or by $ref_ext
*
* @param int $id ID of product
- * @param string $ref Ref of element
- * @param string $ref_ext Ref ext of element
- * @param string $barcode Barcode of element
* @param int $includestockdata Load also information about stock (slower)
* @return array|mixed Data without useless information
*
@@ -75,32 +72,72 @@ class Products extends DolibarrApi
* @throws 403
* @throws 404
*/
- public function get($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0)
+ public function get($id, $includestockdata = 0)
{
- if (empty($id) && empty($ref) && empty($ref_ext) && empty($barcode)) {
- throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode');
- }
+ return $this->_fetch($id, '', '', '', $includestockdata);
+ }
- $id = (empty($id)?0:$id);
+ /**
+ * Get properties of a product object by ref
+ *
+ * Return an array with product information.
+ *
+ * @param string $ref Ref of element
+ * @param int $includestockdata Load also information about stock (slower)
+ *
+ * @return array|mixed Data without useless information
+ *
+ * @url GET byRef/{ref}
+ *
+ * @throws 401
+ * @throws 403
+ * @throws 404
+ */
+ public function getByRef($ref, $includestockdata = 0)
+ {
+ return $this->_fetch('', $ref, '', '', $includestockdata);
+ }
- if(! DolibarrApiAccess::$user->rights->produit->lire) {
- throw new RestException(403);
- }
+ /**
+ * Get properties of a product object by ref_ext
+ *
+ * Return an array with product information.
+ *
+ * @param string $ref_ext Ref_ext of element
+ * @param int $includestockdata Load also information about stock (slower)
+ *
+ * @return array|mixed Data without useless information
+ *
+ * @url GET byRefExt/{ref_ext}
+ *
+ * @throws 401
+ * @throws 403
+ * @throws 404
+ */
+ public function getByRefExt($ref_ext, $includestockdata = 0)
+ {
+ return $this->_fetch('', '', $ref_ext, '', $includestockdata);
+ }
- $result = $this->product->fetch($id, $ref, $ref_ext, $barcode);
- if(! $result ) {
- throw new RestException(404, 'Product not found');
- }
-
- if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
-
- if ($includestockdata) {
- $this->product->load_stock();
- }
-
- return $this->_cleanObjectDatas($this->product);
+ /**
+ * Get properties of a product object by barcode
+ *
+ * Return an array with product information.
+ *
+ * @param string $barcode Barcode of element
+ * @param int $includestockdata Load also information about stock (slower)
+ *
+ * @return array|mixed Data without useless information
+ *
+ * @url GET byBarcode/{barcode}
+ *
+ * @throws 401
+ * @throws 403
+ * @throws 404
+ */
+ public function getByBarcode($barcode, $includestockdata = 0)
+ {
+ return $this->_fetch('', '', '', $barcode, $includestockdata);
}
/**
@@ -246,7 +283,7 @@ class Products extends DolibarrApi
}
$this->product->$field = $value;
}
-
+
$updatetype = false;
if ($this->product->type != $oldproduct->type && ($this->product->isProduct() || $this->product->isService())) {
$updatetype = true;
@@ -696,4 +733,48 @@ class Products extends DolibarrApi
}
return $product;
}
+
+ /**
+ * Get properties of a product object
+ *
+ * Return an array with product information.
+ *
+ * @param int $id ID of product
+ * @param string $ref Ref of element
+ * @param string $ref_ext Ref ext of element
+ * @param string $barcode Barcode of element
+ * @param int $includestockdata Load also information about stock (slower)
+ * @return array|mixed Data without useless information
+ *
+ * @throws 401
+ * @throws 403
+ * @throws 404
+ */
+ private function _fetch($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0)
+ {
+ if (empty($id) && empty($ref) && empty($ref_ext) && empty($barcode)) {
+ throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode');
+ }
+
+ $id = (empty($id)?0:$id);
+
+ if(! DolibarrApiAccess::$user->rights->produit->lire) {
+ throw new RestException(403);
+ }
+
+ $result = $this->product->fetch($id, $ref, $ref_ext, $barcode);
+ if(! $result ) {
+ throw new RestException(404, 'Product not found');
+ }
+
+ if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+
+ if ($includestockdata) {
+ $this->product->load_stock();
+ }
+
+ return $this->_cleanObjectDatas($this->product);
+ }
}
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index d7ab4e99c78..5492f760407 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -1603,85 +1603,85 @@ class Product extends CommonObject
$price_base_type = $this->price_base_type;
// If price per segment
- if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($thirdparty_buyer->price_level))
+ if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($thirdparty_buyer->price_level))
{
- $pu_ht = $this->multiprices[$thirdparty_buyer->price_level];
- $pu_ttc = $this->multiprices_ttc[$thirdparty_buyer->price_level];
- $price_min = $this->multiprices_min[$thirdparty_buyer->price_level];
- $price_base_type = $this->multiprices_base_type[$thirdparty_buyer->price_level];
- if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
- {
- if (isset($this->multiprices_tva_tx[$thirdparty_buyer->price_level])) $tva_tx=$this->multiprices_tva_tx[$thirdparty_buyer->price_level];
- if (isset($this->multiprices_recuperableonly[$thirdparty_buyer->price_level])) $tva_npr=$this->multiprices_recuperableonly[$thirdparty_buyer->price_level];
- if (empty($tva_tx)) $tva_npr=0;
- }
- }
+ $pu_ht = $this->multiprices[$thirdparty_buyer->price_level];
+ $pu_ttc = $this->multiprices_ttc[$thirdparty_buyer->price_level];
+ $price_min = $this->multiprices_min[$thirdparty_buyer->price_level];
+ $price_base_type = $this->multiprices_base_type[$thirdparty_buyer->price_level];
+ if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
+ {
+ if (isset($this->multiprices_tva_tx[$thirdparty_buyer->price_level])) $tva_tx=$this->multiprices_tva_tx[$thirdparty_buyer->price_level];
+ if (isset($this->multiprices_recuperableonly[$thirdparty_buyer->price_level])) $tva_npr=$this->multiprices_recuperableonly[$thirdparty_buyer->price_level];
+ if (empty($tva_tx)) $tva_npr=0;
+ }
+ }
// If price per customer
- elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
+ elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
{
- require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
+ require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
- $prodcustprice = new Productcustomerprice($db);
+ $prodcustprice = new Productcustomerprice($db);
- $filter = array('t.fk_product' => $this->id,'t.fk_soc' => $thirdparty_buyer->id);
+ $filter = array('t.fk_product' => $this->id,'t.fk_soc' => $thirdparty_buyer->id);
- $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
- if ($result) {
- if (count($prodcustprice->lines) > 0) {
- $pu_ht = price($prodcustprice->lines[0]->price);
- $pu_ttc = price($prodcustprice->lines[0]->price_ttc);
- $price_base_type = $prodcustprice->lines[0]->price_base_type;
- $tva_tx = $prodcustprice->lines[0]->tva_tx;
- if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
- $tva_npr = $prodcustprice->lines[0]->recuperableonly;
- if (empty($tva_tx)) $tva_npr=0;
- }
- }
+ $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
+ if ($result) {
+ if (count($prodcustprice->lines) > 0) {
+ $pu_ht = price($prodcustprice->lines[0]->price);
+ $pu_ttc = price($prodcustprice->lines[0]->price_ttc);
+ $price_base_type = $prodcustprice->lines[0]->price_base_type;
+ $tva_tx = $prodcustprice->lines[0]->tva_tx;
+ if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
+ $tva_npr = $prodcustprice->lines[0]->recuperableonly;
+ if (empty($tva_tx)) $tva_npr=0;
}
+ }
+ }
// If price per quantity
- elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
+ elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
{
- if ($this->prices_by_qty[0]) // yes, this product has some prices per quantity
+ if ($this->prices_by_qty[0]) // yes, this product has some prices per quantity
+ {
+ // Search price into product_price_by_qty from $this->id
+ foreach($this->prices_by_qty_list[0] as $priceforthequantityarray)
+ {
+ if ($priceforthequantityarray['rowid'] != $pqp) continue;
+ // We found the price
+ if ($priceforthequantityarray['price_base_type'] == 'HT')
{
- // Search price into product_price_by_qty from $this->id
- foreach($this->prices_by_qty_list[0] as $priceforthequantityarray)
- {
- if ($priceforthequantityarray['rowid'] != $pqp) continue;
- // We found the price
- if ($priceforthequantityarray['price_base_type'] == 'HT')
- {
- $pu_ht = $priceforthequantityarray['unitprice'];
- }
- else
- {
- $pu_ttc = $priceforthequantityarray['unitprice'];
- }
- break;
- }
+ $pu_ht = $priceforthequantityarray['unitprice'];
}
+ else
+ {
+ $pu_ttc = $priceforthequantityarray['unitprice'];
+ }
+ break;
}
+ }
+ }
// If price per quantity and customer
- elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
+ elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
{
- if ($this->prices_by_qty[$thirdparty_buyer->price_level]) // yes, this product has some prices per quantity
+ if ($this->prices_by_qty[$thirdparty_buyer->price_level]) // yes, this product has some prices per quantity
+ {
+ // Search price into product_price_by_qty from $this->id
+ foreach($this->prices_by_qty_list[$thirdparty_buyer->price_level] as $priceforthequantityarray)
+ {
+ if ($priceforthequantityarray['rowid'] != $pqp) continue;
+ // We found the price
+ if ($priceforthequantityarray['price_base_type'] == 'HT')
{
- // Search price into product_price_by_qty from $this->id
- foreach($this->prices_by_qty_list[$thirdparty_buyer->price_level] as $priceforthequantityarray)
- {
- if ($priceforthequantityarray['rowid'] != $pqp) continue;
- // We found the price
- if ($priceforthequantityarray['price_base_type'] == 'HT')
- {
- $pu_ht = $priceforthequantityarray['unitprice'];
- }
- else
- {
- $pu_ttc = $priceforthequantityarray['unitprice'];
- }
- break;
- }
+ $pu_ht = $priceforthequantityarray['unitprice'];
}
+ else
+ {
+ $pu_ttc = $priceforthequantityarray['unitprice'];
+ }
+ break;
}
+ }
+ }
return array('pu_ht'=>$pu_ht, 'pu_ttc'=>$pu_ttc, 'price_min'=>$price_min, 'price_base_type'=>$price_base_type, 'tva_tx'=>$tva_tx, 'tva_npr'=>$tva_npr);
}
@@ -3725,21 +3725,80 @@ class Product extends CommonObject
*/
public function clone_price($fromId, $toId)
{
- // phpcs:enable
+ global $conf, $user;
+
+ $now = dol_now();
+
$this->db->begin();
- // les prix
- $sql = "INSERT ".MAIN_DB_PREFIX."product_price (";
- $sql.= " fk_product, date_price, price, tva_tx, localtax1_tx, localtax2_tx, fk_user_author, tosell)";
- $sql.= " SELECT ".$toId . ", date_price, price, tva_tx, localtax1_tx, localtax2_tx, fk_user_author, tosell";
- $sql.= " FROM ".MAIN_DB_PREFIX."product_price ";
- $sql.= " WHERE fk_product = ". $fromId;
+ // prices
+ $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_price (";
+ $sql .= " entity";
+ $sql .= ", fk_product";
+ $sql .= ", date_price";
+ $sql .= ", price_level";
+ $sql .= ", price";
+ $sql .= ", price_ttc";
+ $sql .= ", price_min";
+ $sql .= ", price_min_ttc";
+ $sql .= ", price_base_type";
+ $sql .= ", default_vat_code";
+ $sql .= ", tva_tx";
+ $sql .= ", recuperableonly";
+ $sql .= ", localtax1_tx";
+ $sql .= ", localtax1_type";
+ $sql .= ", localtax2_tx";
+ $sql .= ", localtax2_type";
+ $sql .= ", fk_user_author";
+ $sql .= ", tosell";
+ $sql .= ", price_by_qty";
+ $sql .= ", fk_price_expression";
+ $sql .= ", fk_multicurrency";
+ $sql .= ", multicurrency_code";
+ $sql .= ", multicurrency_tx";
+ $sql .= ", multicurrency_price";
+ $sql .= ", multicurrency_price_ttc";
+ $sql .= ")";
+ $sql .= " SELECT";
+ $sql .= " entity";
+ $sql .= ", " . $toId;
+ $sql .= ", '" . $this->db->idate($now) . "'";
+ $sql .= ", price_level";
+ $sql .= ", price";
+ $sql .= ", price_ttc";
+ $sql .= ", price_min";
+ $sql .= ", price_min_ttc";
+ $sql .= ", price_base_type";
+ $sql .= ", default_vat_code";
+ $sql .= ", tva_tx";
+ $sql .= ", recuperableonly";
+ $sql .= ", localtax1_tx";
+ $sql .= ", localtax1_type";
+ $sql .= ", localtax2_tx";
+ $sql .= ", localtax2_type";
+ $sql .= ", " . $user->id;
+ $sql .= ", tosell";
+ $sql .= ", price_by_qty";
+ $sql .= ", fk_price_expression";
+ $sql .= ", fk_multicurrency";
+ $sql .= ", multicurrency_code";
+ $sql .= ", multicurrency_tx";
+ $sql .= ", multicurrency_price";
+ $sql .= ", multicurrency_price_ttc";
+ $sql .= " FROM " . MAIN_DB_PREFIX . "product_price";
+ $sql .= " WHERE fk_product = ". $fromId;
+ $sql .= " ORDER BY date_price DESC";
+ if ($conf->global->PRODUIT_MULTIPRICES_LIMIT>0) {
+ $sql .= " LIMIT " . $conf->global->PRODUIT_MULTIPRICES_LIMIT;
+ }
- dol_syslog(get_class($this).'::clone_price', LOG_DEBUG);
- if (! $this->db->query($sql)) {
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (!$resql) {
$this->db->rollback();
return -1;
}
+
$this->db->commit();
return 1;
}
@@ -4293,14 +4352,14 @@ class Product extends CommonObject
{
switch ($type)
{
- case 0:
+ case 0:
return $this->LibStatut($this->status, $mode, $type);
- case 1:
+ case 1:
return $this->LibStatut($this->status_buy, $mode, $type);
- case 2:
+ case 2:
return $this->LibStatut($this->status_batch, $mode, $type);
- default:
- //Simulate previous behavior but should return an error string
+ default:
+ //Simulate previous behavior but should return an error string
return $this->LibStatut($this->status_buy, $mode, $type);
}
}
diff --git a/htdocs/product/inventory/ajax/ajax.inventory.php b/htdocs/product/inventory/ajax/ajax.inventory.php
index f94a383f666..ced76050e31 100644
--- a/htdocs/product/inventory/ajax/ajax.inventory.php
+++ b/htdocs/product/inventory/ajax/ajax.inventory.php
@@ -6,45 +6,45 @@ require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php';
$get = GETPOST('get', 'alpha');
$put = GETPOST('put', 'alpha');
- switch ($put)
- {
- case 'qty':
- if (empty($user->rights->stock->creer)) { echo -1; exit; }
+switch ($put)
+{
+ case 'qty':
+ if (empty($user->rights->stock->creer)) { echo -1; exit; }
- $fk_det_inventory = GETPOST('fk_det_inventory');
+ $fk_det_inventory = GETPOST('fk_det_inventory');
- $det = new InventoryLine($db);
- if( $det->fetch($fk_det_inventory))
- {
- $det->qty_view+=GETPOST('qty');
- $res = $det->update($user);
+ $det = new InventoryLine($db);
+ if( $det->fetch($fk_det_inventory))
+ {
+ $det->qty_view+=GETPOST('qty');
+ $res = $det->update($user);
- echo $det->qty_view;
- }
- else
- {
- echo -2;
- }
+ echo $det->qty_view;
+ }
+ else
+ {
+ echo -2;
+ }
- break;
+ break;
- case 'pmp':
- if (empty($user->rights->stock->creer) || empty($user->rights->stock->changePMP)) { echo -1; exit; }
+ case 'pmp':
+ if (empty($user->rights->stock->creer) || empty($user->rights->stock->changePMP)) { echo -1; exit; }
- $fk_det_inventory = GETPOST('fk_det_inventory');
+ $fk_det_inventory = GETPOST('fk_det_inventory');
- $det = new InventoryLine($db);
- if( $det->fetch($fk_det_inventory))
- {
- $det->new_pmp=price2num(GETPOST('pmp'));
- $det->update($user);
+ $det = new InventoryLine($db);
+ if( $det->fetch($fk_det_inventory))
+ {
+ $det->new_pmp=price2num(GETPOST('pmp'));
+ $det->update($user);
- echo $det->new_pmp;
- }
- else
- {
- echo -2;
- }
+ echo $det->new_pmp;
+ }
+ else
+ {
+ echo -2;
+ }
- break;
- }
+ break;
+}
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index 139fd681ee0..e8e332d95b5 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -475,10 +475,10 @@ if (empty($reshook))
{
$priceid = GETPOST('priceid', 'int');
if (!empty($rowid)) {
- $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
- $sql .= " WHERE fk_product_price = " . $priceid;
+ $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
+ $sql .= " WHERE fk_product_price = " . $priceid;
- $result = $db->query($sql);
+ $result = $db->query($sql);
} else {
setEventMessages(('delete_price_by_qty'.$langs->transnoentities(MissingIds)), null, 'errors');
}
@@ -755,17 +755,17 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUI
if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
{
- // TVA
- print '
' . $langs->trans("DefaultTaxRate") . '
';
+ // TVA
+ print '
' . $langs->trans("DefaultTaxRate") . '
';
- $positiverates='';
- if (price2num($object->multiprices_tva_tx[$soc->price_level])) $positiverates.=($positiverates?'/':'').price2num($object->multiprices_tva_tx[$soc->price_level]);
- if (price2num($object->multiprices_localtax1_type[$soc->price_level])) $positiverates.=($positiverates?'/':'').price2num($object->multiprices_localtax1_tx[$soc->price_level]);
- if (price2num($object->multiprices_localtax2_type[$soc->price_level])) $positiverates.=($positiverates?'/':'').price2num($object->multiprices_localtax2_tx[$soc->price_level]);
- if (empty($positiverates)) $positiverates='0';
- echo vatrate($positiverates.($object->default_vat_code?' ('.$object->default_vat_code.')':''), '%', $object->tva_npr);
- //print vatrate($object->multiprices_tva_tx[$soc->price_level], true);
- print '
';
+ $positiverates='';
+ if (price2num($object->multiprices_tva_tx[$soc->price_level])) $positiverates.=($positiverates?'/':'').price2num($object->multiprices_tva_tx[$soc->price_level]);
+ if (price2num($object->multiprices_localtax1_type[$soc->price_level])) $positiverates.=($positiverates?'/':'').price2num($object->multiprices_localtax1_tx[$soc->price_level]);
+ if (price2num($object->multiprices_localtax2_type[$soc->price_level])) $positiverates.=($positiverates?'/':'').price2num($object->multiprices_localtax2_tx[$soc->price_level]);
+ if (empty($positiverates)) $positiverates='0';
+ echo vatrate($positiverates.($object->default_vat_code?' ('.$object->default_vat_code.')':''), '%', $object->tva_npr);
+ //print vatrate($object->multiprices_tva_tx[$soc->price_level], true);
+ print '
';
}
else
{
@@ -791,10 +791,10 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUI
{
if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
{
- // We show only vat for level 1
- print '
';
// Serial / Eat-by date
- if (! empty($conf->productbatch->enabled) &&
+if (! empty($conf->productbatch->enabled) &&
(($object->element == 'product' && $object->hasbatch())
|| ($object->element == 'stock'))
)
- {
- print '
';
- print '
element == 'stock'?'': ' class="fieldrequired"').'>'.$langs->trans("batch_number").'
';
- if ($pdluoid > 0)
- {
- // If form was opened for a specific pdluoid, field is disabled
- print '';
- print '';
- }
- else
- {
- print '';
- }
- print '
';
- print '
';
+{
+ print '
';
+ print '
element == 'stock'?'': ' class="fieldrequired"').'>'.$langs->trans("batch_number").'
';
+ if ($pdluoid > 0)
+ {
+ // If form was opened for a specific pdluoid, field is disabled
+ print '';
+ print '';
+ }
+ else
+ {
+ print '';
+ }
+ print '
';
+ print '
';
- print '
';
- print '
'.$langs->trans("EatByDate").'
';
- print $form->selectDate(($d_eatby?$d_eatby:$pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
- print '
';
- print '
'.$langs->trans("SellByDate").'
';
- print $form->selectDate(($d_sellby?$d_sellby:$pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
- print '
';
- print '
';
- }
+ print '
';
+ print '
'.$langs->trans("EatByDate").'
';
+ print $form->selectDate(($d_eatby?$d_eatby:$pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
+ print '
';
+ print '
'.$langs->trans("SellByDate").'
';
+ print $form->selectDate(($d_sellby?$d_sellby:$pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled
+ print '
';
+ print '
';
+}
// Label
$valformovementlabel=(GETPOST("label")?GETPOST("label"):$langs->trans("MovementTransferStock", $productref));
diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php
index f5db207a42e..e51b2e4b404 100644
--- a/htdocs/projet/activity/perweek.php
+++ b/htdocs/projet/activity/perweek.php
@@ -813,23 +813,23 @@ if (count($tasksarray) > 0)
print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'';
print '';
- for ($idw = 0; $idw < 7; $idw++)
+ for ($idw = 0; $idw < 7; $idw++)
{
- $cssweekend='';
- if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
- {
- $cssweekend='weekend';
- }
+ $cssweekend='';
+ if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css.
+ {
+ $cssweekend='weekend';
+ }
- $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd');
+ $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd');
- $cssonholiday='';
- if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday ';
- elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning ';
- elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon ';
+ $cssonholiday='';
+ if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday ';
+ elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning ';
+ elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon ';
- print '
';
- }
+ print '
';
+ }
print '
';
}
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index da2d41512e1..a873b53dbc0 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -401,7 +401,7 @@ class Project extends CommonObject
$result = 1;
}
else
- {
+ {
$this->db->rollback();
$result = -1;
}
@@ -1222,7 +1222,7 @@ class Project extends CommonObject
// No filter. Use this if user has permission to see all project
}
- $sql.= $filter;
+ $sql.= $filter;
//print $sql;
$resql = $this->db->query($sql);
@@ -1722,23 +1722,23 @@ class Project extends CommonObject
$num = $this->db->num_rows($resql);
$i = 0;
// Loop on each record found, so each couple (project id, task id)
- while ($i < $num)
+ while ($i < $num)
{
- $obj=$this->db->fetch_object($resql);
- $day=$this->db->jdate($obj->task_date); // task_date is date without hours
- if (empty($daylareadyfound[$day]))
- {
- $this->weekWorkLoad[$day] = $obj->task_duration;
- $this->weekWorkLoadPerTask[$day][$obj->fk_task] = $obj->task_duration;
- }
- else
- {
- $this->weekWorkLoad[$day] += $obj->task_duration;
- $this->weekWorkLoadPerTask[$day][$obj->fk_task] += $obj->task_duration;
- }
- $daylareadyfound[$day]=1;
- $i++;
- }
+ $obj=$this->db->fetch_object($resql);
+ $day=$this->db->jdate($obj->task_date); // task_date is date without hours
+ if (empty($daylareadyfound[$day]))
+ {
+ $this->weekWorkLoad[$day] = $obj->task_duration;
+ $this->weekWorkLoadPerTask[$day][$obj->fk_task] = $obj->task_duration;
+ }
+ else
+ {
+ $this->weekWorkLoad[$day] += $obj->task_duration;
+ $this->weekWorkLoadPerTask[$day][$obj->fk_task] += $obj->task_duration;
+ }
+ $daylareadyfound[$day]=1;
+ $i++;
+ }
$this->db->free($resql);
return 1;
}
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index e35b4b4bdad..1bd044bc985 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -852,15 +852,15 @@ class Task extends CommonObject
$sql.=" t.rowid, t.ref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut,";
$sql.=" t.dateo, t.datee, t.planned_workload, t.rang,";
$sql.=" s.rowid, s.nom, s.email,";
- $sql.=" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount";
- if (!empty($extrafields->attributes['projet']['label']))
- {
- foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql.=($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key : '');
- }
- if (!empty($extrafields->attributes['projet_task']['label']))
- {
- foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql.=($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key : '');
- }
+ $sql.=" p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount";
+ if (!empty($extrafields->attributes['projet']['label']))
+ {
+ foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql.=($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key : '');
+ }
+ if (!empty($extrafields->attributes['projet_task']['label']))
+ {
+ foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql.=($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key : '');
+ }
}
$sql.= " ORDER BY p.ref, t.rang, t.dateo";
diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php
index 3a2886229a0..44b803571ba 100644
--- a/htdocs/projet/element.php
+++ b/htdocs/projet/element.php
@@ -863,8 +863,8 @@ foreach ($listofreferent as $key => $value)
if (canApplySubtotalOn($tablename))
{
- // Sort
- $elementarray = sortElementsByClientName($elementarray);
+ // Sort
+ $elementarray = sortElementsByClientName($elementarray);
}
$num=count($elementarray);
@@ -1077,9 +1077,9 @@ foreach ($listofreferent as $key => $value)
if ($othermessage) print $othermessage;
if (isset($total_ht_by_line))
{
- if (! $qualifiedfortotal) print '';
- print price($total_ht_by_line);
- if (! $qualifiedfortotal) print '';
+ if (! $qualifiedfortotal) print '';
+ print price($total_ht_by_line);
+ if (! $qualifiedfortotal) print '';
}
if ($warning) print ' '.img_warning($warning);
print '';
@@ -1124,9 +1124,9 @@ foreach ($listofreferent as $key => $value)
if ($othermessage) print $othermessage;
if (isset($total_ttc_by_line))
{
- if (! $qualifiedfortotal) print '';
- print price($total_ttc_by_line);
- if (! $qualifiedfortotal) print '';
+ if (! $qualifiedfortotal) print '';
+ print price($total_ttc_by_line);
+ if (! $qualifiedfortotal) print '';
}
if ($warning) print ' '.img_warning($warning);
print '';
diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php
index 5c5cd398354..7d75544ef93 100644
--- a/htdocs/projet/graph_opportunities.inc.php
+++ b/htdocs/projet/graph_opportunities.inc.php
@@ -35,11 +35,11 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
$valsamount[$obj->opp_status]=$obj->opp_amount;
$totalnb+=$obj->nb;
if ($obj->opp_status) $totaloppnb+=$obj->nb;
- if (! in_array($obj->code, array('WON', 'LOST')))
+ if (! in_array($obj->code, array('WON', 'LOST')))
{
- $totalamount+=$obj->opp_amount;
- $ponderated_opp_amount+=$obj->ponderated_opp_amount;
- }
+ $totalamount+=$obj->opp_amount;
+ $ponderated_opp_amount+=$obj->ponderated_opp_amount;
+ }
}
$total+=$row[0];
}
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index 9a5514ff1cc..8524e940f36 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -143,10 +143,10 @@ $arrayfields=array(
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
- foreach($extrafields->attribute_label as $key => $val)
- {
+ foreach($extrafields->attribute_label as $key => $val)
+ {
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key]));
- }
+ }
}
diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php
index 9353f968116..f8480f8f322 100644
--- a/htdocs/projet/stats/index.php
+++ b/htdocs/projet/stats/index.php
@@ -108,7 +108,7 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
unset($data1);
if ($nocolor)
-$px->SetDataColor(array (
+ $px->SetDataColor(array (
array (
220,
220,
@@ -130,9 +130,9 @@ $px->SetDataColor(array (
));
$px->SetTitle($langs->trans('OpportunitiesStatusForProjects'));
$result=$px->draw($filenamenb, $fileurlnb);
- if ($result<0) {
- setEventMessages($px->error, null, 'errors');
- }
+ if ($result<0) {
+ setEventMessages($px->error, null, 'errors');
+ }
} else {
setEventMessages(null, $mesgs, 'errors');
}
diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php
index 3d4077790c7..2abfea6e64e 100644
--- a/htdocs/projet/tasks.php
+++ b/htdocs/projet/tasks.php
@@ -645,7 +645,7 @@ elseif ($id > 0 || ! empty($ref))
print ' ';
-// Link to create task
+ // Link to create task
$linktocreatetaskParam = array();
$linktocreatetaskUserRight = false;
if ($user->rights->projet->all->creer || $user->rights->projet->creer) {
@@ -787,8 +787,8 @@ elseif ($id > 0 || ! empty($ref))
print_liste_field_titre("TaskProgressSummary", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center ');
if ($object->usage_bill_time)
{
- print_liste_field_titre("TimeToBill", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right ');
- print_liste_field_titre("TimeBilled", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right ');
+ print_liste_field_titre("TimeToBill", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right ');
+ print_liste_field_titre("TimeBilled", $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'right ');
}
if (! empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print_liste_field_titre("TaskRessourceLinks", $_SERVER["PHP_SELF"], '', '', '', $sortfield, $sortorder);
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch ');
diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php
index 2448088c6b1..b09d8345177 100644
--- a/htdocs/projet/tasks/contact.php
+++ b/htdocs/projet/tasks/contact.php
@@ -356,7 +356,7 @@ if ($id > 0 || ! empty($ref))
/*
* Lines of contacts
*/
-/*
+ /*
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
foreach($dirtpls as $reldir)
@@ -364,7 +364,7 @@ if ($id > 0 || ! empty($ref))
$res=@include dol_buildpath($reldir.'/contacts.tpl.php');
if ($res) break;
}
-*/
+ */
/*
* Add a new contact line
diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php
index d9730946377..78431f983a4 100644
--- a/htdocs/projet/tasks/task.php
+++ b/htdocs/projet/tasks/task.php
@@ -616,7 +616,7 @@ if ($id > 0 || ! empty($ref))
{
if (! $object->hasChildren() && ! $object->hasTimeSpent())
{
- print ''.$langs->trans('Delete').'';
+ print ''.$langs->trans('Delete').'';
}
else
{
diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php
index 8b95e85f899..15670a2095d 100644
--- a/htdocs/societe/class/api_thirdparties.class.php
+++ b/htdocs/societe/class/api_thirdparties.class.php
@@ -1,6 +1,7 @@
* Copyright (C) 2018 Pierre Chéné
+ * Copyright (C) 2019 Cedric Ancelin
*
* 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
@@ -71,38 +72,26 @@ class Thirdparties extends DolibarrApi
*
* @throws RestException
*/
- public function get($id)
+ public function get($id)
{
- if(! DolibarrApiAccess::$user->rights->societe->lire) {
- throw new RestException(401);
- }
- if ($id ==0) {
- $result = $this->company->initAsSpecimen();
- } else {
- $result = $this->company->fetch($id);
- }
- if( ! $result ) {
- throw new RestException(404, 'Thirdparty not found');
- }
+ return $this->_fetch($id);
+ }
- if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
-
- if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
- $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
- $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
- } else {
- $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
- $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
- }
-
- $absolute_discount = $this->company->getAvailableDiscounts('', $filterabsolutediscount);
- $absolute_creditnote = $this->company->getAvailableDiscounts('', $filtercreditnote);
- $this->company->absolute_discount = price2num($absolute_discount, 'MT');
- $this->company->absolute_creditnote = price2num($absolute_creditnote, 'MT');
-
- return $this->_cleanObjectDatas($this->company);
+ /**
+ * Get properties of a thirdparty object by email.
+ *
+ * Return an array with thirdparty informations
+ *
+ * @param string $email Sort field
+ * @return array|mixed data without useless information
+ *
+ * @url GET byEmail/{email}
+ *
+ * @throws RestException
+ */
+ public function getByEmail($email)
+ {
+ return $this->_fetch('', '', '', '', '', '', '', '', '', '', $email);
}
/**
@@ -1674,4 +1663,56 @@ class Thirdparties extends DolibarrApi
}
return $thirdparty;
}
+
+ /**
+ * Fetch properties of a thirdparty object.
+ *
+ * Return an array with thirdparty informations
+ *
+ * @param int $rowid Id of third party to load
+ * @param string $ref Reference of third party, name (Warning, this can return several records)
+ * @param string $ref_ext External reference of third party (Warning, this information is a free field not provided by Dolibarr)
+ * @param string $ref_int Internal reference of third party (not used by dolibarr)
+ * @param string $idprof1 Prof id 1 of third party (Warning, this can return several records)
+ * @param string $idprof2 Prof id 2 of third party (Warning, this can return several records)
+ * @param string $idprof3 Prof id 3 of third party (Warning, this can return several records)
+ * @param string $idprof4 Prof id 4 of third party (Warning, this can return several records)
+ * @param string $idprof5 Prof id 5 of third party (Warning, this can return several records)
+ * @param string $idprof6 Prof id 6 of third party (Warning, this can return several records)
+ * @param string $email Email of third party (Warning, this can return several records)
+ * @param string $ref_alias Name_alias of third party (Warning, this can return several records)
+ * @return array|mixed data without useless information
+ *
+ * @throws RestException
+ */
+ private function _fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $idprof1 = '', $idprof2 = '', $idprof3 = '', $idprof4 = '', $idprof5 = '', $idprof6 = '', $email = '', $ref_alias = '')
+ {
+ if(! DolibarrApiAccess::$user->rights->societe->lire) {
+ throw new RestException(401);
+ }
+
+ $result = $this->company->fetch($rowid, $ref, $ref_ext, $ref_int, $idprof1, $idprof2, $idprof3, $idprof4, $idprof5, $idprof6, $email, $ref_alias);
+ if( ! $result ) {
+ throw new RestException(404, 'Thirdparty not found');
+ }
+
+ if( ! DolibarrApi::_checkAccessToResource('societe', $this->company->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+
+ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+ $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ } else {
+ $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
+ $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
+ }
+
+ $absolute_discount = $this->company->getAvailableDiscounts('', $filterabsolutediscount);
+ $absolute_creditnote = $this->company->getAvailableDiscounts('', $filtercreditnote);
+ $this->company->absolute_discount = price2num($absolute_discount, 'MT');
+ $this->company->absolute_creditnote = price2num($absolute_creditnote, 'MT');
+
+ return $this->_cleanObjectDatas($this->company);
+ }
}
diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php
index 3574b4d29a2..69228b5efb5 100644
--- a/htdocs/takepos/ajax/ajax.php
+++ b/htdocs/takepos/ajax/ajax.php
@@ -45,18 +45,31 @@ $term = GETPOST('term', 'alpha');
if ($action=="getProducts") {
$object = new Categorie($db);
$result=$object->fetch($category);
- $prods = $object->getObjectsInCateg("product");
- echo json_encode($prods);
+ if ($result)
+ {
+ $prods = $object->getObjectsInCateg("product");
+ echo json_encode($prods);
+ }
+ else
+ {
+ echo 'Failed to load category with id='.$category;
+ }
}
elseif ($action=="search" && $term != '') {
- $sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'product';
+ $sql = 'SELECT rowid, ref, label, tosell, tobuy FROM '.MAIN_DB_PREFIX.'product';
$sql.= ' WHERE entity IN ('.getEntity('product').')';
$sql.= ' AND tosell = 1';
$sql.= natural_search(array('ref','label','barcode'), $term);
$resql = $db->query($sql);
- $rows = array();
- while ($row = $db->fetch_array($resql)) {
- $rows[] = $row;
- }
- echo json_encode($rows);
+ if ($resql)
+ {
+ $rows = array();
+ while ($row = $db->fetch_object($resql)) {
+ $rows[] = $row;
+ }
+ echo json_encode($rows);
+ }
+ else {
+ echo 'Failed to search product : '.$db->lasterror();
+ }
}
diff --git a/htdocs/takepos/css/pos.css b/htdocs/takepos/css/pos.css
index 91c29d73ac1..db3ddfdfa34 100644
--- a/htdocs/takepos/css/pos.css
+++ b/htdocs/takepos/css/pos.css
@@ -132,7 +132,7 @@ table.postablelines tr td {
div.paymentbordline
{
width:50%;
- background-color:#666;
+ background-color:#888;
border-radius: 8px;
margin-bottom: 4px;
}
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index a2c92aa13e4..6a67d9d03f9 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -141,7 +141,7 @@ if ($action == 'valid' && $user->rights->facture->creer)
$invoice = new Facture($db);
$invoice->fetch($placeid);
- if($invoice->total_ttc<0){
+ if ($invoice->total_ttc < 0) {
$invoice->type= $invoice::TYPE_CREDIT_NOTE;
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture WHERE ";
$sql.="fk_soc = '".$invoice->socid."' ";
@@ -189,8 +189,10 @@ if ($action == 'valid' && $user->rights->facture->creer)
$res = $invoice->validate($user);
}
+ $remaintopay = $invoice->getRemainToPay();
+
// Add the payment
- if ($res > 0) {
+ if ($res >= 0 && $remaintopay > 0) {
$payment = new Paiement($db);
$payment->datepaye = $now;
$payment->fk_account = $bankaccount;
@@ -205,9 +207,9 @@ if ($action == 'valid' && $user->rights->facture->creer)
$payment->create($user);
$payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', '');
- $remaintopay = $invoice->getRemainToPay();
+ $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded
if ($remaintopay == 0) {
- dol_syslog("Invoice is paid, so we set it to pay");
+ dol_syslog("Invoice is paid, so we set it to status Paid");
$result = $invoice->set_paid($user);
if ($result > 0) $invoice->paye = 1;
} else {
@@ -656,7 +658,7 @@ if ($placeid > 0)
{
//In Phone basic layout hide some content depends situation
if ($_SESSION["basiclayout"]==1 && $mobilepage!="invoice" && $action!="order") return;
-
+
if (is_array($invoice->lines) && count($invoice->lines))
{
$tmplines = array_reverse($invoice->lines);
@@ -716,10 +718,12 @@ print '
';
if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]})
{
- $soc = new Societe($db);
+ $constforcompanyid='CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"];
+ $soc = new Societe($db);
if ($invoice->socid > 0) $soc->fetch($invoice->socid);
- else $soc->fetch($conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]});
- print '