diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index ec9f2b6ff58dbd678978c13953f827eaee2e4fb3..c59d565e69042b14c950094c9f2d1b5be95f16d0 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -22,9 +22,8 @@ * \ingroup Advanced accountancy * \brief List accounting account */ -require '../../main.inc.php'; -// Class +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; @@ -35,6 +34,7 @@ $langs->load("accountancy"); $mesg = ''; $action = GETPOST('action'); +$cancel = GETPOST('cancel'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); $search_account = GETPOST("search_account"); @@ -80,34 +80,39 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (empty($reshook)) { - $search_account = ""; - $search_label = ""; - $search_accountparent = ""; - $search_pcgtype = ""; - $search_pcgsubtype = ""; -} - -if ($action == 'disable') { - if ($accounting->fetch($id)) { - $result = $accounting->account_desactivate($id); - } - - $action = 'update'; - if ($result < 0) { - setEventMessages($accounting->error, $accounting->errors, 'errors'); - } -} else if ($action == 'enable') { - if ($accounting->fetch($id)) { - $result = $accounting->account_activate($id); - } - $action = 'update'; - if ($result < 0) { - setEventMessages($accounting->error, $accounting->errors, 'errors'); - } + if (! empty($cancel)) $action = ''; + + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + { + $search_account = ""; + $search_label = ""; + $search_accountparent = ""; + $search_pcgtype = ""; + $search_pcgsubtype = ""; + } + + if ($action == 'disable') { + if ($accounting->fetch($id)) { + $result = $accounting->account_desactivate($id); + } + + $action = 'update'; + if ($result < 0) { + setEventMessages($accounting->error, $accounting->errors, 'errors'); + } + } else if ($action == 'enable') { + if ($accounting->fetch($id)) { + $result = $accounting->account_activate($id); + } + $action = 'update'; + if ($result < 0) { + setEventMessages($accounting->error, $accounting->errors, 'errors'); + } + } } diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 934e5f1f0814694592e69754437e95aa1ea8914f..ec41611a4cd831f65c55356ebab1e5234ab29432 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -22,9 +22,8 @@ * \ingroup Advanced accountancy * \brief Card of accounting account */ -require '../../main.inc.php'; -// Class +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; @@ -47,7 +46,11 @@ $cancel = GETPOST('cancel'); $object = new AccountingAccount($db); -// Action + +/* + * Action + */ + if ($action == 'add' && $user->rights->accounting->chartofaccount) { if (! $cancel) { @@ -85,18 +88,28 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $object->active = 1; $res = $object->create($user); - if ($res == - 3) { $error = 1; $action = "create"; + setEventMessages($object->error, $object->errors, 'errors'); } - if ($res == - 4) { + elseif ($res == - 4) { $error = 2; $action = "create"; + setEventMessages($object->error, $object->errors, 'errors'); + } + elseif ($res < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = "create"; + } + if (! $error) + { + header("Location: account.php"); + exit; } } - header("Location: account.php"); - exit; } else if ($action == 'edit' && $user->rights->accounting->chartofaccount) { if (! $cancel) { $result = $object->fetch($id); diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 00a16a227e37f9173d5422bee231357ab0e0ed8e..b63d7ce2fda056b18a3c25992b74f1bff758d5bd 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -172,16 +172,15 @@ class AccountingAccount extends CommonObject $sql .= " '" . $this->db->idate($now) . "'"; $sql .= ", " . $conf->entity; - $sql .= ", " . (! isset($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'"); - $sql .= ", " . (! isset($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'"); - $sql .= ", " . (! isset($this->pcg_subtype) ? 'NULL' : "'" . $this->pcg_subtype . "'"); - $sql .= ", " . (! isset($this->account_number) ? 'NULL' : "'" . $this->account_number . "'"); - $sql .= ", " . (! isset($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'"); - $sql .= ", " . (! isset($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'"); - $sql .= ", " . (! isset($this->account_category) ? 'NULL' : "'" . $this->db->escape($this->account_category) . "'"); + $sql .= ", " . (empty($this->fk_pcg_version) ? 'NULL' : "'" . $this->db->escape($this->fk_pcg_version) . "'"); + $sql .= ", " . (empty($this->pcg_type) ? 'NULL' : "'" . $this->db->escape($this->pcg_type) . "'"); + $sql .= ", " . (empty($this->pcg_subtype) ? 'NULL' : "'" . $this->pcg_subtype . "'"); + $sql .= ", " . (empty($this->account_number) ? 'NULL' : "'" . $this->account_number . "'"); + $sql .= ", " . (empty($this->account_parent) ? 'NULL' : "'" . $this->db->escape($this->account_parent) . "'"); + $sql .= ", " . (empty($this->label) ? 'NULL' : "'" . $this->db->escape($this->label) . "'"); + $sql .= ", " . (empty($this->account_category) ? 'NULL' : "'" . $this->db->escape($this->account_category) . "'"); $sql .= ", " . $user->id; - $sql .= ", " . (! isset($this->active) ? 'NULL' : "'" . $this->db->escape($this->active) . "'"); - + $sql .= ", " . (! isset($this->active) ? 'NULL' : $this->db->escape($this->active)); $sql .= ")"; $this->db->begin(); diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 83e30a05413a106643ac8790a9f063a45abaded4..39a45ad783b8d4648221a3a748e45e9337f7f40a 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -396,6 +396,11 @@ class SMTPs $host=$this->getHost(); $host=preg_replace('@tcp://@i','',$host); // Remove prefix $host=preg_replace('@ssl://@i','',$host); // Remove prefix + if (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS)) + { + $host=preg_replace('@tls://@i','',$host); // Remove prefix + $host='tls://'.$host; + } if ( $_retVal = $this->socket_send_str('EHLO ' . $host, '250') ) { if (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS)) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index ab9877d38b1b08deb7afd78efea14aa9964df6dd..a37389623b44524285e9371b42443a70ae8b323d 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -16,8 +16,8 @@ BackToChartofaccounts=Return chart of accounts AccountancyArea=Accountancy area AccountancyAreaDescIntro=Usage of the accountancy module is done in several step: -AccountancyAreaDescActionOnce=The following action are usually executed one time only, or once per year... -AccountancyAreaDescActionFreq=The following action are usually executed every month, week or day for very large companies... +AccountancyAreaDescActionOnce=The following actions are usually executed one time only, or once per year... +AccountancyAreaDescActionFreq=The following actions are usually executed every month, week or day for very large companies... AccountancyAreaDescChart=STEP %s: Create or check your chart of account from menu %s AccountancyAreaDescProd=STEP %s: Check the binding between products/services and accounting account is done. Complete missing bindings. This will save you time in future for the next steps by suggesting you the correct default accounting account on your invoice lines.<br>For this you can use the menu entry %s. AccountancyAreaDescBank=STEP %s: Check the binding between bank accounts and accounting account is done. Complete missing bindings. This will save you time in future for the next steps by suggesting you the correct default accounting account on your payment lines.<br>For this, go on the card of each financial account. You can start from page %s.