diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 0cfc0d24826..b244d8be123 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -154,7 +154,7 @@ class AccountingAccount extends CommonObject * @param int $rowid Id * @param string $account_number Account number * @param int|boolean $limittocurrentchart 1 or true=Load record only if it is into current active char of account - * @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC'. + * @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code). * @return int <0 if KO, 0 if not found, Id of record if OK and found */ public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index ae076a414cb..4312a3a1fe1 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -406,6 +406,8 @@ if ($result) { $isSellerInEEC = isInEEC($mysoc); + $accountingaccount_codetotid_cache = array(); + while ($i < min($num_lines, $limit)) { $objp = $db->fetch_object($result); @@ -474,8 +476,8 @@ if ($result) { } } - if (! empty($objp->code_sell)) { - //$objp->code_sell_p = $objp->code_sell; // Code on product + if (! empty($objp->code_sell_p)) { + // Value was defined previously } else { $code_sell_p_notset = 'color:orange'; } @@ -547,11 +549,26 @@ if ($result) { print ''; // Suggested accounting account + // $objp->code_sell_l = default (it takes the country into consideration), $objp->code_sell_p is value for product (it takes the country into consideration too) print ''; $suggestedid = $objp->aarowid_suggest; + /*var_dump($suggestedid); + var_dump($objp->code_sell_p); + var_dump($objp->code_sell_l);*/ if (empty($suggestedid) && empty($objp->code_sell_p) && ! empty($objp->code_sell_l) && ! empty($conf->global->ACCOUNTANCY_AUTOFILL_ACCOUNT_WITH_GENERIC)) { - //$suggestedid = // id of $objp->code_sell_l + if (empty($accountingaccount_codetotid_cache[$objp->code_sell_l])) + { + $tmpaccount = new AccountingAccount($db); + $tmpaccount->fetch(0, $objp->code_sell_l, 1); + if ($tmpaccount->id > 0) { + $suggestedid = $tmpaccount->id; + } + $accountingaccount_codetotid_cache[$objp->code_sell_l] = $tmpaccount->id; + } + else { + $suggestedid = $accountingaccount_codetotid_cache[$objp->code_sell_l]; + } } print $formaccounting->select_account($suggestedid, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); print ''; diff --git a/htdocs/install/doctemplates/contracts/index.html b/htdocs/install/doctemplates/contracts/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/install/doctemplates/invoices/index.html b/htdocs/install/doctemplates/invoices/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/install/doctemplates/orders/index.html b/htdocs/install/doctemplates/orders/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/install/doctemplates/products/index.html b/htdocs/install/doctemplates/products/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/install/doctemplates/projects/index.html b/htdocs/install/doctemplates/projects/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/install/doctemplates/proposals/index.html b/htdocs/install/doctemplates/proposals/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/install/doctemplates/shipments/index.html b/htdocs/install/doctemplates/shipments/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/install/doctemplates/supplier_proposals/index.html b/htdocs/install/doctemplates/supplier_proposals/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/install/doctemplates/tasks/index.html b/htdocs/install/doctemplates/tasks/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/install/doctemplates/thirdparties/index.html b/htdocs/install/doctemplates/thirdparties/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/install/doctemplates/usergroups/index.html b/htdocs/install/doctemplates/usergroups/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/install/doctemplates/users/index.html b/htdocs/install/doctemplates/users/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index a25528f58fb..3883b483a28 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -219,6 +219,7 @@ if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if (!$user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")"; $sql.= ' AND s.entity IN ('.getEntity('societe').')'; +$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND (d.product_type = 0 OR d.product_type = 1)"; if(! empty($TSelectedProducts)) { diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index dbd0354cea3..f5604cbacdb 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -65,7 +65,7 @@ class Productlot extends CommonObject 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), - 'fk_user_author'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), + 'fk_user_creat'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511) );