diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php
index c905ad25cd0..23ebde7e230 100644
--- a/htdocs/accountancy/admin/card.php
+++ b/htdocs/accountancy/admin/card.php
@@ -76,7 +76,7 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
$action = 'create';
} else {
- $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
+ $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid='.((int) $conf->global->CHARTOFACCOUNTS);
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
$result = $db->query($sql);
diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php
index fcd7efdab47..de60bd09897 100644
--- a/htdocs/accountancy/bookkeeping/balance.php
+++ b/htdocs/accountancy/bookkeeping/balance.php
@@ -16,7 +16,6 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
- *
*/
/**
@@ -307,7 +306,7 @@ if ($action != 'export_csv')
$accountingaccountstatic->fetch(null, $line->numero_compte, true);
if (!empty($accountingaccountstatic->account_number)) {
- $accounting_account = $accountingaccountstatic->getNomUrl(0, 1);
+ $accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 0, '', 0, -1, 0, 'accountcard');
} else {
$accounting_account = length_accountg($line->numero_compte);
}
@@ -322,10 +321,19 @@ if ($action != 'export_csv')
$root_account_description = $tmparrayforrootaccount['label'];
$root_account_number = $tmparrayforrootaccount['account_number'];
+ //var_dump($tmparrayforrootaccount);
+ //var_dump($accounting_account);
+ //var_dump($accountingaccountstatic);
if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) {
$link = '' . img_edit() . '';
- } elseif (empty($tmparrayforrootaccount['label'])) {
+ } elseif ($accounting_account == 'NotDefined') {
$link = '' . img_edit_add() . '';
+ } elseif (empty($tmparrayforrootaccount['label'])) {
+ // $tmparrayforrootaccount['label'] not defined = the account has not parent with a parent.
+ // This is useless, we should not create a new account when an account has no parent, we must edit it to fix its parent.
+ // BUG 1: Accounts on level root or level 1 must not have a parent 2 level higher, so shoule not show a link to create another account.
+ // BUG 2: Adding a link to create a new accounting account here is useless because it is not add as parent of the orphelin.
+ //$link = '' . img_edit_add() . '';
}
if (!empty($show_subgroup))
@@ -363,8 +371,22 @@ if ($action != 'export_csv')
print '
';
print '
'.$accounting_account.'
';
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) print '
';
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index 40af8784817..614040fc063 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -1914,25 +1914,24 @@ class BookKeeping extends CommonObject
/**
* Return id and description of a root accounting account.
- * This function takes the parent of parent to get the root account !
+ * FIXME: This function takes the parent of parent to get the root account !
*
* @param string $account Accounting account
- * @return string Root account
+ * @return array Array with root account information (max 2 upper level)
*/
public function getRootAccount($account = null)
{
global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS;
- $sql = "SELECT root.rowid, root.account_number, root.label as label";
+ $sql = "SELECT root.rowid, root.account_number, root.label as label,";
+ $sql .= " parent.rowid as parent_rowid, parent.account_number as parent_account_number, parent.label as parent_label";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = ".((int) $pcgver);
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as parent ON aa.account_parent = parent.rowid";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as root ON parent.account_parent = root.rowid";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as parent ON aa.account_parent = parent.rowid AND parent.active = 1";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as root ON parent.account_parent = root.rowid AND root.active = 1";
$sql .= " WHERE aa.account_number = '".$this->db->escape($account)."'";
- $sql .= " AND parent.active = 1";
- $sql .= " AND root.active = 1";
$sql .= " AND aa.entity IN (".getEntity('accountancy').")";
dol_syslog(get_class($this)."::select_account sql=".$sql, LOG_DEBUG);
@@ -1943,7 +1942,8 @@ class BookKeeping extends CommonObject
$obj = $this->db->fetch_object($resql);
}
- return array('id'=>$obj->rowid, 'account_number'=>$obj->account_number, 'label'=>$obj->label);
+ $result = array('id'=>$obj->rowid, 'account_number'=>$obj->account_number, 'label'=>$obj->label);
+ return $result;
} else {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(__METHOD__." ".$this->error, LOG_ERR);
diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php
index c1f77f4995e..a072869be8c 100644
--- a/htdocs/admin/agenda_other.php
+++ b/htdocs/admin/agenda_other.php
@@ -51,6 +51,7 @@ $type = 'action';
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
+$reg = array();
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
{
$code = $reg[1];
diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php
index 24220f79f8c..31af34e3ad1 100644
--- a/htdocs/core/actions_setmoduleoptions.inc.php
+++ b/htdocs/core/actions_setmoduleoptions.inc.php
@@ -21,7 +21,7 @@
* \brief Code for actions on setting notes of object page
*/
-
+// $error must have been initialized to 0
// $action must be defined
// $arrayofparameters must be set for action 'update'
// $nomessageinupdate can be set to 1
@@ -31,7 +31,6 @@ if ($action == 'update' && is_array($arrayofparameters))
{
$db->begin();
- $ok = true;
foreach ($arrayofparameters as $key => $val)
{
// Modify constant only if key was posted (avoid resetting key to the null value)
@@ -40,7 +39,7 @@ if ($action == 'update' && is_array($arrayofparameters))
$result = dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity);
if ($result < 0)
{
- $ok = false;
+ $error++;
break;
}
}
@@ -93,7 +92,11 @@ if ($action == 'setModuleOptions')
if (!$tmpdir) {
unset($listofdir[$key]); continue;
}
- if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
+ if (!is_dir($tmpdir)) {
+ if (empty($nomessageinsetmoduleoptions)) {
+ setEventMessages($langs->trans("ErrorDirNotFound", $tmpdir), null, 'warnings');
+ }
+ }
else {
$upload_dir = $tmpdir;
}
diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
index e28cd62efae..2b9fb62b1d4 100644
--- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php
+++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
@@ -340,13 +340,12 @@ class pdf_strato extends ModelePDFContract
$datere = $langs->trans("Unknown");
}
- $txtpredefinedservice = '';
- $txtpredefinedservice = $objectligne->product_label;
- if ($objectligne->product_label)
- {
- $txtpredefinedservice .= ' - ';
- $txtpredefinedservice .= $objectligne->product_label;
- }
+ $txtpredefinedservice = $objectligne->product_ref;
+ if ($objectligne->product_label)
+ {
+ $txtpredefinedservice .= ' - ';
+ $txtpredefinedservice .= $objectligne->product_label;
+ }
$desc = dol_htmlentitiesbr($objectligne->desc, 1); // Desc (not empty for free lines)
$txt = '';
diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang
index 902f167d819..3dbcda8e4eb 100644
--- a/htdocs/langs/en_US/mrp.lang
+++ b/htdocs/langs/en_US/mrp.lang
@@ -8,11 +8,11 @@ MenuBOM=Bills of material
LatestBOMModified=Latest %s Bills of materials modified
LatestMOModified=Latest %s Manufacturing Orders modified
Bom=Bills of Material
-BillOfMaterials=Bill of Material
+BillOfMaterials=Bill of Materials
BOMsSetup=Setup of module BOM
ListOfBOMs=List of bills of material - BOM
ListOfManufacturingOrders=List of Manufacturing Orders
-NewBOM=New bill of material
+NewBOM=New bill of materials
ProductBOMHelp=Product to create with this BOM. Note: Products with the property 'Nature of product' = 'Raw material' are not visible into this list.
BOMsNumberingModules=BOM numbering templates
BOMsModelModule=BOM document templates
@@ -22,7 +22,7 @@ FreeLegalTextOnBOMs=Free text on document of BOM
WatermarkOnDraftBOMs=Watermark on draft BOM
FreeLegalTextOnMOs=Free text on document of MO
WatermarkOnDraftMOs=Watermark on draft MO
-ConfirmCloneBillOfMaterials=Are you sure you want to clone the bill of material %s ?
+ConfirmCloneBillOfMaterials=Are you sure you want to clone the bill of materials %s ?
ConfirmCloneMo=Are you sure you want to clone the Manufacturing Order %s ?
ManufacturingEfficiency=Manufacturing efficiency
ConsumptionEfficiency=Consumption efficiency
@@ -30,8 +30,8 @@ ValueOfMeansLoss=Value of 0.95 means an average of 5%% of loss during the produc
ValueOfMeansLossForProductProduced=Value of 0.95 means an average of 5%% of loss of produced product
DeleteBillOfMaterials=Delete Bill Of Materials
DeleteMo=Delete Manufacturing Order
-ConfirmDeleteBillOfMaterials=Are you sure you want to delete this Bill Of Material?
-ConfirmDeleteMo=Are you sure you want to delete this Bill Of Material?
+ConfirmDeleteBillOfMaterials=Are you sure you want to delete this Bill Of Materials?
+ConfirmDeleteMo=Are you sure you want to delete this Bill Of Materials?
MenuMRP=Manufacturing Orders
NewMO=New Manufacturing Order
QtyToProduce=Qty to produce
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index 7d09667bd22..a27ddb524a3 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -106,7 +106,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)
-if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
+if (!$sortfield) { reset($object->fields); $sortfield="t.".key($object->fields); } // Set here default search field. By default 1st field in definition. Reset is required to avoid key() to return null.
if (!$sortorder) $sortorder = "ASC";
// Initialize array of search criterias
diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php
index 655d501cac3..873678adcae 100644
--- a/htdocs/paypal/lib/paypal.lib.php
+++ b/htdocs/paypal/lib/paypal.lib.php
@@ -105,7 +105,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType,
$landingPage = 'Billing';
}
- dol_syslog("expresscheckout redirect with callSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum");
+ dol_syslog("print_paypal_redirect expresscheckout redirect with callSetExpressCheckout $paymentAmount, $currencyCodeType, $paymentType, $returnURL, $cancelURL, $tag, $solutionType, $landingPage, $shipToName, $shipToStreet, $shipToCity, $shipToState, $shipToCountryCode, $shipToZip, $shipToStreet2, $phoneNum");
$resArray = callSetExpressCheckout(
$paymentAmount,
$currencyCodeType,
@@ -127,6 +127,8 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType,
$desc
);
+ dol_syslog("print_paypal_redirect resArray=".var_export($resArray, true), LOG_DEBUG);
+
$ack = strtoupper($resArray["ACK"]);
if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING")
{
@@ -134,6 +136,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType,
// Redirect to paypal.com here
$payPalURL = $API_Url.$token;
+ dol_syslog("Redirect to ".$payPalURL, LOG_INFO);
header("Location: ".$payPalURL);
exit;
} else {
@@ -282,7 +285,7 @@ function callSetExpressCheckout($paymentAmount, $currencyCodeType, $paymentType,
$_SESSION["FinalPaymentAmt"] = $paymentAmount;
$_SESSION["currencyCodeType"] = $currencyCodeType;
$_SESSION["PaymentType"] = $paymentType; // 'Mark', 'Sole'
- $_SESSION['ipaddress'] = $_SERVER['REMOTE_ADDR']; // Payer ip
+ $_SESSION['ipaddress'] = getUserRemoteIP(); // Payer ip
//'---------------------------------------------------------------------------------------------------------------
//' Make the API call to PayPal
@@ -433,7 +436,7 @@ function DirectPayment($paymentType, $paymentAmount, $creditCardType, $creditCar
$nvpstr = $nvpstr . "&CITY=" . urlencode($city);
$nvpstr = $nvpstr . "&STATE=" . urlencode($state);
$nvpstr = $nvpstr . "&COUNTRYCODE=" . urlencode($countryCode);
- $nvpstr = $nvpstr . "&IPADDRESS=" . $_SERVER['REMOTE_ADDR'];
+ $nvpstr = $nvpstr . "&IPADDRESS=" . getUserRemotIP();
$nvpstr = $nvpstr . "&INVNUM=" . urlencode($tag);
$resArray=hash_call("DoDirectPayment", $nvpstr);
diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php
index ac92c958931..b99c4a39392 100644
--- a/htdocs/public/payment/paymentko.php
+++ b/htdocs/public/payment/paymentko.php
@@ -31,7 +31,7 @@ if (!defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined
if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1');
// For MultiCompany module.
-// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
+// Do not use GETPOST here, function is not defined and this test must be done before including main.inc.php
// TODO This should be useless. Because entity must be retrieve from object ref and not from url.
$entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1));
if (is_numeric($entity)) define("DOLENTITY", $entity);
diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php
index ef4931c4b4a..346e4003e4c 100644
--- a/htdocs/public/payment/paymentok.php
+++ b/htdocs/public/payment/paymentok.php
@@ -409,7 +409,7 @@ if ($ispaymentok)
$postactionmessages[] = $errmsg;
$ispostactionok = -1;
} else {
- $postactionmessages[] = 'Subscription created';
+ $postactionmessages[] = 'Subscription created (id='.$crowid.')';
$ispostactionok = 1;
}
}
diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php
index 84bec78bf30..d4185e7dbc6 100644
--- a/htdocs/ticket/card.php
+++ b/htdocs/ticket/card.php
@@ -586,16 +586,16 @@ if (empty($reshook)) {
if (!$error) {
$result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
- if ($result > 0) {
- setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
- $action = 'view';
- } else {
- $error++;
- setEventMessages($object->error, $object->errors, 'errors');
- }
+ if ($result < 0) { $error++; }
}
- if ($error) $action = 'edit_extras';
+ if ($error) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $action = 'edit_extras';
+ } else {
+ setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
+ $action = 'view';
+ }
}
if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') && $user->rights->ticket->write) {