diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 86603642362..eb915999e7e 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -164,10 +164,14 @@ class Skeleton_Class extends CommonObject $sql .= ' t.field2'; //... $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; + $sql.= ' WHERE 1 = 1'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("skeleton", 1) . ")"; + } if (null !== $ref) { - $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\''; + $sql .= ' AND t.ref = ' . '\'' . $ref . '\''; } else { - $sql .= ' WHERE t.rowid = ' . $id; + $sql .= ' AND t.rowid = ' . $id; } $resql = $this->db->query($sql); @@ -236,16 +240,20 @@ class Skeleton_Class extends CommonObject $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; } } - if (count($sqlwhere) > 0) { - $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); + $sql.= ' WHERE 1 = 1'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("skeleton", 1) . ")"; + } + if (count($sqlwhere) > 0) { + $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); } - if (!empty($sortfield)) { $sql .= $this->db->order($sortfield,$sortorder); } if (!empty($limit)) { $sql .= ' ' . $this->db->plimit($limit + 1, $offset); } + $this->lines = array(); $resql = $this->db->query($sql); @@ -491,7 +499,7 @@ class Skeleton_Class extends CommonObject * Return the status * * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto * @return string Label of status */ static function LibStatut($status,$mode=0) @@ -529,6 +537,11 @@ class Skeleton_Class extends CommonObject if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); } + if ($mode == 6) + { + if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); + if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + } } diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index e1a0e3fe052..12d9a707cbd 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -79,9 +79,11 @@ if ($action == 'delete') { } } + /* * View */ + llxheader('', $langs->trans('AccountAccounting')); $formaccounting = new FormAccounting($db); @@ -126,6 +128,7 @@ dol_fiche_end(); print ''; + if ($action == 'display' || $action == 'delete') { print ''; diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 51b530cbc12..a66217ebbee 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -126,9 +126,7 @@ print ''; print ''; print ''; -/* - * Define Chart of accounts - */ +// Define Chart of accounts print '
'; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 7d640968eb1..598320bfd63 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -49,7 +49,7 @@ if (! $user->rights->accounting->bind->write) accessforbidden(); // search & action GETPOST -$action = GETPOST('action'); +$action = GETPOST('action', 'alpha'); $codeventil_buy = GETPOST('codeventil_buy', 'array'); $codeventil_sell = GETPOST('codeventil_sell', 'array'); $chk_prod = GETPOST('chk_prod', 'array'); @@ -65,28 +65,34 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); $btn_changeaccount = GETPOST('changeaccount'); $btn_changetype = GETPOST('changetype'); -$sortfield = GETPOST('sortfield', 'alpha'); -$sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); -if ($page < 0) - $page = 0; +$limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -// bug in page limit if ACCOUNTING_LIMIT_LIST_VENTILATION < $conf->liste_limit there is no pagination displayed ! -if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) && $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION >= $conf->liste_limit) { - $limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION; -} else { - $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit; -} -$offset = $limit * $page; +if (! $sortfield) $sortfield="p.ref"; +if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) { - $sortfield = "p.ref"; +if (empty($action)) $action='list'; + +$arrayfields=array(); + + +/* + * Actions + */ + +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +{ + $search_ref = ''; + $search_label = ''; + $search_desc = ''; } -if (! $sortorder) { - $sortorder = "ASC"; -} - + // Sales or Purchase mode ? if ($action == 'update') { if (! empty($btn_changetype)) { @@ -158,6 +164,12 @@ if ($action == 'update') { } } + + +/* + * View + */ + $form = new FormVentilation($db); // Defaut AccountingAccount RowId Product / Service @@ -175,44 +187,13 @@ $aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $c $aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_prodsell = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); -// Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers -{ - $search_ref = ''; - $search_label = ''; - $search_desc = ''; -} - - -/* - * View - */ - llxHeader('', $langs->trans("ProductsBinding")); -print ''; +$pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT p.rowid, p.ref, p.label, p.description , p.accountancy_code_sell, p.accountancy_code_buy, p.tms, p.fk_product_type as product_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; $sql .= " WHERE ("; - -$pcgver = $conf->global->CHARTOFACCOUNTS; - if ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { $sql .= " p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL"; $sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN @@ -222,39 +203,58 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') { $sql .= " OR (p.accountancy_code_sell IS NOT NULL AND p.accountancy_code_sell != '' AND p.accountancy_code_sell NOT IN (SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))"; } - $sql .= ")"; - +if (! empty($conf->multicompany->enabled)) { + $sql.= ' AND p.entity IN ('.getEntity('product', 1).')'; +} // Add search filter like if (strlen(trim($search_ref))) { - $sql .= " AND (p.ref like '" . $search_ref . "%')"; + $sql .= natural_search("p.ref",$search_ref); } if (strlen(trim($search_label))) { - $sql .= " AND (p.label like '" . $search_label . "%')"; + $sql .= natural_search("p.label",$search_label); } if (strlen(trim($search_desc))) { - $sql .= " AND (p.description like '%" . $search_desc . "%')"; + $sql .= natural_search("p.description",$search_desc); } $sql .= $db->order($sortfield, $sortorder); - +$nbtotalofrecords = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); -if ($result) { - $num_lines = $db->num_rows($result); +if ($result) +{ + $num = $db->num_rows($result); $i = 0; - print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy'); + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($search_ref > 0) $param.="&search_desc=".urlencode($search_ref); + if ($search_label > 0) $param.="&search_desc=".urlencode($search_label); + if ($search_desc > 0) $param.="&search_desc=".urlencode($search_desc); + + print ''; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy'); print '
'; print $langs->trans("InitAccountancyDesc") . '
'; print '
'; - print ''; - print ''; - print ''; - + // Select mode print '
'; print ''; print ''; @@ -270,11 +270,17 @@ if ($result) { print '
'; print "
\n"; + + // Filter on categories + $moreforfilter=''; + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print_barre_liste($langs->trans("ListOfProductsWithoutAccountingAccount"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines, '', ''); + $texte=$langs->trans("ListOfProductsWithoutAccountingAccount"); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); - print '
' . $langs->trans('Options') . '' . $langs->trans('Description') . '
'; + print '
'; print ''; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); @@ -292,12 +298,11 @@ if ($result) { print ''; print ''; - print ''; - print ''; - print ''; - + print ''; + print ''; + print ''; print ''; - print ''; @@ -305,7 +310,8 @@ if ($result) { $var = true; - while ( $i < min($num_lines, 250) ) { + while ($i < min($num,$limit)) + { $obj = $db->fetch_object($result); $var = ! $var; @@ -374,14 +380,15 @@ if ($result) { } // Checkbox select - print ''; - print ""; $i ++; } print '
 '; + print ''; $searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1); print $searchpitco; print ''; + print ''; print '
'; - print '
'; + + print '
'; + print ''; $db->free($result); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index ed4881ddff2..a6f487c1211 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -110,7 +110,7 @@ class BookKeeping extends CommonObject * @return int <0 if KO, Id of created object if OK */ public function create(User $user, $notrigger = false) { - global $langs; + global $conf, $langs; dol_syslog(__METHOD__, LOG_DEBUG); @@ -184,6 +184,9 @@ class BookKeeping extends CommonObject $sql .= " WHERE doc_type = '" . $this->doc_type . "'"; $sql .= " AND fk_docdet = " . $this->fk_docdet; $sql .= " AND numero_compte = '" . $this->numero_compte . "'"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + } $resql = $this->db->query($sql); @@ -197,6 +200,9 @@ class BookKeeping extends CommonObject $sqlnum .= " WHERE doc_type = '" . $this->doc_type . "'"; $sqlnum .= " AND fk_docdet = '" . $this->fk_docdet . "'"; $sqlnum .= " AND doc_ref = '" . $this->doc_ref . "'"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + } dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); @@ -208,7 +214,10 @@ class BookKeeping extends CommonObject if (empty($this->piece_num)) { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum .= " FROM " . MAIN_DB_PREFIX . $this->table_element; - + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + } + dol_syslog(get_class($this) . ":: create sqlnum=" . $sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { @@ -470,11 +479,12 @@ class BookKeeping extends CommonObject * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = null) { - dol_syslog(__METHOD__, LOG_DEBUG); + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); $sql = 'SELECT'; $sql .= ' t.rowid,'; - $sql .= " t.doc_date,"; $sql .= " t.doc_type,"; $sql .= " t.doc_ref,"; @@ -491,7 +501,6 @@ class BookKeeping extends CommonObject $sql .= " t.import_key,"; $sql .= " t.code_journal,"; $sql .= " t.piece_num"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' WHERE 1 = 1'; if (! empty($conf->multicompany->enabled)) { @@ -556,11 +565,12 @@ class BookKeeping extends CommonObject * @return int <0 if KO, >0 if OK */ public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { - dol_syslog(__METHOD__, LOG_DEBUG); + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); $sql = 'SELECT'; $sql .= ' t.rowid,'; - $sql .= " t.doc_date,"; $sql .= " t.doc_type,"; $sql .= " t.doc_ref,"; @@ -577,9 +587,6 @@ class BookKeeping extends CommonObject $sql .= " t.import_key,"; $sql .= " t.code_journal,"; $sql .= " t.piece_num"; - - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; - // Manage filter $sqlwhere = array (); if (count($filter) > 0) { @@ -601,7 +608,6 @@ class BookKeeping extends CommonObject } } } - $sql.= ' WHERE 1 = 1'; if (! empty($conf->multicompany->enabled)) { $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; @@ -672,11 +678,12 @@ class BookKeeping extends CommonObject * @return int <0 if KO, >0 if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { - dol_syslog(__METHOD__, LOG_DEBUG); + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); $sql = 'SELECT'; $sql .= ' t.rowid,'; - $sql .= " t.doc_date,"; $sql .= " t.doc_type,"; $sql .= " t.doc_ref,"; @@ -693,9 +700,7 @@ class BookKeeping extends CommonObject $sql .= " t.import_key,"; $sql .= " t.code_journal,"; $sql .= " t.piece_num"; - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; - // Manage filter $sqlwhere = array (); if (count($filter) > 0) { @@ -715,7 +720,6 @@ class BookKeeping extends CommonObject } } } - $sql.= ' WHERE 1 = 1'; if (! empty($conf->multicompany->enabled)) { $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; @@ -784,16 +788,15 @@ class BookKeeping extends CommonObject * @return int <0 if KO, >0 if OK */ public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { - dol_syslog(__METHOD__, LOG_DEBUG); + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); $sql = 'SELECT'; $sql .= " t.numero_compte,"; $sql .= " SUM(t.debit) as debit,"; $sql .= " SUM(t.credit) as credit"; - - $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; - // Manage filter $sqlwhere = array (); if (count($filter) > 0) { @@ -813,11 +816,14 @@ class BookKeeping extends CommonObject } } } - - if (count($sqlwhere) > 0) { - $sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere); + $sql.= ' WHERE 1 = 1'; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; } - + if (count($sqlwhere) > 0) { + $sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere); + } + $sql .= ' GROUP BY t.numero_compte'; if (! empty($sortfield)) { @@ -917,7 +923,6 @@ class BookKeeping extends CommonObject // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - $sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ','; $sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ','; $sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ','; @@ -934,7 +939,6 @@ class BookKeeping extends CommonObject $sql .= ' import_key = ' . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ','; $sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ','; $sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null"); - $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); @@ -1049,11 +1053,13 @@ class BookKeeping extends CommonObject /** * Delete bookkepping by year * - * @param string $delyear Year to delete - * @param string $journal Journal to delete - * @return int Result + * @param string $delyear Year to delete + * @param string $journal Journal to delete + * @return int <0 if KO, >0 if OK */ function deleteByYearAndJournal($delyear='', $journal='') { + global $conf; + if (empty($delyear) && empty($journal)) { return -1; @@ -1067,6 +1073,9 @@ class BookKeeping extends CommonObject $sql.= " WHERE 1 = 1"; if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + } $resql = $this->db->query($sql); if (! $resql) { @@ -1090,12 +1099,17 @@ class BookKeeping extends CommonObject * @return int Result */ function deleteMvtNum($piecenum) { + global $conf; + $this->db->begin(); // first check if line not yet in bookkeeping $sql = "DELETE"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + } $resql = $this->db->query($sql); @@ -1193,9 +1207,14 @@ class BookKeeping extends CommonObject * @return int <0 if KO, >0 if OK */ public function fetchPerMvt($piecenum) { - $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; + global $conf; + + $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + } dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); @@ -1223,8 +1242,13 @@ class BookKeeping extends CommonObject */ public function getNextNumMvt() { + global $conf; + $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element; - + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + } + dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); @@ -1247,12 +1271,17 @@ class BookKeeping extends CommonObject * @return int <0 if KO, >0 if OK */ function fetch_all_per_mvt($piecenum) { + global $conf; + $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND entity IN (" . getEntity("accountancy", 1) . ")"; + } dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); $result = $this->db->query($sql); @@ -1297,11 +1326,16 @@ class BookKeeping extends CommonObject * @return int Result */ function export_bookkeping($model = 'ebp') { + global $conf; + $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE entity IN (" . getEntity("accountancy", 1) . ")"; + } dol_syslog(get_class($this) . "::export_bookkeping", LOG_DEBUG); @@ -1345,75 +1379,76 @@ class BookKeeping extends CommonObject - /** - * Return list of accounts with label by chart of accounts - * - * @param string $selectid Preselected chart of accounts - * @param string $htmlname Name of field in html form - * @param int $showempty Add an empty field - * @param array $event Event options - * @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1) - * @param int $select_out set value returned by select 0=rowid (default), 1=account_number - * @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number - * - * @return string String with HTML select - */ - function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { - global $conf; - - require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; - - $pcgver = $conf->global->CHARTOFACCOUNTS; - - $sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte"; - $sql .= " AND aa.active = 1"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = " . $pcgver; - $sql .= " ORDER BY account_number ASC"; - - dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); - $resql = $this->db->query($sql); - - if (!$resql) { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); - return -1; - } - - $out = ajax_combobox($htmlname, $event); - - $options = array(); - $selected = null; - - while ($obj = $this->db->fetch_object($resql)) { - $label = length_accountg($obj->account_number) . ' - ' . $obj->label; - $label = dol_trunc($label, $trunclength); - - $select_value_in = $obj->rowid; - $select_value_out = $obj->rowid; - - if ($select_in == 1) { - $select_value_in = $obj->account_number; - } - if ($select_out == 1) { - $select_value_out = $obj->account_number; - } - - // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number - // Because same account_number can be share between different accounting_system and do have the same meaning - if (($selectid != '') && $selectid == $select_value_in) { - $selected = $select_value_out; - } - - $options[$select_value_out] = $label; - } - - $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); - $this->db->free($resql); - return $out; - } + /** + * Return list of accounts with label by chart of accounts + * + * @param string $selectid Preselected chart of accounts + * @param string $htmlname Name of field in html form + * @param int $showempty Add an empty field + * @param array $event Event options + * @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1) + * @param int $select_out Set value returned by select 0=rowid (default), 1=account_number + * @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number + * @return string String with HTML select + */ + function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { + global $conf; + + require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; + + $pcgver = $conf->global->CHARTOFACCOUNTS; + + $sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version"; + $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte"; + $sql .= " AND aa.active = 1"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; + $sql .= " AND asy.rowid = " . $pcgver; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND ab.entity IN (" . getEntity("accountancy", 1) . ")"; + } + $sql .= " ORDER BY account_number ASC"; + + dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); + $resql = $this->db->query($sql); + + if (! $resql) { + $this->error = "Error " . $this->db->lasterror(); + dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); + return - 1; + } + + $out = ajax_combobox($htmlname, $event); + + $options = array(); + $selected = null; + + while ($obj = $this->db->fetch_object($resql)) { + $label = length_accountg($obj->account_number) . ' - ' . $obj->label; + + $select_value_in = $obj->rowid; + $select_value_out = $obj->rowid; + + if ($select_in == 1) { + $select_value_in = $obj->account_number; + } + if ($select_out == 1) { + $select_value_out = $obj->account_number; + } + + // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number + // Because same account_number can be share between different accounting_system and do have the same meaning + if (($selectid != '') && $selectid == $select_value_in) { + $selected = $select_value_out; + } + + $options[$select_value_out] = $label; + } + + $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300'); + $this->db->free($resql); + return $out; + } @@ -1421,25 +1456,26 @@ class BookKeeping extends CommonObject * Description of a root accounting account * * @param string $account Accounting account - * @return string + * @return string Root account */ function get_compte_racine($account = null) { global $conf; $pcgver = $conf->global->CHARTOFACCOUNTS; - - - $sql = "SELECT root.account_number, root.label as 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 = " . $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 .= " WHERE aa.account_number = '" . $account . "'"; - $sql .= " AND parent.active = 1"; - $sql .= " AND root.active = 1"; - - + + $sql = "SELECT root.account_number, root.label as 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 = " . $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 .= " WHERE aa.account_number = '" . $account . "'"; + $sql .= " AND parent.active = 1"; + $sql .= " AND root.active = 1"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " AND aa.entity IN (" . getEntity("accountancy", 1) . ")"; + } + dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1463,11 +1499,12 @@ class BookKeeping extends CommonObject * Description of accounting account * * @param string $account Accounting account - * @return string + * @return string Account desc */ function get_compte_desc($account = null) { global $conf; + $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa "; @@ -1476,6 +1513,10 @@ class BookKeeping extends CommonObject $sql .= " AND asy.rowid = " . $pcgver; $sql .= " AND aa.active = 1"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid"; + if (! empty($conf->multicompany->enabled)) { + $sql .= " WHERE aa.entity IN (" . getEntity("accountancy", 1) . ")"; + } + dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -1499,6 +1540,7 @@ class BookKeeping extends CommonObject } + /** * Class BookKeepingLine */ diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index d215cf1826e..f605f504539 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -80,23 +80,21 @@ print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, print "
\n"; print "
\n"; $step++; -//$textlink=''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Modules")."-".$langs->transnoentitiesnoconv("Accountancy").''; -$textlink=''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuBankCash").''; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); -print "
\n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'')."
\n"; print "
\n"; $step++; $textlink = ''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("Dictionaries")."-".$langs->transnoentitiesnoconv("DictionaryVAT").''; -//$textlink.= ' '.$langs->trans("and").' '; -//$textlink.= ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("MenuDefaultAccounts").''; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink); print "
\n"; print "
\n"; +$step++; +$textlink=''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuBankCash").''; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); +print "
\n"; +print "
\n"; if (! empty($conf->tax->enabled)) { $textlink = ''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("Dictionaries")."-".$langs->transnoentitiesnoconv("DictionarySocialContributions").''; - //$textlink.= ' '.$langs->trans("and").' '; - //$textlink.= ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''; $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); print "
\n"; @@ -118,9 +116,6 @@ if (! empty($conf->don->enabled)) print "
\n"; }*/ -$step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'')."
\n"; -print "
\n"; $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("ProductsBinding").'')."
\n"; print "
\n"; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 90f9222854d..77ef3bf4122 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -55,7 +55,9 @@ $confirm=GETPOST('confirm','alpha'); $id=GETPOST('id','int'); $rowid=GETPOST('rowid','alpha'); -if (!$user->admin) accessforbidden(); +$allowed=$user->admin; +if ($id == 10 && ! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Vat page allowed to manager of chart account +if (! $allowed) accessforbidden(); $acts[0] = "activate"; $acts[1] = "disable"; @@ -76,7 +78,6 @@ $pagenext = $page + 1; $search_country_id = GETPOST('search_country_id','int'); - // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('admin')); @@ -673,8 +674,8 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) } // Clean some parameters - if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 - if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 + if (! empty($_POST["localtax1_type"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 + if (! empty($_POST["localtax2_type"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null @@ -720,7 +721,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $_POST[$listfieldvalue[$i]] = $conf->entity; } if ($i) $sql.=","; - if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; + if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $i++; } @@ -769,7 +770,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) } if ($i) $sql.=","; $sql.= $field."="; - if ($_POST[$listfieldvalue[$i]] == '') $sql.="null"; + if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; $i++; } @@ -992,12 +993,12 @@ if ($id) if ($fieldlist[$field]=='taux') { if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); else $valuetoshow=$langs->trans("Amount"); - $align='right'; + $align='center'; } if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2";} + if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $align="center"; } if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3";} + if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $align="center"; } if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field]=='type') { @@ -1072,7 +1073,7 @@ if ($id) { foreach ($fieldlist as $key=>$val) { - if (GETPOST($val)) + if (GETPOST($val) != '') $obj->$val=GETPOST($val); } } @@ -1082,7 +1083,7 @@ if ($id) $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - if ($id == 3) unset($fieldlist[2]); + if ($id == 3) unset($fieldlist[2]); // Remove field ??? if ??? if (empty($reshook)) { @@ -1127,7 +1128,7 @@ if ($id) - // List of available values in database + // List of available recod in database dol_syslog("htdocs/admin/dict", LOG_DEBUG); $resql=$db->query($sql); if ($resql) @@ -1174,12 +1175,12 @@ if ($id) if ($fieldlist[$field]=='taux') { if ($tabname[$id] != MAIN_DB_PREFIX."c_revenuestamp") $valuetoshow=$langs->trans("Rate"); else $valuetoshow=$langs->trans("Amount"); - $align='right'; + $align='center'; } if ($fieldlist[$field]=='localtax1_type') { $valuetoshow=$langs->trans("UseLocalTax")." 2"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $sortable=0; } + if ($fieldlist[$field]=='localtax1') { $valuetoshow=$langs->trans("Rate")." 2"; $align="center"; $sortable=0; } if ($fieldlist[$field]=='localtax2_type') { $valuetoshow=$langs->trans("UseLocalTax")." 3"; $align="center"; $sortable=0; } - if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $sortable=0; } + if ($fieldlist[$field]=='localtax2') { $valuetoshow=$langs->trans("Rate")." 3"; $align="center"; $sortable=0; } if ($fieldlist[$field]=='organization') { $valuetoshow=$langs->trans("Organization"); } if ($fieldlist[$field]=='lang') { $valuetoshow=$langs->trans("Language"); } if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } @@ -1282,8 +1283,11 @@ if ($id) if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id],'edit'); - print ' '; - print ' '; + print ''; + print ''; + print '
'; + print ''; + print ''; } else { @@ -1430,24 +1434,26 @@ if ($id) $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$fieldlist[$field]}); } - + else if ($fieldlist[$field]=='localtax1' || $fieldlist[$field]=='localtax2') { + $align="center"; + } else if ($fieldlist[$field]=='localtax1_type') { - if ($obj->localtax1 != 0) + if ($obj->localtax1 != 0) $valuetoshow=$localtax_typeList[$valuetoshow]; else $valuetoshow = ''; - $align="right"; + $align="center"; } else if ($fieldlist[$field]=='localtax2_type') { if ($obj->localtax2 != 0) $valuetoshow=$localtax_typeList[$valuetoshow]; else $valuetoshow = ''; - $align="right"; + $align="center"; } else if ($fieldlist[$field]=='taux') { $valuetoshow = price($valuetoshow, 0, $langs, 0, 0); - $align="right"; + $align="center"; } else if (in_array($fieldlist[$field],array('recuperableonly'))) { @@ -1509,7 +1515,11 @@ if ($id) else print ' '; // Delete link - if ($iserasable) print ''.img_delete().''; + if ($iserasable) + { + if ($user->admin) print ''.img_delete().''; + //else print ''.img_delete().''; // Some dictionnary can be edited by other profile than admin + } else print ' '; print "\n"; @@ -1700,9 +1710,9 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') } elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) { $align="left"; - if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) $align="right"; // Fields aligned on right + if (in_array($fieldlist[$field],array('taux','localtax1','localtax2'))) $align="center"; // Fields aligned on right print ''; - print ''; + print ''; print ''; } elseif (in_array($fieldlist[$field], array('libelle_facture'))) { @@ -1770,10 +1780,10 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') $size=''; $class=''; if ($fieldlist[$field]=='code') $size='size="8" '; if ($fieldlist[$field]=='position') $size='size="4" '; - if ($fieldlist[$field]=='libelle') $size='centpercent'; + if ($fieldlist[$field]=='libelle') $class='centpercent'; if ($fieldlist[$field]=='tracking') $class='centpercent'; if ($fieldlist[$field]=='sortorder' || $fieldlist[$field]=='sens' || $fieldlist[$field]=='category_type') $size='size="2" '; - print ''; + print ''; print ''; } } diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 08fed83acc0..9a5a19a1e09 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -92,30 +92,35 @@ if ($negpage) if ($page > GETPOST("nbpage")) $page = GETPOST("nbpage"); } +$sortfield = "b.datev, b.datec, b.rowid"; + $object = new Account($db); -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers -{ - $paiementtype=""; - $req_nb=""; - $thirdparty=""; - $req_desc=""; - $req_debit=""; - $req_credit=""; - $req_stdtmonth=""; - $req_stdtday=""; - $req_stdtyear=""; - $req_stdt = ""; - $req_enddtmonth=""; - $req_enddtday=""; - $req_enddtyear=""; - $req_enddt = ""; - $search_reconciled = ''; -} + /* * Action */ + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +{ + $paiementtype=""; + $req_nb=""; + $thirdparty=""; + $req_desc=""; + $req_debit=""; + $req_credit=""; + $req_stdtmonth=""; + $req_stdtday=""; + $req_stdtyear=""; + $req_stdt = ""; + $req_enddtmonth=""; + $req_enddtday=""; + $req_enddtyear=""; + $req_enddt = ""; + $search_reconciled = ''; +} + $dateop=-1; if ($action == 'add' && $id && ! isset($_POST["cancel"]) && $user->rights->banque->modifier) @@ -340,23 +345,10 @@ if ($id > 0 || ! empty($ref)) $head=bank_prepare_head($object); dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); - - print ''; - $linkback = ''.$langs->trans("BackToList").''; - - // Ref - print ''; - print ''; - - // Label - print ''; - print ''; - - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref'); - print '
'.$langs->trans("Label").''.$object->label.'
'; - + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_fiche_end(); @@ -507,7 +499,7 @@ if ($id > 0 || ! empty($ref)) // Ligne de titre tableau des ecritures print ''; print ''.$langs->trans("Date").''; - print ''.$langs->trans("Value").''; + print_liste_field_titre($langs->trans("Value"), '', 'b.datev, b.datec, b.rowid','',$param,'',$sortfield,$sortorder); print ''.$langs->trans("Type").''; print ''.$langs->trans("Numero").''; print ''.$langs->trans("Description").''; @@ -603,7 +595,7 @@ if ($id > 0 || ! empty($ref)) $sql.= " AND b.fk_account = ba.rowid"; $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; $sql.= $sql_rech; - $sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day + $sql.= $db->order($sortfield, "ASC"); // We add date of creation to have correct order when everything is done the same day $sql.= $db->plimit($limitsql, 0); dol_syslog("account.php get transactions -", LOG_DEBUG); diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index bfda1fb9c1b..6115c0f6c84 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $langs->load("banks"); $langs->load("categories"); -$id=GETPOST('account'); +$id=GETPOST('account')?GETPOST('account','alpha'):GETPOST('id'); $ref=GETPOST('ref'); // Security check @@ -60,16 +60,16 @@ llxHeader('',$title,$helpurl); $form = new Form($db); // Get account informations -$acct = new Account($db); +$object = new Account($db); if ($id > 0 && ! preg_match('/,/', $id)) // if for a particular account and not a list { - $result=$acct->fetch($id); - $id=$acct->id; + $result=$object->fetch($id); + $id=$object->id; } if (! empty($ref)) { - $result=$acct->fetch(0, $ref); - $id=$acct->id; + $result=$object->fetch(0, $ref); + $id=$object->id; } @@ -134,58 +134,38 @@ else // Onglets -$head=bank_prepare_head($acct); +$head=bank_prepare_head($object); dol_fiche_head($head,'annual',$langs->trans("FinancialAccount"),0,'account'); -$title=$langs->trans("FinancialAccount")." : ".$acct->label; -$link=($year_start?"".img_previous()." ".$langs->trans("Year")." ".img_next()."":""); - -print ''; +$title=$langs->trans("FinancialAccount")." : ".$object->label; +$link=($year_start?"".img_previous()." ".$langs->trans("Year")." ".img_next()."":""); $linkback = ''.$langs->trans("BackToList").''; -// Ref -print ''; -print ''; - -// Label -print ''; -print ''; - -print '
'.$langs->trans("Ref").''; + if (!empty($id)) { - if (! preg_match('/,/', $id)) - { - print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref'); - } - else - { - $bankaccount=new Account($db); - $listid=explode(',', $id); - foreach($listid as $key => $aId) - { - $bankaccount->fetch($aId); - $bankaccount->label=$bankaccount->ref; - print $bankaccount->getNomUrl(1); - if ($key < (count($listid)-1)) print ', '; - } - } -} -else -{ - print $langs->trans("ALL"); -} -print '
'.$langs->trans("Label").''; -if (! empty($id)) -{ - print $acct->label; + if (! preg_match('/,/', $id)) + { + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + } + else + { + $bankaccount=new Account($db); + $listid=explode(',', $id); + foreach($listid as $key => $aId) + { + $bankaccount->fetch($aId); + $bankaccount->label=$bankaccount->ref; + print $bankaccount->getNomUrl(1); + if ($key < (count($listid)-1)) print ', '; + } + } } else { print $langs->trans("AllAccounts"); } -print '
'; dol_fiche_end(); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 07a1548bd47..a56d69138c1 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -655,31 +655,6 @@ else if ($object->url) print ''; print "\n"; - // Categories - if ($conf->categorie->enabled) { - print ''.$langs->trans("Categories").''; - print $form->showCategories($object->id,'account',1); - print ""; - } - - print ''.$langs->trans("Comment").''; - print ''.dol_htmlentitiesbr($object->comment).''; - - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print ''; - - - print ''; - print '
'; - print '
'; - print '
'; - - - print ''; - // Accountancy code print ''; print ''; } + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'.$langs->trans("AccountancyCode").''; @@ -697,6 +672,31 @@ else print ''.$object->accountancy_journal.'
'; + + + print '
'; + print '
'; + print '
'; + print '
'; + + + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print ''; + print ''; + print '
'.$langs->trans("Categories").''; + print $form->showCategories($object->id,'account',1); + print "
'.$langs->trans("Comment").''.dol_htmlentitiesbr($object->comment).'
'; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 4c2182bb1e8..0878474dcb5 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -139,6 +139,7 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes') { /* * View */ + $title = $langs->trans("FinancialAccount").' - '.$langs->trans("Documents"); $helpurl = ""; llxHeader('',$title,$helpurl); @@ -152,8 +153,7 @@ if ($id > 0 || !empty($ref)) { // Onglets $head = bank_prepare_head($object); - dol_fiche_head($head, 'document', $langs->trans("FinancialAccount"), 0, - 'account'); + dol_fiche_head($head, 'document', $langs->trans("FinancialAccount"), 0, 'account'); // Construit liste des fichiers @@ -166,29 +166,25 @@ if ($id > 0 || !empty($ref)) { } $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print ''; - - // Ref - print ''; - print ''; - - // Label - print ''; - print ''; - - // Status - print ''; - print ''; - print ''; + + print '
'; + print '
'; + + print '
' . $langs->trans("Ref") . ''; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref'); - print '
' . $langs->trans("Label") . '' . $object->label . '
' . $langs->trans("Status") . '' . $object->getLibStatut(4) . '
' . $langs->trans("NbOfAttachedFiles") . '' . count($filearray) . '
'; + print ''; print ''; print "
' . $langs->trans("NbOfAttachedFiles") . '' . count($filearray) . '
' . $langs->trans("TotalSizeOfAttachedFiles") . '' . $totalsize . ' ' . $langs->trans("bytes") . '
\n"; - print "
\n"; + + print '
'; + + dol_fiche_end(); dol_htmloutput_mesg($mesg, $mesgs); + /* * Confirmation suppression fichier */ diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 66aff20f40c..5f00a500c31 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -67,15 +67,15 @@ if (! empty($_GET["year"])) $year=sprintf("%04d",$_GET["year"]); if (! empty($_GET["month"])) $month=sprintf("%02d",$_GET["month"]); -$acct = new Account($db); +$object = new Account($db); if ($_GET["account"] && ! preg_match('/,/',$_GET["account"])) // if for a particular account and not a list { - $result=$acct->fetch($_GET["account"]); + $result=$object->fetch($_GET["account"]); } if ($_GET["ref"]) { - $result=$acct->fetch(0,$_GET["ref"]); - $account=$acct->id; + $result=$object->fetch(0,$_GET["ref"]); + $account=$object->id; } $result=dol_mkdir($conf->bank->dir_temp); @@ -202,8 +202,8 @@ else { $datas[$i] = $solde + $subtotal; } - $datamin[$i] = $acct->min_desired; - $dataall[$i] = $acct->min_allowed; + $datamin[$i] = $object->min_desired; + $dataall[$i] = $object->min_allowed; //$labels[$i] = strftime("%d",$day); $labels[$i] = $xday; @@ -230,15 +230,15 @@ else foreach($datas as $i => $val) { $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); - if ($acct->min_desired) array_push($graph_datas[$i],$datamin[$i]); - if ($acct->min_allowed) array_push($graph_datas[$i],$dataall[$i]); + if ($object->min_desired) array_push($graph_datas[$i],$datamin[$i]); + if ($object->min_allowed) array_push($graph_datas[$i],$dataall[$i]); } $px1 = new DolGraph(); $px1->SetData($graph_datas); $arraylegends=array($langs->transnoentities("Balance")); - if ($acct->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired")); - if ($acct->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed")); + if ($object->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired")); + if ($object->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed")); $px1->SetLegend($arraylegends); $px1->SetLegendWidthMin(180); $px1->SetMaxValue($px1->GetCeilMaxValue()<0?0:$px1->GetCeilMaxValue()); @@ -346,8 +346,8 @@ else { $datas[$i] = $solde + $subtotal; } - $datamin[$i] = $acct->min_desired; - $dataall[$i] = $acct->min_allowed; + $datamin[$i] = $object->min_desired; + $dataall[$i] = $object->min_allowed; if ($xday == '15') { $labels[$i] = dol_print_date($day,"%b"); @@ -367,14 +367,14 @@ else foreach($datas as $i => $val) { $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); - if ($acct->min_desired) array_push($graph_datas[$i],$datamin[$i]); - if ($acct->min_allowed) array_push($graph_datas[$i],$dataall[$i]); + if ($object->min_desired) array_push($graph_datas[$i],$datamin[$i]); + if ($object->min_allowed) array_push($graph_datas[$i],$dataall[$i]); } $px2 = new DolGraph(); $px2->SetData($graph_datas); $arraylegends=array($langs->transnoentities("Balance")); - if ($acct->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired")); - if ($acct->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed")); + if ($object->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired")); + if ($object->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed")); $px2->SetLegend($arraylegends); $px2->SetLegendWidthMin(180); $px2->SetMaxValue($px2->GetCeilMaxValue()<0?0:$px2->GetCeilMaxValue()); @@ -462,8 +462,8 @@ else { $datas[$i] = '' + $solde + $subtotal; } - $datamin[$i] = $acct->min_desired; - $dataall[$i] = $acct->min_allowed; + $datamin[$i] = $object->min_desired; + $dataall[$i] = $object->min_allowed; if (substr($textdate,6,2) == '01' || $i == 0) { $labels[$i] = substr($textdate,4,2); @@ -482,15 +482,15 @@ else foreach($datas as $i => $val) { $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); - if ($acct->min_desired) array_push($graph_datas[$i],$datamin[$i]); - if ($acct->min_allowed) array_push($graph_datas[$i],$dataall[$i]); + if ($object->min_desired) array_push($graph_datas[$i],$datamin[$i]); + if ($object->min_allowed) array_push($graph_datas[$i],$dataall[$i]); } $px3 = new DolGraph(); $px3->SetData($graph_datas); $arraylegends=array($langs->transnoentities("Balance")); - if ($acct->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired")); - if ($acct->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed")); + if ($object->min_desired) array_push($arraylegends,$langs->transnoentities("BalanceMinimalDesired")); + if ($object->min_allowed) array_push($arraylegends,$langs->transnoentities("BalanceMinimalAllowed")); $px3->SetLegend($arraylegends); $px3->SetLegendWidthMin(180); $px3->SetMaxValue($px3->GetCeilMaxValue()<0?0:$px3->GetCeilMaxValue()); @@ -605,7 +605,7 @@ else $data_credit[$i] = isset($credits[substr("0".($i+1),-2)]) ? $credits[substr("0".($i+1),-2)] : 0; $data_debit[$i] = isset($debits[substr("0".($i+1),-2)]) ? $debits[substr("0".($i+1),-2)] : 0; $labels[$i] = sprintf("%02d",$i+1); - $datamin[$i] = $acct->min_desired; + $datamin[$i] = $object->min_desired; } // Fabrication tableau 4a @@ -714,7 +714,7 @@ else $data_credit[$i] = isset($credits[substr("0".($i+1),-2)]) ? $credits[substr("0".($i+1),-2)] : 0; $data_debit[$i] = isset($debits[substr("0".($i+1),-2)]) ? $debits[substr("0".($i+1),-2)] : 0; $labels[$i] = dol_print_date(dol_mktime(12,0,0,$i+1,1,2000),"%b"); - $datamin[$i] = $acct->min_desired; + $datamin[$i] = $object->min_desired; } // Fabrication tableau 4b @@ -754,36 +754,33 @@ else // Onglets -$head=bank_prepare_head($acct); +$head=bank_prepare_head($object); dol_fiche_head($head,'graph',$langs->trans("FinancialAccount"),0,'account'); -print ''; $linkback = ''.$langs->trans("BackToList").''; -// Ref -print ''; -print ''; - -// Label -print ''; -print ''; - -print '
'.$langs->trans("Ref").''; if ($account) { if (! preg_match('/,/',$account)) { $moreparam='&month='.$month.'&year='.$year.($mode=='showalltime'?'&mode=showalltime':''); + if ($_GET["option"]!='all') { $morehtml=''.$langs->trans("ShowAllAccounts").''; - print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam); } else { $morehtml=''.$langs->trans("BackToAccount").''; - print $langs->trans("All"); + print $langs->trans("AllAccounts"); //print $morehtml; } } else { - $bankaccount=new Account($db); + $bankaccount=new Account($db); $listid=explode(',',$account); foreach($listid as $key => $id) { @@ -795,25 +792,9 @@ if ($account) } } else -{ - print $langs->trans("All"); -} -print '
'.$langs->trans("Label").''; -if ($account && $_GET["option"]!='all') -{ - print $acct->label; -} -else { print $langs->trans("AllAccounts"); } -print '
'; dol_fiche_end(); diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index b0447db68c2..4b03250e76a 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -33,6 +33,16 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; + $langs->load("banks"); $langs->load("bills"); $langs->load("categories"); @@ -61,6 +71,8 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); +$pageplusone = GETPOST("pageplusone",'int'); +if ($pageplusone) $page = $pageplusone - 1; if ($page == -1) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; @@ -68,6 +80,16 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder='DESC'; if (! $sortfield) $sortfield='b.dateo'; +$mode_balance_ok=false; +//if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected +if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid') && $account > 0) +{ + $sortfield = 'b.datev, b.dateo, b.rowid'; + $mode_balance_ok = true; +} +if (strtolower($sortorder) == 'desc') $mode_balance_ok = false; + + // Initialize technical object to manage context to save list fields $contextpage='banktransactionlist'; @@ -81,15 +103,16 @@ $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search $arrayfields=array( 'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'description'=>array('label'=>$langs->trans("Description"), 'checked'=>1), 'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1), 'b.datev'=>array('label'=>$langs->trans("DateValueShort"), 'checked'=>1), 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), 'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1), - 'description'=>array('label'=>$langs->trans("Description"), 'checked'=>1), 'bu.label'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>500), + 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1, 'position'=>1000), 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), - 'ba.ref'=>array('label'=>$langs->trans("Account"), 'checked'=>1, 'position'=>1000), + 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1000), 'b.num_releve'=>array('label'=>$langs->trans("AccountStatement"), 'checked'=>1, 'position'=>1010), ); // Extra fields @@ -148,22 +171,35 @@ if (empty($reshook)) * View */ -$companystatic=new Societe($db); -$bankaccountstatic=new Account($db); - -llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param); - $form = new Form($db); $formother = new FormOther($db); -if ($vline) $viewline = $vline; -else $viewline = 50; +$companystatic=new Societe($db); +$bankaccountstatic=new Account($db); + +$societestatic=new Societe($db); +$userstatic=new User($db); +$chargestatic=new ChargeSociales($db); +$loanstatic=new Loan($db); +$memberstatic=new Adherent($db); +$paymentstatic=new Paiement($db); +$paymentsupplierstatic=new PaiementFourn($db); +$paymentvatstatic=new TVA($db); +$paymentsalstatic=new PaymentSalary($db); +$donstatic=new Don($db); +$expensereportstatic=new ExpenseReport($db); +$bankstatic=new Account($db); +$banklinestatic=new AccountLine($db); + +$now = dol_now(); + +llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param); $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq,"; $sql.= " b.fk_account, b.fk_type,"; $sql.= " ba.rowid as bankid, ba.ref as bankref,"; $sql.= " bu.url_id,"; -$sql.= " s.nom, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; +$sql.= " s.nom, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -183,7 +219,8 @@ if ($search_ref) $sql.=natural_search("b.rowid", $search_ref); if ($account > 0) $sql.=" AND b.fk_account = ".$account; if ($search_req_nb) $sql.= natural_search("b.num_chq", $search_req_nb); if ($search_num_releve) $sql.= natural_search("b.num_releve", $search_num_releve); -if ($search_thirdparty) $sql.=" AND s.nom LIKE '%".$db->escape($search_thirdparty)."%'"; +if ($search_thirdparty) $sql.= natural_search("s.nom", $search_thirdparty); +if ($description) $sql.= natural_search("b.label", $description); // Warning some text are just translation keys, not translated strings if ($bid) $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$bid; if (! empty($type)) $sql.= " AND b.fk_type = '".$db->escape($type)."' "; // Search period criteria @@ -219,6 +256,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + $nbtotalofpages = ceil($nbtotalofrecords/$limit); } $sql.= $db->plimit($limit+1,$offset); @@ -280,14 +318,20 @@ if ($resql) // Title $bankcateg=new BankCateg($db); + $morehtml='
'; + $morehtml.= ' "; // ' Page '; + $morehtml.=''; + $morehtml.='/'.$nbtotalofpages.' '; + $morehtml.='
'; + if (GETPOST("bid")) { $result=$bankcateg->fetch(GETPOST("bid")); - print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, '', '', $limit); + print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, $morehtml, '', $limit); } else { - print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, '', '', $limit); + print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, $morehtml, '', $limit); } $moreforfilter = ''; @@ -320,16 +364,17 @@ if ($resql) // Fields title print ''; if (! empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'],$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['description']['checked'])) print_liste_field_titre($arrayfields['description']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['b.dateo']['checked'])) print_liste_field_titre($arrayfields['b.dateo']['label'],$_SERVER['PHP_SELF'],'b.dateo','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'],$_SERVER['PHP_SELF'],'b.datev','',$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'],$_SERVER['PHP_SELF'],'b.datev, b.dateo, b.rowid','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['b.num_chq']['checked'])) print_liste_field_titre($arrayfields['b.num_chq']['label'],$_SERVER['PHP_SELF'],'b.num_chq','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['description']['checked'])) print_liste_field_titre($arrayfields['description']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['bu.label']['checked'])) print_liste_field_titre($arrayfields['bu.label']['label'],$_SERVER['PHP_SELF'],'bu.label','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['ba.ref']['checked'])) print_liste_field_titre($arrayfields['ba.ref']['label'],$_SERVER['PHP_SELF'],'ba.ref','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['b.debit']['checked'])) print_liste_field_titre($arrayfields['b.debit']['label'],$_SERVER['PHP_SELF'],'b.amount','',$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['b.credit']['checked'])) print_liste_field_titre($arrayfields['b.credit']['label'],$_SERVER['PHP_SELF'],'b.amount','',$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['ba.ref']['checked'])) print_liste_field_titre($arrayfields['ba.ref']['label'],$_SERVER['PHP_SELF'],'ba.ref','',$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['b.num_releve']['checked'])) print_liste_field_titre($arrayfields['b.num_releve']['label'],$_SERVER['PHP_SELF'],'b.num_releve','',$param,'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['balance']['checked'])) print_liste_field_titre($arrayfields['balance']['label'],$_SERVER['PHP_SELF'],'balance','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['b.num_releve']['checked'])) print_liste_field_titre($arrayfields['b.num_releve']['label'],$_SERVER['PHP_SELF'],'b.num_releve','',$param,'align="center"',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -356,6 +401,12 @@ if ($resql) print ''; print ''; } + if (! empty($arrayfields['description']['checked'])) + { + print ''; + //print ''; + print ''; + } if (! empty($arrayfields['b.dateo']['checked'])) { print ' '; @@ -367,7 +418,7 @@ if ($resql) if (! empty($arrayfields['type']['checked'])) { print ''; - $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1); + $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1, 0, 1, 'maxwidth100'); print ''; } if (! empty($arrayfields['b.num_chq']['checked'])) @@ -375,16 +426,16 @@ if ($resql) // Numero print ''; } - if (! empty($arrayfields['description']['checked'])) - { - print ''; - print ''; - print ''; - } if (! empty($arrayfields['bu.label']['checked'])) { print ''; } + if (! empty($arrayfields['ba.ref']['checked'])) + { + print ''; + $form->select_comptes($account,'account',0,'',1); + print ''; + } if (! empty($arrayfields['b.debit']['checked'])) { print ''; @@ -397,16 +448,17 @@ if ($resql) print ''; print ''; } - if (! empty($arrayfields['ba.ref']['checked'])) + if (! empty($arrayfields['balance']['checked'])) { print ''; - $form->select_comptes($account,'account',0,'',1); + $htmltext=$langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue")); + print $form->textwithpicto('', $htmltext, 1); print ''; } if (! empty($arrayfields['b.num_releve']['checked'])) { - // Numero - print ''; + // Numero statement + print ''; } print ''; $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); @@ -415,168 +467,346 @@ if ($resql) print "\n"; // Loop on each record + $total = 0; // For balance + $sign = 1; + $totalarray=array(); while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); - // Why this ? - $printline=false; - //Search Description - if ($description) { - preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthese on tente recherche de traduction - if ($reg[1]) { - if ($langs->transnoentities($reg[1])==$description) { - $printline=true; - } - } elseif ($objp->label==$description) { - $printline=true; - } - } else { - $printline=true; + $total = price2num($total + ($sign * $objp->amount),'MT'); + + if (empty($cachebankaccount[$objp->bankid])) + { + $bankaccounttmp = new Account($db); + $bankaccounttmp->fetch($objp->bankid); + $cachebankaccount[$objp->bankid]=$bankaccounttmp; + $bankaccount = $bankaccounttmp; } - if ($printline) { - - $var=!$var; + else + { + $bankaccount = $cachebankaccount[$objp->bankid]; + } + + $var=!$var; - print ""; + print ""; - // Ref - if (! empty($arrayfields['b.rowid']['checked'])) - { - print ''; - print "rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'payment', 'class="classfortooltip"').' '.$objp->rowid."   "; - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date ope - if (! empty($arrayfields['b.dateo']['checked'])) - { - print ''.dol_print_date($db->jdate($objp->do),"day")."\n"; - if (! $i) $totalarray['nbfield']++; - } - - // Date value - if (! empty($arrayfields['b.datev']['checked'])) - { - print ''.dol_print_date($db->jdate($objp->dv),"day")."\n"; - if (! $i) $totalarray['nbfield']++; - } - - // Payment type - if (! empty($arrayfields['type']['checked'])) - { - print ''; - $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle'); - if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance"); - else print $labeltype; - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - - // Num cheque - if (! empty($arrayfields['b.num_releve']['checked'])) - { - print ''.($objp->num_chq?$objp->num_chq:"")."\n"; - if (! $i) $totalarray['nbfield']++; - } - - // Description - if (! empty($arrayfields['description']['checked'])) - { - print ""; - - print "rowid."&account=".$objp->fk_account."\">"; - $reg=array(); - preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthee on tente recherche de traduction - if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); - else print dol_trunc($objp->label,40); - print " "; - - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Third party - if (! empty($arrayfields['bu.label']['checked'])) - { - print ""; - if ($objp->url_id) - { - $companystatic->id=$objp->url_id; - $companystatic->name=$objp->nom; - $companystatic->name_alias=$objp->name_alias; - $companystatic->client=$objp->client; - $companystatic->fournisseur=$objp->fournisseur; - $companystatic->code_client=$objp->code_client; - $companystatic->code_fournisseur=$objp->code_fournisseur; - print $companystatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; + // Ref + if (! empty($arrayfields['b.rowid']['checked'])) + { + print ''; + print "rowid.'">'.img_object($langs->trans("ShowPayment").': '.$objp->rowid, 'account', 'class="classfortooltip"').' '.$objp->rowid."   "; + print ''; if (! $i) $totalarray['nbfield']++; - } - - // Debit - if (! empty($arrayfields['b.debit']['checked'])) - { - print ''; - if ($objp->amount < 0) - { - print price($objp->amount * -1); - $totalarray['totaldeb'] += $objp->amount; - } - print "\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield']; - } - // Credit - if (! empty($arrayfields['b.credit']['checked'])) - { - print ''; - if ($objp->amount > 0) - { - print price($objp->amount); - $totalarray['totalcred'] += $objp->amount; - } - print "\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield']; - } - - // Bank account - if (! empty($arrayfields['ba.ref']['checked'])) - { - print ''; - $bankaccountstatic->id=$objp->bankid; - $bankaccountstatic->label=$objp->bankref; - print $bankaccountstatic->getNomUrl(1); - print "\n"; + } + + // Description + if (! empty($arrayfields['description']['checked'])) + { + print ""; + + //print "rowid."&account=".$objp->fk_account."\">"; + $reg=array(); + preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthee on tente recherche de traduction + if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); + else print dol_trunc($objp->label,40); + //print " "; + + // Add links after description + $links = $bankaccountstatic->get_url($objp->rowid); + $cachebankaccount=array(); + foreach($links as $key=>$val) + { + if ($links[$key]['type']=='payment') + { + $paymentstatic->id=$links[$key]['url_id']; + $paymentstatic->ref=$links[$key]['url_id']; + print ' '.$paymentstatic->getNomUrl(2); + } + elseif ($links[$key]['type']=='payment_supplier') + { + $paymentsupplierstatic->id=$links[$key]['url_id']; + $paymentsupplierstatic->ref=$links[$key]['url_id']; + print ' '.$paymentsupplierstatic->getNomUrl(2); + } + elseif ($links[$key]['type']=='payment_sc') + { + print ''; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + //print $langs->trans("SocialContributionPayment"); + print ''; + } + elseif ($links[$key]['type']=='payment_vat') + { + $paymentvatstatic->id=$links[$key]['url_id']; + $paymentvatstatic->ref=$links[$key]['url_id']; + print ' '.$paymentvatstatic->getNomUrl(2); + } + elseif ($links[$key]['type']=='payment_salary') + { + $paymentsalstatic->id=$links[$key]['url_id']; + $paymentsalstatic->ref=$links[$key]['url_id']; + print ' '.$paymentsalstatic->getNomUrl(2); + } + elseif ($links[$key]['type']=='payment_loan') + { + print ''; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + print ''; + } + elseif ($links[$key]['type']=='payment_donation') + { + print ''; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + print ''; + } + elseif ($links[$key]['type']=='payment_expensereport') + { + print ''; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + print ''; + } + elseif ($links[$key]['type']=='banktransfert') + { + // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. + if ($objp->amount > 0) + { + $banklinestatic->fetch($links[$key]['url_id']); + $bankstatic->id=$banklinestatic->fk_account; + $bankstatic->label=$banklinestatic->bank_account_ref; + print ' ('.$langs->trans("TransferFrom").' '; + print $bankstatic->getNomUrl(1,'transactions'); + print ' '.$langs->trans("toward").' '; + $bankstatic->id=$objp->bankid; + $bankstatic->label=$objp->bankref; + print $bankstatic->getNomUrl(1,''); + print ')'; + } + else + { + $bankstatic->id=$objp->bankid; + $bankstatic->label=$objp->bankref; + print ' ('.$langs->trans("TransferFrom").' '; + print $bankstatic->getNomUrl(1,''); + print ' '.$langs->trans("toward").' '; + $banklinestatic->fetch($links[$key]['url_id']); + $bankstatic->id=$banklinestatic->fk_account; + $bankstatic->label=$banklinestatic->bank_account_ref; + print $bankstatic->getNomUrl(1,'transactions'); + print ')'; + } + //var_dump($links); + } + elseif ($links[$key]['type']=='company') + { + + } + elseif ($links[$key]['type']=='user') + { + + } + elseif ($links[$key]['type']=='member') + { + + } + elseif ($links[$key]['type']=='sc') + { + + } + else + { + // Show link with label $links[$key]['label'] + if (! empty($objp->label) && ! empty($links[$key]['label'])) print ' - '; + print ''; + if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg)) + { + // Label generique car entre parentheses. On l'affiche en le traduisant + if ($reg[1]=='paiement') $reg[1]='Payment'; + print ' '.$langs->trans($reg[1]); + } + else + { + print ' '.$links[$key]['label']; + } + print ''; + } + } + + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Date ope + if (! empty($arrayfields['b.dateo']['checked'])) + { + print ''.dol_print_date($db->jdate($objp->do),"day")."\n"; if (! $i) $totalarray['nbfield']++; - } - - if (! empty($arrayfields['b.num_releve']['checked'])) - { - print ''.($objp->num_releve?$objp->num_releve:"")."\n"; + } + + // Date value + if (! empty($arrayfields['b.datev']['checked'])) + { + print ''.dol_print_date($db->jdate($objp->dv),"day")."\n"; if (! $i) $totalarray['nbfield']++; - } - - // Action column - print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; - } - print ''; + } + + // Payment type + if (! empty($arrayfields['type']['checked'])) + { + print ''; + $labeltype=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle'); + if ($labeltype == 'SOLD') print ' '; //$langs->trans("InitialBankBalance"); + else print $labeltype; + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + + // Num cheque + if (! empty($arrayfields['b.num_releve']['checked'])) + { + print ''.($objp->num_chq?$objp->num_chq:"")."\n"; + if (! $i) $totalarray['nbfield']++; + } + + // Third party + if (! empty($arrayfields['bu.label']['checked'])) + { + print ""; + if ($objp->url_id) + { + $companystatic->id=$objp->url_id; + $companystatic->name=$objp->nom; + $companystatic->name_alias=$objp->name_alias; + $companystatic->client=$objp->client; + $companystatic->fournisseur=$objp->fournisseur; + $companystatic->code_client=$objp->code_client; + $companystatic->code_fournisseur=$objp->code_fournisseur; + $companystatic->code_compta=$objp->code_compta; + $companystatic->code_compta_fournisseur=$objp->code_compta_fournisseur; + print $companystatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; if (! $i) $totalarray['nbfield']++; - - print ""; - } + } + + // Bank account + if (! empty($arrayfields['ba.ref']['checked'])) + { + print ''; + print $bankaccount->getNomUrl(1); + print "\n"; + if (! $i) $totalarray['nbfield']++; + } + + // Debit + if (! empty($arrayfields['b.debit']['checked'])) + { + print ''; + if ($objp->amount < 0) + { + print price($objp->amount * -1); + $totalarray['totaldeb'] += $objp->amount; + } + print "\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield']; + } + // Credit + if (! empty($arrayfields['b.credit']['checked'])) + { + print ''; + if ($objp->amount > 0) + { + print price($objp->amount); + $totalarray['totalcred'] += $objp->amount; + } + print "\n"; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield']; + } + + // Balance + if (! empty($arrayfields['balance']['checked'])) + { + if ($mode_balance_ok) + { + if ($total >= 0) + { + print ' '.price($total).''; + } + else + { + print ' '.price($total).''; + } + } + else + { + print '-'; + } + } + + // Transaction reconciliated or edit link + if ($objp->rappro && $bankaccount->canBeConciliated() > 0) // If line not conciliated and account can be conciliated + { + print ''; + print ''; + print img_edit(); + print ''; + print "  "; + print ''.$objp->num_releve.''; + print ""; + } + else + { + print ''; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + print img_edit(); + print ''; + } + else + { + print ''; + print img_view(); + print ''; + } + if ($bankaccount->canBeConciliated() > 0 && empty($objp->rappro)) + { + if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) + { + print ' '.img_warning($langs->trans("Late")); + } + } + print ' '; + if ($user->rights->banque->modifier) + { + print 'rowid.'&id='.$object->id.'&page='.$page.'">'; + print img_delete(); + print ''; + } + print ''; + } + + // Action column + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print ''; + if (! $i) $totalarray['nbfield']++; + + print ""; + $i++; } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 2b3593cd5bd..3de977f29cf 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -22,7 +22,7 @@ /** * \file htdocs/compta/bank/treso.php * \ingroup banque - * \brief Page de detail du budget de tresorerie + * \brief Page to estimate future balance */ require '../../main.inc.php'; @@ -77,42 +77,32 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $viewline = 20; } - $acct = new Account($db); + $object = new Account($db); if ($_GET["account"]) { - $result=$acct->fetch($_GET["account"]); + $result=$object->fetch($_GET["account"]); } if ($_GET["ref"]) { - $result=$acct->fetch(0,$_GET["ref"]); - $_GET["account"]=$acct->id; + $result=$object->fetch(0,$_GET["ref"]); + $_GET["account"]=$object->id; } // Onglets - $head=bank_prepare_head($acct); + $head=bank_prepare_head($object); dol_fiche_head($head,'cash',$langs->trans("FinancialAccount"),0,'account'); print ''; $linkback = ''.$langs->trans("BackToList").''; - // Ref - print ''; - print ''; - - // Label - print ''; - print ''; - - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($acct, 'ref', $linkback, 1, 'ref'); - print '
'.$langs->trans("Label").''.$acct->label.'
'; + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_fiche_end(); - $solde = $acct->solde(0); + $solde = $object->solde(0); /* * Affiche tableau des echeances a venir @@ -154,7 +144,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.paye = 0 AND f.fk_statut = 1"; // Not paid - $sql.= " AND (f.fk_account IN (0, ".$acct->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice + $sql.= " AND (f.fk_account IN (0, ".$object->id.") OR f.fk_account IS NULL)"; // Id bank account of invoice $sql.= " ORDER BY dlr ASC"; // Supplier invoices @@ -164,7 +154,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; $sql2.= " WHERE ff.entity = ".$conf->entity; $sql2.= " AND ff.paye = 0 AND fk_statut = 1"; // Not paid - $sql2.= " AND (ff.fk_account IN (0, ".$acct->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice + $sql2.= " AND (ff.fk_account IN (0, ".$object->id.") OR ff.fk_account IS NULL)"; // Id bank account of supplier invoice $sql2.= " ORDER BY dlr ASC"; // Social contributions @@ -174,7 +164,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql3.= " LEFT JOIN ".MAIN_DB_PREFIX."c_chargesociales as ccs ON cs.fk_type = ccs.id"; $sql3.= " WHERE cs.entity = ".$conf->entity; $sql3.= " AND cs.paye = 0"; // Not paid - $sql3.= " AND (cs.fk_account IN (0, ".$acct->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution + $sql3.= " AND (cs.fk_account IN (0, ".$object->id.") OR cs.fk_account IS NULL)"; // Id bank account of social contribution $sql3.= " ORDER BY dlr ASC"; $error=0; @@ -332,8 +322,8 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) // Solde actuel $var=!$var; print ''; - print ''.$langs->trans("FutureBalance").' ('.$acct->currency_code.')'; - print ''.price($solde, 0, $langs, 0, 0, -1, $acct->currency_code).''; + print ''.$langs->trans("FutureBalance").' ('.$object->currency_code.')'; + print ''.price($solde, 0, $langs, 0, 0, -1, $object->currency_code).''; print ''; print ""; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ceac1fc4b44..b5d9ead05e3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2814,9 +2814,10 @@ class Form * @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $maxlength Max length of label * @param int $active Active or not, -1 = all + * @param string $morecss Add more css * @return void */ - function select_types_paiements($selected='', $htmlname='paiementtype', $filtertype='', $format=0, $empty=0, $noadmininfo=0, $maxlength=0, $active=1) + function select_types_paiements($selected='', $htmlname='paiementtype', $filtertype='', $format=0, $empty=0, $noadmininfo=0, $maxlength=0, $active=1, $morecss='') { global $langs,$user; @@ -2829,7 +2830,7 @@ class Form $this->load_cache_types_paiements(); - print ''; if ($empty) print ''; foreach($this->cache_types_paiements as $id => $arraytypes) { diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a1e86aed8c0..df355418191 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -943,11 +943,12 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Chart of account if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("", $langs->trans("Setup"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 2); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 3); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 2); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 2); - + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 10); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 20); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 40); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 50); + // Binding if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); if (preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer",$langs->trans("ToBind"),2,$user->rights->accounting->bind->write); diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index b44414b8c29..dc8681a85fd 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -377,92 +377,16 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $default_font_size = pdf_getPDFFontSize($outputlangs); $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf,$outputlangs,'BANK_CHEQUERECEIPT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); - $paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT'; - $marge_basse=$this->marge_basse; - $marge_gauche=$this->marge_gauche; - $page_hauteur=$this->page_hauteur; // Line of free text - $line=(! empty($conf->global->$paramfreetext))?$outputlangs->convToOutputCharset($conf->global->$paramfreetext):""; - - $pdf->SetFont('','', $default_font_size - 3); - $pdf->SetDrawColor(224,224,224); - - // The start of the bottom of this page footer is positioned according to # of lines - $freetextheight=0; - if ($line) // Free text - { - //$line="eee
\nfdsfsdf
\nghfghg
"; - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) // by default - { - $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. - if (! empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { - $width=200; $align='C'; - } - $freetextheight=$pdf->getStringHeight($width,$line); - } - else - { - $freetextheight=pdfGetHeightForHtmlContent($pdf,dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); // New method (works for HTML content) - //print '
'.$freetextheight;exit; - } - } - - $marginwithfooter=$marge_basse + $freetextheight; - $posy=$marginwithfooter+0; - - if ($line) // Free text - { - $pdf->SetXY($dims['lm'],-$posy); - if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) // by default - { - $pdf->MultiCell(0, 3, $line, 0, $align, 0); - } - else - { - $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $freetextheight, $dims['lm'], $dims['hk']-$marginwithfooter, dol_htmlentitiesbr($line, 1, 'UTF-8', 0)); - } - $posy-=$freetextheight; - } - - // On positionne le debut du bas de page selon nbre de lignes de ce bas de page - /* - $nbofline=dol_nboflines_bis($line,0,$outputlangs->charset_output); - //print 'e'.$line.'t'.dol_nboflines($line);exit; - $posy=$marge_basse + ($nbofline*3); - - if ($line) // Free text + $newfreetext=''; + $paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT'; + if (! empty($conf->global->$paramfreetext)) { - $pdf->SetXY($marge_gauche,-$posy); - $pdf->MultiCell(20000, 3, $line, 0, 'L', 0); // Use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. - $posy-=($nbofline*3); // 6 of ligne + 3 of MultiCell - }*/ - - $pdf->SetY(-$posy); - $pdf->line($marge_gauche, $page_hauteur-$posy, 200, $page_hauteur-$posy); - $posy--; - - /*if ($line1) - { - $pdf->SetXY($marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $line1, 0, 'C', 0); + $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); } - - if ($line2) - { - $posy-=3; - $pdf->SetXY($marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $line2, 0, 'C', 0); - }*/ - - // Show page nb only on iso languages (so default Helvetica font) - if (pdf_getPDFFont($outputlangs) == 'Helvetica') - { - $pdf->SetXY(-20,-$posy); - $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); - } + + return pdf_pagefoot($pdf,$outputlangs,$newfreetext,$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } - } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index ea330faef1a..6b14a6c99fa 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -590,8 +590,6 @@ class pdf_einstein extends ModelePDFCommandes $this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); return 0; } - $this->error=$langs->trans("ErrorUnknown"); - return 0; // Erreur par defaut } /** diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index a25c9918408..411b3deadf3 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -406,8 +406,6 @@ class pdf_strato extends ModelePDFContract $this->error=$langs->trans("ErrorConstantNotDefined","CONTRACT_OUTPUTDIR"); return 0; } - $this->error=$langs->trans("ErrorUnknown"); - return 0; // Erreur par defaut } /** diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index c20eb924e97..314d5779ede 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -269,8 +269,6 @@ class html_cerfafr extends ModeleDon $this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR"); return 0; } - $this->error=$langs->trans("ErrorUnknown"); - return 0; // Error by default } } diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index c46e675b34c..abc40f23005 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -482,8 +482,6 @@ class pdf_standard extends ModeleExpenseReport $this->error=$langs->trans("ErrorConstantNotDefined","EXPENSEREPORT_OUTPUTDIR"); return 0; } - $this->error=$langs->trans("ErrorUnknown"); - return 0; // Erreur par defaut } /** diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 5711c5b698c..83306b95adb 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -405,8 +405,6 @@ class pdf_soleil extends ModelePDFFicheinter $this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR"); return 0; } - $this->error=$langs->trans("ErrorUnknown"); - return 0; // Erreur par defaut } /** diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 7d9dc1df1ef..19d09fd7631 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -763,9 +763,6 @@ class pdf_azur extends ModelePDFPropales $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR"); return 0; } - - $this->error=$langs->trans("ErrorUnknown"); - return 0; // Erreur par defaut } /** diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index cd6f0b1fdc9..c5f68df95c1 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -549,8 +549,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); return 0; } - $this->error=$langs->trans("ErrorUnknown"); - return 0; // Erreur par defaut } /** diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 411c2325e2e..8d7093bfe73 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -572,8 +572,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); return 0; } - $this->error=$langs->trans("ErrorUnknown"); - return 0; // Erreur par defaut } diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index 431bc1bff7c..48702607b77 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -198,8 +198,6 @@ class InterfaceLogevents extends DolibarrTriggers dol_syslog(get_class($this).": ".$this->error, LOG_ERR); return -1; } - - return 0; } } diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index 7c1da17c8b0..81c72eccb8f 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -333,3 +333,7 @@ INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (20 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2321,232, '0','0','No VAT',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2322,232, '12','0','VAT 12%',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2323,232, '8','0','VAT 8%',1); + + + + diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 1b50ae0cc15..cf34086f066 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -140,3 +140,13 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN tms timestamp; ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint + + +ALTER TABLE llx_facturedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; +ALTER TABLE llx_facture_fourn_det ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; +ALTER TABLE llx_commandedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; +ALTER TABLE llx_commande_fournisseurdet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; +ALTER TABLE llx_propaldet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; +ALTER TABLE llx_supplier_proposaldet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; + + \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseurdet.sql b/htdocs/install/mysql/tables/llx_commande_fournisseurdet.sql index f7b10c8e35e..85cdcbb9a60 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseurdet.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseurdet.sql @@ -28,6 +28,7 @@ create table llx_commande_fournisseurdet ref varchar(50), -- supplier product ref label varchar(255), -- product label description text, + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva_tx double(6,3) DEFAULT 0, -- taux tva localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_type varchar(10) NULL, -- localtax1 type diff --git a/htdocs/install/mysql/tables/llx_commandedet.sql b/htdocs/install/mysql/tables/llx_commandedet.sql index 913351ef2f8..53a1b07c3c7 100644 --- a/htdocs/install/mysql/tables/llx_commandedet.sql +++ b/htdocs/install/mysql/tables/llx_commandedet.sql @@ -28,7 +28,8 @@ create table llx_commandedet fk_product integer NULL, label varchar(255) DEFAULT NULL, description text, - tva_tx double(6,3), -- vat rate + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. + tva_tx double(6,3), -- Vat rate localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_type varchar(10) NULL, -- localtax1 type localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate diff --git a/htdocs/install/mysql/tables/llx_facture_fourn_det.sql b/htdocs/install/mysql/tables/llx_facture_fourn_det.sql index feff72e39b9..2f75f9ff54e 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn_det.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn_det.sql @@ -31,6 +31,7 @@ create table llx_facture_fourn_det pu_ttc double(24,8), -- unit price with tax qty real, -- quantity of product/service remise_percent real DEFAULT 0, -- % de la remise ligne (exemple 20%) + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva_tx double(6,3), -- TVA taux product/service localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_type varchar(10) NULL, -- localtax1 type diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index 42f83e16500..0bf124975ab 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -26,15 +26,16 @@ create table llx_facturedet ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture integer NOT NULL, - fk_parent_line integer NULL, + fk_parent_line integer NULL, fk_product integer NULL, -- Doit pouvoir etre nul pour ligne detail sans produits label varchar(255) DEFAULT NULL, description text, + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva_tx double(6,3), -- Vat rate (example 20%) localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate - localtax1_type varchar(10) NULL, -- localtax1 type + localtax1_type varchar(10) NULL, -- localtax1 type localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate - localtax2_type varchar(10) NULL, -- localtax2 type + localtax2_type varchar(10) NULL, -- localtax2 type qty real, -- Quantity (exemple 2) remise_percent real DEFAULT 0, -- % de la remise ligne (exemple 20%) remise real DEFAULT 0, -- Montant calcule de la remise % sur PU HT (exemple 20) @@ -43,13 +44,13 @@ create table llx_facturedet price double(24,8), -- Deprecated (Do not use) total_ht double(24,8), -- Total HT de la ligne toute quantite et incluant remise ligne et globale total_tva double(24,8), -- Total TVA de la ligne toute quantite et incluant remise ligne et globale - total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1 for total quantity of line - total_localtax2 double(24,8) DEFAULT 0, -- total LocalTax2 for total quantity of line + total_localtax1 double(24,8) DEFAULT 0, -- Total LocalTax1 for total quantity of line + total_localtax2 double(24,8) DEFAULT 0, -- Total LocalTax2 for total quantity of line total_ttc double(24,8), -- Total TTC de la ligne toute quantite et incluant remise ligne et globale product_type integer DEFAULT 0, - date_start datetime DEFAULT NULL, -- date debut si service - date_end datetime DEFAULT NULL, -- date fin si service - info_bits integer DEFAULT 0, -- TVA NPR ou non + date_start datetime DEFAULT NULL, -- date start if service + date_end datetime DEFAULT NULL, -- date end if service + info_bits integer DEFAULT 0, -- VAT NPR or not (for france only) buy_price_ht double(24,8) DEFAULT 0, -- buying price fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created) @@ -58,19 +59,19 @@ create table llx_facturedet special_code integer DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, -- position of line - fk_contract_line integer NULL, -- id of contract line when invoice comes from contract lines + fk_contract_line integer NULL, -- id of contract line when invoice comes from contract lines import_key varchar(14), - situation_percent real, -- % progression of lines invoicing - fk_prev_id integer, -- id of the line in the previous situation, - fk_unit integer DEFAULT NULL, -- id of the unit codeĀ” + situation_percent real, -- % progression of lines invoicing + fk_prev_id integer, -- id of the line in the previous situation, + fk_unit integer DEFAULT NULL, -- id of the unit codeĀ” - fk_multicurrency integer, + fk_multicurrency integer, multicurrency_code varchar(255), multicurrency_subprice double(24,8) DEFAULT 0, multicurrency_total_ht double(24,8) DEFAULT 0, - multicurrency_total_tva double(24,8) DEFAULT 0, - multicurrency_total_ttc double(24,8) DEFAULT 0 + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0 )ENGINE=innodb; -- diff --git a/htdocs/install/mysql/tables/llx_propaldet.sql b/htdocs/install/mysql/tables/llx_propaldet.sql index 3f372894182..70029acdb08 100644 --- a/htdocs/install/mysql/tables/llx_propaldet.sql +++ b/htdocs/install/mysql/tables/llx_propaldet.sql @@ -28,7 +28,8 @@ create table llx_propaldet label varchar(255) DEFAULT NULL, description text, fk_remise_except integer NULL, -- Lien vers table des remises fixes - tva_tx double(6,3) DEFAULT 0, -- taux tva + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. + tva_tx double(6,3) DEFAULT 0, -- Vat rate localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_type varchar(10) NULL, -- localtax1 type localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate diff --git a/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql b/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql index 22467c63e26..f94df8f2e74 100644 --- a/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql +++ b/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql @@ -23,7 +23,8 @@ CREATE TABLE llx_supplier_proposaldet ( label varchar(255) DEFAULT NULL, description text, fk_remise_except integer DEFAULT NULL, - tva_tx double(6,3) DEFAULT 0, + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. + tva_tx double(6,3) DEFAULT 0, -- Vat rate localtax1_tx double(6,3) DEFAULT 0, localtax1_type varchar(10) DEFAULT NULL, localtax2_tx double(6,3) DEFAULT 0, @@ -45,7 +46,6 @@ CREATE TABLE llx_supplier_proposaldet ( special_code integer DEFAULT 0, rang integer DEFAULT 0, ref_fourn varchar(30) DEFAULT NULL, - fk_multicurrency integer, multicurrency_code varchar(255), multicurrency_subprice double(24,8) DEFAULT 0, diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index a1859e0ad4b..f41bc17814d 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -24,7 +24,7 @@ AccountancyAreaDescActionFreq=The following actions are usually executed every m AccountancyAreaDescChartModel=STEP %s: Create a model of chart of account from menu %s AccountancyAreaDescChart=STEP %s: Create or check content of your chart of account from menu %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.
For this, go on the card of each financial account. You can start from page %s. -AccountancyAreaDescVat=STEP %s: Check the binding between vat payment 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 record related to VAT payments.
You can set accounting accounts to use for each VAT from page %s. +AccountancyAreaDescVat=STEP %s: Check the binding between vat rates 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 record related to VAT lines.
You can set accounting accounts to use for each VAT from page %s. AccountancyAreaDescSal=STEP %s: Check the binding between salaries payment 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 record related to payment of salaries.
For this you can use the menu entry %s. AccountancyAreaDescContrib=STEP %s: Check the binding between special expences (miscellaneous taxes) 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 record related to payments of taxes.
For this you can use the menu entry %s. AccountancyAreaDescDonation=STEP %s: Check the binding between donation 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 record related to payments of donation.
You can set the account dedicated for that from the menu entry %s. @@ -46,6 +46,7 @@ AccountAccounting=Accounting account AccountAccountingShort=Account AccountAccountingSuggest=Accounting account suggest MenuDefaultAccounts=Default accounts +MenuVatAccounts=Vat accounts MenuProductsAccounts=Product accounts ProductsBinding=Products accounts Ventilation=Binding to accounts diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index c6f56630745..bd410e7b726 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -86,6 +86,7 @@ Refund=Refund SocialContributionsPayments=Social/fiscal taxes payments ShowVatPayment=Show VAT payment TotalToPay=Total to pay +BalanceVisibilityDependsOnSortAndFilters=Balance is visible in this list only if table is sorted ascending on %s and filtered for 1 bank account CustomerAccountancyCode=Customer accountancy code SupplierAccountancyCode=Supplier accountancy code CustomerAccountancyCodeShort=Cust. account. code diff --git a/htdocs/product/list.php b/htdocs/product/list.php index ec55ad4f74c..fa0f18f538c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -335,23 +335,23 @@ else } $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_categ > 0) $param.="&search_categ=".$search_categ; - if ($sref) $param="&sref=".$sref; - if ($search_ref_supplier) $param="&search_ref_supplier=".$search_ref_supplier; - if ($sbarcode) $param.=($sbarcode?"&sbarcode=".$sbarcode:""); - if ($snom) $param.="&snom=".$snom; - if ($sall) $param.="&sall=".$sall; - if ($tosell != '') $param.="&tosell=".$tosell; - if ($tobuy != '') $param.="&tobuy=".$tobuy; - if ($fourn_id) $param.=($fourn_id?"&fourn_id=".$fourn_id:""); - if ($seach_categ) $param.=($search_categ?"&search_categ=".$search_categ:""); + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_categ > 0) $param.="&search_categ=".urlencode($search_categ); + if ($sref) $param="&sref=".urlencode($sref); + if ($search_ref_supplier) $param="&search_ref_supplier=".urlencode($search_ref_supplier); + if ($sbarcode) $param.=($sbarcode?"&sbarcode=".urlencode($sbarcode):""); + if ($snom) $param.="&snom=".urlencode($snom); + if ($sall) $param.="&sall=".urlencode($sall); + if ($tosell != '') $param.="&tosell=".urlencode($tosell); + if ($tobuy != '') $param.="&tobuy=".urlencode($tobuy); + if ($fourn_id > 0) $param.=($fourn_id?"&fourn_id=".$fourn_id:""); + if ($seach_categ) $param.=($search_categ?"&search_categ=".urlencode($search_categ):""); if ($type != '') $param.='&type='.urlencode($type); - if ($optioncss != '') $param.='&optioncss='.$optioncss; - if ($search_tobatch) $param="&search_ref_supplier=".$search_ref_supplier; - if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".$search_accountancy_code_sell; - if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".$search_accountancy_code_buy; + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_tobatch) $param="&search_ref_supplier=".urlencode($search_ref_supplier); + if ($search_accountancy_code_sell) $param="&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); + if ($search_accountancy_code_buy) $param="&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); // Add $param from extra fields foreach ($search_array_options as $key => $val) { diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 95d5b33e162..689771ad223 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -260,7 +260,6 @@ abstract class ActionsCardCommon return; } } - exit; } else { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index ee60baaa395..1d8ac3ff98a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1904,7 +1904,11 @@ class Societe extends CommonObject $label.= '
' . $langs->trans('CustomerCode') . ': '. $this->code_client; if (! empty($this->code_fournisseur) && $this->fournisseur) $label.= '
' . $langs->trans('SupplierCode') . ': '. $this->code_fournisseur; - + if (! empty($conf->accounting->enabled) && $this->client) + $label.= '
' . $langs->trans('CustomerAccountancyCode') . ': '. $this->code_compta_client; + if (! empty($conf->accounting->enabled) && $this->fournisseur) + $label.= '
' . $langs->trans('SupplierAccountancyCode') . ': '. $this->code_compta_fournisseur; + if (! empty($this->logo)) { $label.= '
';