diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php
index 39cf8aaea1d..7da6de23725 100644
--- a/htdocs/accountancy/admin/account.php
+++ b/htdocs/accountancy/admin/account.php
@@ -70,9 +70,12 @@ $arrayfields = array(
'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1),
'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1),
'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'),
- 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
+ 'aa.reconciliable'=>array('label'=>$langs->trans("Reconciliable"), 'checked'=>1),
+ 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
);
+if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['aa.reconciliable']);
+
$accounting = new AccountingAccount($db);
@@ -157,7 +160,8 @@ if (empty($reshook))
if ($action == 'disable') {
if ($accounting->fetch($id)) {
- $result = $accounting->account_desactivate($id);
+ $mode = GETPOST('mode', 'int');
+ $result = $accounting->account_desactivate($id, $mode);
}
$action = 'update';
@@ -166,7 +170,8 @@ if (empty($reshook))
}
} elseif ($action == 'enable') {
if ($accounting->fetch($id)) {
- $result = $accounting->account_activate($id);
+ $mode = GETPOST('mode', 'int');
+ $result = $accounting->account_activate($id, $mode);
}
$action = 'update';
if ($result < 0) {
@@ -192,7 +197,7 @@ if ($action == 'delete') {
$pcgver = $conf->global->CHARTOFACCOUNTS;
-$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.active, ";
+$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.reconciliable, aa.active, ";
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity;
@@ -352,6 +357,7 @@ if ($resql)
print '';
}
if (!empty($arrayfields['aa.pcg_type']['checked'])) print '
';
print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
- print_liste_field_titre("Opening Balance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
+ print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder);
diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php
index 21f7c1cb210..0178f87a32d 100644
--- a/htdocs/accountancy/class/accountingaccount.class.php
+++ b/htdocs/accountancy/class/accountingaccount.class.php
@@ -135,6 +135,11 @@ class AccountingAccount extends CommonObject
*/
public $active;
+ /**
+ * @var int reconciliable
+ */
+ public $reconciliable;
+
/**
* Constructor
*
@@ -162,7 +167,7 @@ class AccountingAccount extends CommonObject
global $conf;
if ($rowid || $account_number) {
- $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active";
+ $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconciliable";
$sql .= ", ca.label as category_label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid";
@@ -203,6 +208,7 @@ class AccountingAccount extends CommonObject
$this->fk_user_modif = $obj->fk_user_modif;
$this->active = $obj->active;
$this->status = $obj->active;
+ $this->reconciliable = $obj->reconciliable;
return $this->id;
} else {
@@ -261,6 +267,7 @@ class AccountingAccount extends CommonObject
$sql .= ", fk_accounting_category";
$sql .= ", fk_user_author";
$sql .= ", active";
+ $sql .= ", reconciliable";
$sql .= ") VALUES (";
$sql .= " '" . $this->db->idate($now) . "'";
$sql .= ", " . $conf->entity;
@@ -273,6 +280,7 @@ class AccountingAccount extends CommonObject
$sql .= ", " . (empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= ", " . $user->id;
$sql .= ", " . (int) $this->active;
+ $sql .= ", " . (int) $this->reconciliable;
$sql .= ")";
$this->db->begin();
@@ -340,6 +348,7 @@ class AccountingAccount extends CommonObject
$sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= " , fk_user_modif = " . $user->id;
$sql .= " , active = " . (int) $this->active;
+ $sql .= " , reconciliable = " . (int) $this->reconciliable;
$sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
@@ -565,21 +574,31 @@ class AccountingAccount extends CommonObject
* Account deactivated
*
* @param int $id Id
+ * @param int $mode 0=field active, 1=field active_customer_list, 2=field_active_supplier_list
* @return int <0 if KO, >0 if OK
*/
- public function account_desactivate($id)
+ public function account_desactivate($id, $mode = 0)
{
// phpcs:enable
$result = $this->checkUsage();
+ if ($mode == 0)
+ {
+ $fieldtouse = 'active';
+ }
+ elseif ($mode == 1)
+ {
+ $fieldtouse = 'reconciliable';
+ }
+
if ($result > 0) {
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
- $sql .= "SET active = '0'";
+ $sql .= "SET " . $fieldtouse . " = '0'";
$sql .= " WHERE rowid = " . $this->db->escape($id);
- dol_syslog(get_class($this) . "::desactivate sql=" . $sql, LOG_DEBUG);
+ dol_syslog(get_class($this) . "::account_desactivate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
@@ -600,18 +619,28 @@ class AccountingAccount extends CommonObject
* Account activated
*
* @param int $id Id
+ * @param int $mode 0=field active, 1=field reconciliable, 2=field active_customer_list, 3=field_active_supplier_list
* @return int <0 if KO, >0 if OK
*/
- public function account_activate($id)
+ public function account_activate($id, $mode = 0)
{
// phpcs:enable
$this->db->begin();
+ if ($mode == 0)
+ {
+ $fieldtouse = 'active';
+ }
+ elseif ($mode == 1)
+ {
+ $fieldtouse = 'reconciliable';
+ }
+
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
- $sql .= "SET active = '1'";
+ $sql .= "SET " . $fieldtouse . " = '1'";
$sql .= " WHERE rowid = " . $this->db->escape($id);
- dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG);
+ dol_syslog(get_class($this) . "::account_activate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$this->db->commit();
diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php
index 48df5ce374a..19a5adcca34 100644
--- a/htdocs/accountancy/customer/index.php
+++ b/htdocs/accountancy/customer/index.php
@@ -122,8 +122,8 @@ if ($action == 'validatehistory') {
// Customer Invoice lines (must be same request than into page list.php for manual binding)
$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
- $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
- $sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
+ $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,";
+ $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
@@ -154,14 +154,22 @@ if ($action == 'validatehistory') {
$isBuyerInEEC = isInEEC($objp);
- // Search suggested account for product/service
+ // Search suggested account for product/service (similar code exists in page list.php to make manual binding)
$suggestedaccountingaccountfor = '';
if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid;
$suggestedaccountingaccountfor = '';
} else {
- if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
+ if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT
+ $objp->code_sell_p = $objp->code_sell;
+ $objp->aarowid_suggest = $objp->aarowid;
+ $suggestedaccountingaccountfor = 'eecwithvat';
+ } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
+ $objp->code_sell_p = $objp->code_sell;
+ $objp->aarowid_suggest = 0; // There is a doubt, no automatic binding
+ $suggestedaccountingaccountfor = 'eecwithoutvatnumber';
+ } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_p = $objp->code_sell_intra;
$objp->aarowid_suggest = $objp->aarowid_intra;
$suggestedaccountingaccountfor = 'eec';
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index 162fa4df638..9e4f73d8f7a 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -206,8 +206,10 @@ if (empty($chartaccountcode))
// Customer Invoice lines
$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
-$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
-$sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
+$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,";
+$sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
+$sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,";
+$sql .= " p.tosell as status, p.tobuy as status_buy,";
$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
@@ -399,7 +401,7 @@ if ($result) {
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
- print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center ');
+ print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
$checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1);
@@ -423,6 +425,14 @@ if ($result) {
$product_static->id = $objp->product_id;
$product_static->type = $objp->type;
$product_static->label = $objp->product_label;
+ $product_static->status = $objp->status;
+ $product_static->status_buy = $objp->status_buy;
+ $product_static->accountancy_code_sell = $objp->code_sell;
+ $product_static->accountancy_code_sell_intra = $objp->code_sell_intra;
+ $product_static->accountancy_code_sell_export = $objp->code_sell_export;
+ $product_static->accountancy_code_buy = $objp->code_buy;
+ $product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
+ $product_static->accountancy_code_buy_export = $objp->code_buy_export;
$facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid;
@@ -433,15 +443,19 @@ if ($result) {
$isBuyerInEEC = isInEEC($objp);
+ // Search suggested default account for product/service
$suggestedaccountingaccountbydefaultfor = '';
if ($objp->type_l == 1) {
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = '';
} else {
- if ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale without VAT intra community number
+ if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
- $suggestedaccountingaccountbydefaultfor = '';
+ $suggestedaccountingaccountbydefaultfor = 'eecwithvat';
+ } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
+ $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber';
} elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eec';
@@ -455,9 +469,12 @@ if ($result) {
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = '';
} else {
- if ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale without VAT intra community number
+ if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
- $suggestedaccountingaccountbydefaultfor = '';
+ $suggestedaccountingaccountbydefaultfor = 'eecwithvat';
+ } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
+ $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber';
} elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eec';
@@ -469,17 +486,21 @@ if ($result) {
}
if ($objp->code_sell_l == -1) $objp->code_sell_l = '';
- // Search suggested account for product/service
+ // Search suggested account for product/service (similar code exists in page index.php to make automatic binding)
$suggestedaccountingaccountfor = '';
if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid;
$suggestedaccountingaccountfor = '';
} else {
- if ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale without VAT intra community number
+ if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT
$objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid;
- $suggestedaccountingaccountfor = '';
+ $suggestedaccountingaccountfor = 'eecwithvat';
+ } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
+ $objp->code_sell_p = $objp->code_sell;
+ $objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ?
+ $suggestedaccountingaccountfor = 'eecwithoutvatnumber';
} elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_p = $objp->code_sell_intra;
$objp->aarowid_suggest = $objp->aarowid_intra;
@@ -497,6 +518,7 @@ if ($result) {
$code_sell_p_notset = 'color:orange';
}
if (empty($objp->code_sell_l) && empty($objp->code_sell_p)) $code_sell_p_notset = 'color:red';
+ if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber' && empty($code_sell_p_notset)) $code_sell_p_notset = 'color:orange';
// $objp->code_sell_l is now default code of product/service
// $objp->code_sell_p is now code of product/service
@@ -513,9 +535,10 @@ if ($result) {
// Ref Product
print '';
- if ($product_static->id > 0)
+ if ($product_static->id > 0) {
print $product_static->getNomUrl(1);
- if ($objp->product_label) print ' '.$objp->product_label;
+ }
+ if ($objp->product_label) print ' '.$objp->product_label.'';
print ' | ';
print '';
@@ -545,7 +568,7 @@ if ($result) {
// Current account
print ' | ';
- $s = (($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
+ $s = ''.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport");
@@ -554,9 +577,11 @@ if ($result) {
if ($objp->product_id > 0)
{
print ' ';
- $s = (($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
+ $s = ''.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
+ elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT");
+ elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber");
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
$s .= (empty($objp->code_sell_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_sell_p));
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
@@ -592,6 +617,7 @@ if ($result) {
print ' | ';
//var_dump($objp->aarowid);var_dump($objp->aarowid_intra);var_dump($objp->aarowid_export);var_dump($objp->aarowid_suggest);
$ischecked = $objp->aarowid_suggest;
+ if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $ischecked = 0;
print '';
print ' | ';
diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php
index 4547767f69a..e03c717039f 100644
--- a/htdocs/accountancy/expensereport/list.php
+++ b/htdocs/accountancy/expensereport/list.php
@@ -313,8 +313,8 @@ if ($result) {
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right maxwidth50 ');
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
- print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', $sortfield, $sortorder, 'center ');
- print_liste_field_titre("IntoAccount", '', '', '', '', '', $sortfield, $sortorder, 'center ');
+ print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
+ print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', '');
$checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1);
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
@@ -366,12 +366,12 @@ if ($result) {
print '';
// Current account
- print '';
+ print ' | ';
print length_accountg(html_entity_decode($objp->code_buy));
print ' | ';
// Suggested accounting account
- print '';
+ print ' | ';
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print ' | ';
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index c462b1af9e2..b6c220c347a 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -210,8 +210,10 @@ if (empty($chartaccountcode))
// Supplier Invoice Lines
$sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
-$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
-$sql .= " p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,";
+$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,";
+$sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
+$sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,";
+$sql .= " p.tosell as status, p.tobuy as status_buy,";
$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
@@ -399,7 +401,7 @@ if ($result) {
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
- print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center ');
+ print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
$checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1);
@@ -422,6 +424,14 @@ if ($result) {
$product_static->id = $objp->product_id;
$product_static->type = $objp->type;
$product_static->label = $objp->product_label;
+ $product_static->status = $objp->status;
+ $product_static->status_buy = $objp->status_buy;
+ $product_static->accountancy_code_sell = $objp->code_sell;
+ $product_static->accountancy_code_sell_intra = $objp->code_sell_intra;
+ $product_static->accountancy_code_sell_export = $objp->code_sell_export;
+ $product_static->accountancy_code_buy = $objp->code_buy;
+ $product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
+ $product_static->accountancy_code_buy_export = $objp->code_buy_export;
$facturefourn_static->ref = $objp->ref;
$facturefourn_static->id = $objp->facid;
@@ -508,7 +518,7 @@ if ($result) {
print '';
if ($product_static->id > 0)
print $product_static->getNomUrl(1);
- if ($objp->product_label) print ' '.$objp->product_label;
+ if ($objp->product_label) print ' '.$objp->product_label.'';
print ' | ';
// Description
@@ -539,8 +549,8 @@ if ($result) {
print ''.$objp->tva_intra.' | ';
// Current account
- print '';
- $s = (($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
+ print ' | ';
+ $s = ''.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport");
@@ -549,7 +559,7 @@ if ($result) {
if ($objp->product_id > 0)
{
print ' ';
- $s = (($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
+ $s = ''.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index ac4e5b030c1..e8296b96beb 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -1912,8 +1912,8 @@ class Categorie extends CommonObject
/**
* Return label of contact status
*
- * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
- * @return string Label of contact status
+ * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
+ * @return string Label of contact status
*/
public function getLibStatut($mode)
{
@@ -1968,8 +1968,9 @@ class Categorie extends CommonObject
*/
public static function getFilterJoinQuery($type, $rowIdName)
{
- return " LEFT JOIN ".MAIN_DB_PREFIX."categorie_".$type." as cp"
- . " ON ".$rowIdName." = cp.fk_".$type;
+ if ($type == 'bank_account') $type = 'account';
+
+ return " LEFT JOIN ".MAIN_DB_PREFIX."categorie_".$type." as cp ON ".$rowIdName." = cp.fk_".$type;
}
/**
@@ -1982,6 +1983,8 @@ class Categorie extends CommonObject
*/
public static function getFilterSelectQuery($type, $rowIdName, $searchList)
{
+ if ($type == 'bank_account') $type = 'account';
+
if (empty($searchList) && !is_array($searchList))
{
return "";
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 7645fc608a9..f1ea3c0923d 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -751,7 +751,7 @@ if ($object->id > 0)
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
$sql .= " WHERE c.fk_soc = s.rowid ";
$sql .= " AND s.rowid = ".$object->id;
- $sql .= " AND c.entity = ".$conf->entity;
+ $sql .= " AND c.entity IN (".getEntity('commande').')';
$sql .= " ORDER BY c.date_commande DESC";
$resql = $db->query($sql);
@@ -905,7 +905,7 @@ if ($object->id > 0)
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
$sql .= " WHERE c.fk_soc = s.rowid ";
$sql .= " AND s.rowid = ".$object->id;
- $sql .= " AND c.entity = ".$conf->entity;
+ $sql .= " AND c.entity IN (".getEntity('contract').")";
$sql .= " ORDER BY c.datec DESC";
$resql = $db->query($sql);
@@ -975,7 +975,7 @@ if ($object->id > 0)
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND s.rowid = ".$object->id;
- $sql .= " AND f.entity = ".$conf->entity;
+ $sql .= " AND f.entity IN (".getEntity('intervention').")";
$sql .= " ORDER BY f.tms DESC";
$resql = $db->query($sql);
@@ -1044,7 +1044,7 @@ if ($object->id > 0)
$sql .= ', s.nom, s.rowid as socid';
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
$sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
- $sql .= " AND f.entity = ".$conf->entity;
+ $sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= ' GROUP BY f.rowid, f.titre, f.total, f.tva, f.total_ttc,';
$sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
$sql .= ' f.suspended, f.date_when,';
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 6df80898af7..ff3038e85d1 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -3342,8 +3342,8 @@ class Propal extends CommonObject
$statusType = '';
if ($status == self::STATUS_DRAFT) $statusType = 'status0';
elseif ($status == self::STATUS_VALIDATED) $statusType = 'status1';
- elseif ($status == self::STATUS_SIGNED) $statusType = 'status3';
- elseif ($status == self::STATUS_NOTSIGNED) $statusType = 'status5';
+ elseif ($status == self::STATUS_SIGNED) $statusType = 'status4';
+ elseif ($status == self::STATUS_NOTSIGNED) $statusType = 'status9';
elseif ($status == self::STATUS_BILLED) $statusType = 'status6';
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php
index 11a9fa8eff6..66f4aa94fd2 100644
--- a/htdocs/comm/propal/index.php
+++ b/htdocs/comm/propal/index.php
@@ -82,7 +82,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles
* Statistics
*/
-$sql = "SELECT count(p.rowid), p.fk_statut";
+$sql = "SELECT count(p.rowid) as nb, p.fk_statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -101,24 +101,26 @@ if ($resql)
$total = 0;
$totalinprocess = 0;
$dataseries = array();
+ $colorseries = array();
$vals = array();
+
// -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not)
while ($i < $num)
{
- $row = $db->fetch_row($resql);
- if ($row)
+ $obj = $db->fetch_object($resql);
+ if ($obj)
{
- //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
- {
- $vals[$row[1]] = $row[0];
- $totalinprocess += $row[0];
- }
- $total += $row[0];
+ $vals[$obj->status] = $obj->nb;
+ $totalinprocess += $obj->nb;
+
+ $total += $obj->nb;
}
$i++;
}
$db->free($resql);
+ include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
+
print '';
print ' ';
print '| '.$langs->trans("Statistics").' - '.$langs->trans("Proposals").' | '."\n";
@@ -126,7 +128,13 @@ if ($resql)
foreach ($listofstatus as $status)
{
$dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
- if (!$conf->use_javascript_ajax)
+ if ($status == Propal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
+ if ($status == Propal::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
+ if ($status == Propal::STATUS_SIGNED) $colorseries[$status] = $badgeStatus4;
+ if ($status == Propal::STATUS_NOTSIGNED) $colorseries[$status] = $badgeStatus9;
+ if ($status == Propal::STATUS_BILLED) $colorseries[$status] = $badgeStatus6;
+
+ if (empty($conf->use_javascript_ajax))
{
print '';
print '| '.$propalstatic->LibStatut($status, 0).' | ';
@@ -141,6 +149,7 @@ if ($resql)
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
+ $dolgraph->SetDataColor(array_values($colorseries));
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php
index 23de377cf24..57d81c625fe 100644
--- a/htdocs/compta/cashcontrol/cashcontrol_card.php
+++ b/htdocs/compta/cashcontrol/cashcontrol_card.php
@@ -77,6 +77,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('cashcontrolcard', 'globalcard'));
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
+
/*
* Actions
@@ -96,7 +99,22 @@ if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && empty($conf->global->C
if (GETPOST('cancel', 'alpha'))
{
- $action = 'create';
+ if ($action == 'valid') {
+ $action = 'view';
+ }
+ else {
+ $action = 'create';
+ }
+}
+
+if ($action == "reopen")
+{
+ $result = $object->setStatut($object::STATUS_DRAFT, null, '', 'CASHFENCE_REOPEN');
+ if ($result < 0) {
+ dol_print_error($db, $object->error, $object->error);
+ }
+
+ $action = 'view';
}
if ($action == "start")
@@ -162,18 +180,35 @@ elseif ($action == "add")
}
}
-if ($action == "close")
+if ($action == "valid") // validate = close
{
$object->fetch($id);
- $result = $object->valid($user);
+ $db->begin();
+
+ /*
+ $object->day_close = GETPOST('closeday', 'int');
+ $object->month_close = GETPOST('closemonth', 'int');
+ $object->year_close = GETPOST('closeyear', 'int');
+ */
+
+ $object->cash = price2num(GETPOST('cash_amount', 'alpha'));
+ $object->card = price2num(GETPOST('card_amount', 'alpha'));
+ $object->cheque = price2num(GETPOST('cheque_amount', 'alpha'));
+
+ $result = $object->update($user);
+
+ $result = $object->valid($user);
+
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
+ $db->rollback();
}
else
{
setEventMessages($langs->trans("CashFenceDone"), null);
+ $db->commit();
}
$action = "view";
@@ -213,15 +248,22 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete))
$form = new Form($db);
-if ($action == "create" || $action == "start")
+$initialbalanceforterminal = array();
+$theoricalamountforterminal = array();
+$theoricalnbofinvoiceforterminal = array();
+
+if ($action == "create" || $action == "start" || $action == 'close')
{
- llxHeader();
+ if ($action == 'close') {
+ $posmodule = $object->posmodule;
+ $terminalid = $object->posnumber;
+ $terminaltouse = $terminalid;
- $initialbalanceforterminal = array();
- $theoricalamountforterminal = array();
- $theoricalnbofinvoiceforterminal = array();
-
- if (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1')
+ $syear = $object->year_close;
+ $smonth = $object->month_close;
+ $sday = $object->day_close;
+ }
+ elseif (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1')
{
$posmodule = GETPOST('posmodule', 'alpha');
$terminalid = GETPOST('posnumber', 'alpha');
@@ -234,7 +276,10 @@ if ($action == "create" || $action == "start")
setEventMessages($langs->trans("OnlyTerminal1IsAvailableForCashDeskModule"), null, 'errors');
$error++;
}
+ }
+ if ($terminalid != '')
+ {
// Calculate $initialbalanceforterminal for terminal 0
foreach ($arrayofpaymentmode as $key => $val)
{
@@ -246,9 +291,7 @@ if ($action == "create" || $action == "start")
// Get the bank account dedicated to this point of sale module/terminal
$vartouse = 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse;
- $bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal)
- // Hook to get the good bank id according to posmodule and posnumber.
- // @todo add hook here
+ $bankid = $conf->global->$vartouse;
if ($bankid > 0)
{
@@ -274,11 +317,9 @@ if ($action == "create" || $action == "start")
}
}
- // Calculate $theoricalamountforterminal for terminal 0
+ // Calculate $theoricalamountforterminal
foreach ($arrayofpaymentmode as $key => $val)
{
- /*$sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank";
- $sql.= " WHERE fk_account = ".$bankid;*/
$sql = "SELECT SUM(pf.amount) as total, COUNT(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp";
$sql .= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement";
@@ -315,197 +356,230 @@ if ($action == "create" || $action == "start")
}
}
- print load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'cash-register');
+ //var_dump($theoricalamountforterminal); var_dump($theoricalnbofinvoiceforterminal);
+ if ($action != 'close') {
+ llxHeader();
- print ' |