diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index ce0bd4d3aa2..055451016e9 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,9 +18,9 @@ */ /** - * \file htdocs/accountancy/bookkeeping/card.php + * \file htdocs/accountancy/bookkeeping/card.php * \ingroup Advanced accountancy - * \brief Page to show book-entry + * \brief Page to show book-entry */ require '../../main.inc.php'; @@ -28,9 +28,14 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; // Langs $langs->load("accountancy"); +$langs->load("bank"); +$langs->load("bills"); +$langs->load("trips"); // Security check $id = GETPOST('id', 'int'); @@ -211,6 +216,7 @@ llxHeader(); $html = new Form($db); $formventilation = new FormVentilation($db); +$formaccountancy = new FormAccounting($db); /* * Confirmation to delete the command @@ -223,26 +229,6 @@ if ($action == 'delete') { if ($action == 'create') { print load_fiche_titre($langs->trans("CreateMvts")); - $code_journal_array = array ( - $conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL, - $conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL, - $conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL, - $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL => $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL, - $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL - ); - - $sql = 'SELECT DISTINCT accountancy_journal FROM ' . MAIN_DB_PREFIX . 'bank_account WHERE clos=0'; - $resql = $db->query($sql); - if (! $resql) { - setEventMessages($db->lasterror, null, 'errors'); - } else { - while ( $obj_bank = $db->fetch_object($resql) ) { - if (! empty($obj_bank->accountancy_journal)) { - $code_journal_array[$obj_bank->accountancy_journal] = $obj_bank->accountancy_journal; - } - } - } - $book = new BookKeeping($db); $next_num_mvt = $book->getNextNumMvt(); if (empty($next_num_mvt)) @@ -270,9 +256,10 @@ if ($action == 'create') { print ''; print ''; - print '' . $langs->trans("Codejournal") . ''; - print '' . $html->selectarray('code_journal', $code_journal_array) . ''; - print ''; + print ''.$langs->trans("AccountancyJournal").''; + print ''; + print $formaccountancy->select_journal('', 'code_journal', '', 0, '', 1, 1, 1, 1); + print ''; print ''; print '' . $langs->trans("Docref") . ''; @@ -308,25 +295,46 @@ if ($action == 'create') { print '
'; print ''; + print ''; print ''; print ''; print ''; + print ''; print ''; print ''; print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; print ''; + + $typelabel = $book->doc_type; + if ($typelabel == 'bank') { + $typelabel = $langs->trans('Bank'); + } + if ($typelabel == 'customer_invoice') { + $typelabel = $langs->trans('CustomerInvoice'); + } + if ($typelabel == 'supplier_invoice') { + $typelabel = $langs->trans('SupplierInvoice'); + } + if ($typelabel == 'expense_report') { + $typelabel = $langs->trans('ExpenseReport'); + } print ''; print ''; - print ''; + print ''; print ''; print '
' . $langs->trans("NumMvts") . '' . $book->piece_num . '
' . $langs->trans("Docdate") . '' . dol_print_date($book->doc_date, 'daytextshort') . '
' . $langs->trans("Codejournal") . '' . $book->code_journal . '
'; + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch('',$book->code_journal); + print $accountingjournal->getNomUrl(0,1,1,'',1); + print '
' . $langs->trans("Docref") . '' . $book->doc_ref . '
' . $langs->trans("Doctype") . '' . $book->doc_type . '' . $typelabel . '
'; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 75d0a63bf39..b382d855994 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2016 Alexandre Spangaro + * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2016 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; // Langs $langs->load("accountancy"); @@ -443,7 +444,11 @@ foreach ($object->lines as $line ) { print '' . $line->label_compte . ''; print '' . price($line->debit) . ''; print '' . price($line->credit) . ''; - print '' . $line->code_journal . ''; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch('',$line->code_journal); + print '' . $accountingjournal->getNomUrl(0,0,0,'',0) . ''; + print ''; print '' . img_edit() . ' '; print '' . img_delete() . ''; diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 064f56bddd6..168934ee5a5 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -48,64 +48,114 @@ class AccountingJournal extends CommonObject } /** - * Load an object from database - * - * @param int $id Id of record to load - * @return int <0 if KO, >0 if OK - */ - function fetch($id) + * Load an object from database + * + * @param int $rowid Id of record to load + * @param string $journal_code Journal code + * @return int <0 if KO, Id of record if OK and found + */ + function fetch($rowid = null, $journal_code = null) { - $sql = "SELECT rowid, code, label, nature, active"; - $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; - $sql.= " WHERE rowid = ".$id; - - dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ( $result ) + if ($rowid || $journal_code) { - $obj = $this->db->fetch_object($result); + $sql = "SELECT rowid, code, label, nature, active"; + $sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal"; + $sql .= " WHERE"; + if ($rowid) { + $sql .= " rowid = '" . $rowid . "'"; + } elseif ($journal_code) { + $sql .= " code = '" . $journal_code . "'"; + } - $this->id = $obj->rowid; + dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $obj = $this->db->fetch_object($result); - $this->code = $obj->code; - $this->ref = $obj->code; - $this->label = $obj->label; - $this->nature = $obj->nature; - $this->active = $obj->active; + if ($obj) { + $this->id = $obj->rowid; + $this->rowid = $obj->rowid; - return 1; - } - else - { - $this->error=$this->db->lasterror(); - return -1; + $this->code = $obj->code; + $this->ref = $obj->code; + $this->label = $obj->label; + $this->nature = $obj->nature; + $this->active = $obj->active; + + return $this->id; + } else { + return 0; + } + } + else + { + $this->error = "Error " . $this->db->lasterror(); + $this->errors[] = "Error " . $this->db->lasterror(); + } } + return -1; } /** * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @return string Chaine avec URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $withlabel 0=No label, 1=Include label of journal + * @param int $nourl 1=Disable url + * @param string $moretitle Add more text to title tooltip + * @param int $notooltip 1=Disable tooltip + * @return string String with URL */ - function getNomUrl($withpicto = 0) { - global $langs; + function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0) + { + global $langs, $conf, $user; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips $result = ''; - $link = ''; - $linkend = ''; + $url = DOL_URL_ROOT . '/accountancy/admin/journals_list.php?id=35'; $picto = 'billr'; + $label=''; - $label = $langs->trans("Show") . ': ' . $this->code . ' - ' . $this->label; + $label = '' . $langs->trans("ShowAccountingJournal") . ''; + if (! empty($this->code)) + $label .= '
'.$langs->trans('Code') . ': ' . $this->code; + if (! empty($this->label)) + $label .= '
'.$langs->trans('Label') . ': ' . $this->label; + if ($moretitle) $label.=' - '.$moretitle; - if ($withpicto) - $result .= ($link . img_object($label, $picto) . $linkend); - if ($withpicto && $withpicto != 2) - $result .= ' '; - if ($withpicto != 2) - $result .= $link . $this->code . ' - ' . $this->label . $linkend; + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowAccoutingJournal"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip"'; + } + + $linkstart=''; + $linkend=''; + + if ($nourl) + { + $linkstart = ''; + $linkclose = ''; + $linkend = ''; + } + + $label_link = $this->code; + if ($withlabel) $label_link .= ' - ' . $this->label; + + if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend; return $result; } @@ -136,19 +186,19 @@ class AccountingJournal extends CommonObject if ($mode == 0) { $prefix=''; - if ($nature == 9) return $langs->trans('AccountingJournalTypeHasNew'); - if ($nature == 3) return $langs->trans('AccountingJournalTypeBank'); - if ($nature == 2) return $langs->trans('AccountingJournalTypePurchase'); - if ($nature == 1) return $langs->trans('AccountingJournalTypeSale'); - if ($nature == 0) return $langs->trans('AccountingJournalTypeVariousOperation'); + if ($nature == 9) return $langs->trans('AccountingJournalType9'); + if ($nature == 4) return $langs->trans('AccountingJournalType4'); + if ($nature == 3) return $langs->trans('AccountingJournalType3'); + if ($nature == 2) return $langs->trans('AccountingJournalType2'); + if ($nature == 1) return $langs->trans('AccountingJournalType1'); } if ($mode == 1) { - if ($nature == 9) return $langs->trans('AccountingJournalTypeHasNew'); - if ($nature == 3) return $langs->trans('AccountingJournalTypeBank'); - if ($nature == 2) return $langs->trans('AccountingJournalTypePurchase'); - if ($nature == 1) return $langs->trans('AccountingJournalTypeSale'); - if ($nature == 0) return $langs->trans('AccountingJournalTypeVariousOperation'); + if ($nature == 9) return $langs->trans('AccountingJournalType9'); + if ($nature == 4) return $langs->trans('AccountingJournalType4'); + if ($nature == 3) return $langs->trans('AccountingJournalType3'); + if ($nature == 2) return $langs->trans('AccountingJournalType2'); + if ($nature == 1) return $langs->trans('AccountingJournalType1'); } } } diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 050e00e6278..36a4ec697e6 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -3,7 +3,7 @@ * Copyright (C) 2008-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2012-2013 Juanjo Menent - * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2013-2017 Philippe Grand * Copyright (C) 2013 Florian Henry * * This program is free software; you can redistribute it and/or modify @@ -436,7 +436,6 @@ if ($virtualdiffersfromphysical) print '
'; if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $var=false; print ''; print ''; print ''."\n"; @@ -444,8 +443,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''."\n"; // Example with a yes / no select - $var=!$var; - print ''; + print ''; print ''; print ''; print ''; // Example with a yes / no select - $var=!$var; - print ''; + print ''; print ''; print ''; print ''; // Example with a yes / no select - $var=!$var; - print ''; + print ''; print ''; print ''; print '
'.$langs->trans("Inventory").' 
'.$langs->trans("INVENTORY_DISABLE_VIRTUAL").' '; @@ -458,8 +456,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print '
'.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").' '; @@ -472,8 +469,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print '
'.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").' '; @@ -488,7 +484,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print '
'; } -$var=true; print ''; print ''; @@ -510,8 +505,6 @@ if (! empty($conf->fournisseur->enabled) && !empty($conf->global->STOCK_CALCULAT print "\n\n"; } - - print ''; print ''; print '\n"; print "\n"; - - print ''; print ''; diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index ca2b7b5c76f..b68da6fd597 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -112,8 +112,7 @@ if ($catname || $id > 0) $var=true; foreach ($cats as $cat) { - $var = ! $var; - print "\t\n"; + print "\t".''."\n"; print "\t\t\n"; if (count($cats) > 0) { - $var=true; foreach ($cats as $cat) - { - - print "\t\n"; + { + print "\t".''."\n"; print "\t\t".'\n"; @@ -360,11 +358,9 @@ if ($object->type == Categorie::TYPE_PRODUCT) if (count($prods) > 0) { - $var=true; foreach ($prods as $prod) - { - - print "\t\n"; + { + print "\t".''."\n"; print '\n"; @@ -411,12 +407,9 @@ if ($object->type == Categorie::TYPE_SUPPLIER) if (count($socs) > 0) { - $var=true; foreach ($socs as $soc) - { - - print "\t\n"; - + { + print "\t".''."\n"; print '\n"; @@ -464,14 +457,13 @@ if($object->type == Categorie::TYPE_CUSTOMER) if (count($socs) > 0) { $i = 0; - $var=true; foreach ($socs as $key => $soc) { if ($user->societe_id > 0 && $soc->id != $user->societe_id) continue; // External user always see only themself $i++; - print "\t\n"; + print "\t".''."\n"; print '\n"; @@ -520,11 +512,9 @@ if ($object->type == Categorie::TYPE_MEMBER) if (count($prods) > 0) { - $var=true; foreach ($prods as $key => $member) - { - - print "\t\n"; + { + print "\t".''."\n"; print '\n"; + print "\t".''."\n"; print '\n"; @@ -629,11 +618,9 @@ if ($object->type == Categorie::TYPE_ACCOUNT) if (count($accounts) > 0) { - $var=true; foreach ($accounts as $key => $account) - { - - print "\t\n"; + { + print "\t".''."\n"; print '\n"; @@ -684,11 +671,9 @@ if ($object->type == Categorie::TYPE_PROJECT) if (count($projects) > 0) { - $var=true; foreach ($projects as $key => $project) - { - - print "\t\n"; + { + print "\t".''."\n"; print '\n"; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index aae1398109d..b933289be4f 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -788,8 +788,7 @@ if ($id > 0) while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); - $var = ! $var; - print ""; + print ''; print '"; + print ''; print ''; - print ''; + print ''; } // Other attributes @@ -980,8 +992,10 @@ else // Accountancy journal if (! empty($conf->accounting->enabled)) { - print ''; - print ''; + print ''; + print ''; } print '
'.$langs->trans("UserWarehouseAutoCreate").''; @@ -524,8 +517,6 @@ print ''; print "
'.$langs->trans("AllowAddLimitStockByWarehouse").'
"; $categstatic->id=$cat->id; $categstatic->ref=$cat->label; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index ebd5fa9991c..d04d0baebd2 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -289,11 +289,9 @@ else print "
'; print "".$cat->label.""; print "
'; print $prod->getNomUrl(1); print "
'; print $soc->getNomUrl(1); print "
'; print $soc->getNomUrl(1); print "
'; $member->ref=$member->login; print $member->getNomUrl(1,0); @@ -574,12 +564,11 @@ if($object->type == Categorie::TYPE_CONTACT) if (count($contacts) > 0) { $i = 0; - $var=true; foreach ($contacts as $key => $contact) { $i++; - print "\t
'; print $contact->getNomUrl(1,'category'); print "
'; print $account->getNomUrl(1,0); print "
'; print $project->getNomUrl(1,0); print "
'; $sendingstatic->id = $objp->id; $sendingstatic->ref = $objp->ref; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 4bd999b1d5a..24bccbf9c9c 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Jean-François Ferry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -479,7 +479,6 @@ if (! empty($conf->societe->enabled) && $user->rights->societe->lire) $resql = $db->query($sql); if ($resql) { - $var=false; $num = $db->num_rows($resql); $i = 0; @@ -544,7 +543,6 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->societe->lire) $result = $db->query($sql); if ($result) { - $var=false; $num = $db->num_rows($result); $i = 0; @@ -633,11 +631,10 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) // TO $staticcontrat=new Contrat($db); - $var=false; while ($i < $num) { $obj = $db->fetch_object($resql); - print "
contratid."\">".img_object($langs->trans("ShowContract","contract"), 'contract')." ".$obj->ref."
contratid."\">".img_object($langs->trans("ShowContract","contract"), "contract")." ".$obj->ref."'; $companystatic->id=$objp->rowid; $companystatic->name=$objp->name; @@ -686,8 +683,6 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) $i = 0; if ($num > 0) { - $var=true; - print ''; print ''; @@ -785,8 +780,6 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $i = 0; if ($num > 0) { - $var=true; - print '
'.$langs->trans("ProposalsOpened").' '.$num.'
'; print ''; diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index abb24b8ffa4..5c74c8374a0 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -293,7 +293,6 @@ print ''; print ''; $oldyear=0; -$var=true; foreach ($data as $val) { $year = $val['year']; @@ -301,7 +300,7 @@ foreach ($data as $val) { // If we have empty year $oldyear--; - print ''; + print ''; print ''; print ''; print ''; @@ -311,7 +310,7 @@ foreach ($data as $val) print ''; print ''; } - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 5b3bb3a58fe..804d2c5511d 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -36,7 +36,9 @@ require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; $langs->load("banks"); $langs->load("bills"); @@ -99,7 +101,7 @@ if ($action == 'add') $account_number = GETPOST('account_number','alpha'); if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; } - $object->accountancy_journal = trim($_POST["accountancy_journal"]); + $object->fk_accountancy_journal = trim($_POST["fk_accountancy_journal"]); $object->solde = $_POST["solde"]; $object->date_solde = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); @@ -197,7 +199,7 @@ if ($action == 'update') $account_number = GETPOST('account_number', 'int'); if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; } - $object->accountancy_journal = trim($_POST["accountancy_journal"]); + $object->fk_accountancy_journal = trim($_POST["fk_accountancy_journal"]); $object->currency_code = trim($_POST["account_currency_code"]); @@ -278,6 +280,7 @@ $form = new Form($db); $formbank = new FormBank($db); $formcompany = new FormCompany($db); if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); +if (! empty($conf->accounting->enabled)) $formaccountancy2 = New FormAccounting($db); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; @@ -534,7 +537,9 @@ if ($action == 'create') if (! empty($conf->accounting->enabled)) { print ''; - print ''; + print ''; } print '
'.$langs->trans("OrdersOpened").' '.$num.'
%
0?'&userid='.$userid:'').'">'.$oldyear.'0
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].''.round($val['nb_diff']).'
'.$langs->trans("AccountancyJournal").'accountancy_journal).'">
'; + print $formaccountancy2->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 1, 1); + print '
'; @@ -677,7 +682,14 @@ else if (! empty($conf->accounting->enabled)) { print '
'.$langs->trans("AccountancyJournal").''.$object->accountancy_journal.'
'; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($object->fk_accountancy_journal); + + print $accountingjournal->getNomUrl(0,1,1,'',1); + + print '
'.$langs->trans("AccountancyJournal").'accountancy_journal).'">
'.$langs->trans("AccountancyJournal").''; + print $formaccountancy2->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 1, 1); + print '
'; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 897fd5de496..4f28028f34d 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -160,7 +160,7 @@ class Account extends CommonObject * @var string */ public $account_number; - public $accountancy_journal; + public $fk_accountancy_journal; /** * Currency code @@ -471,9 +471,9 @@ class Account extends CommonObject if ($accline->insert() > 0) { - if ($categorie) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_account ("; - $sql .= "fk_account, fk_categorie"; + if ($categorie>0) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; + $sql .= "lineid, fk_categ; $sql .= ") VALUES ("; $sql .= " ".$accline->id.", ".$categorie; $sql .= ")"; @@ -545,7 +545,7 @@ class Account extends CommonObject $sql.= ", label"; $sql.= ", entity"; $sql.= ", account_number"; - $sql.= ", accountancy_journal"; + $sql.= ", fk_accountancy_journal"; $sql.= ", bank"; $sql.= ", code_banque"; $sql.= ", code_guichet"; @@ -569,7 +569,7 @@ class Account extends CommonObject $sql.= ", '".$this->db->escape($this->label)."'"; $sql.= ", ".$conf->entity; $sql.= ", '".$this->db->escape($this->account_number)."'"; - $sql.= ", '".$this->db->escape($this->accountancy_journal)."'"; + $sql.= ", '".$this->db->escape($this->fk_accountancy_journal)."'"; $sql.= ", '".$this->db->escape($this->bank)."'"; $sql.= ", '".$this->code_banque."'"; $sql.= ", '".$this->code_guichet."'"; @@ -702,7 +702,7 @@ class Account extends CommonObject $sql.= ",rappro = ".$this->rappro; $sql.= ",url = ".($this->url?"'".$this->url."'":"null"); $sql.= ",account_number = '".$this->account_number."'"; - $sql.= ",accountancy_journal = '".$this->accountancy_journal."'"; + $sql.= ",fk_accountancy_journal = '".$this->fk_accountancy_journal."'"; $sql.= ",bank = '".$this->db->escape($this->bank)."'"; $sql.= ",code_banque='".$this->code_banque."'"; @@ -847,7 +847,7 @@ class Account extends CommonObject $sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,"; $sql.= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,"; $sql.= " ba.domiciliation, ba.proprio, ba.owner_address, ba.state_id, ba.fk_pays as country_id,"; - $sql.= " ba.account_number, ba.accountancy_journal, ba.currency_code,"; + $sql.= " ba.account_number, ba.fk_accountancy_journal, ba.currency_code,"; $sql.= " ba.min_allowed, ba.min_desired, ba.comment,"; $sql.= " ba.datec as date_creation, ba.tms as date_update,"; $sql.= ' c.code as country_code, c.label as country,'; @@ -897,7 +897,7 @@ class Account extends CommonObject $this->country = $obj->country; $this->account_number = $obj->account_number; - $this->accountancy_journal = $obj->accountancy_journal; + $this->fk_accountancy_journal = $obj->fk_accountancy_journal; $this->currency_code = $obj->currency_code; $this->account_currency_code = $obj->currency_code; @@ -1259,7 +1259,7 @@ class Account extends CommonObject include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $langs->load("accountancy"); $label .= '
' . $langs->trans('AccountAccounting') . ': ' . length_accountg($this->account_number); - $label .= '
' . $langs->trans('AccountancyJournal') . ': ' . $this->accountancy_journal; + $label .= '
' . $langs->trans('AccountancyJournal') . ': ' . $this->fk_accountancy_journal; } $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index f98f9b9cb49..f5d4fee1fc0 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -29,6 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; $langs->load("banks"); $langs->load("categories"); @@ -88,7 +90,7 @@ $arrayfields=array( 'b.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'b.number'=>array('label'=>$langs->trans("AccountIdShort"), 'checked'=>1), 'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>$conf->accountancy->enabled), - 'b.accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>$conf->accountancy->enabled), + 'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>$conf->accountancy->enabled), 'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1), 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), @@ -141,7 +143,7 @@ $title=$langs->trans('BankAccounts'); // Load array of financial accounts (opened by default) $accounts = array(); -$sql = "SELECT rowid, label, courant, rappro, account_number, accountancy_journal, datec as date_creation, tms as date_update"; +$sql = "SELECT rowid, label, courant, rappro, account_number, fk_accountancy_journal, datec as date_creation, tms as date_update"; // 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 @@ -323,7 +325,7 @@ if (! empty($arrayfields['b.account_number']['checked'])) print ''; } // Accountancy journal -if (! empty($arrayfields['b.accountancy_journal']['checked'])) +if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) { print ''; print ''; @@ -403,7 +405,7 @@ if (! empty($arrayfields['b.label']['checked'])) print_liste_field_titr if (! empty($arrayfields['accountype']['checked'])) print_liste_field_titre($arrayfields['accountype']['label'],$_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'],$_SERVER["PHP_SELF"],'b.number','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'],$_SERVER["PHP_SELF"],'b.account_number','',$param,'',$sortfield,$sortorder); -if (! empty($arrayfields['b.accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.accountancy_journal']['label'],$_SERVER["PHP_SELF"],'b.accountancy_journal','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'],$_SERVER["PHP_SELF"],'b.fk_accountancy_journal','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -488,16 +490,23 @@ foreach ($accounts as $key=>$type) if (! empty($arrayfields['b.account_number']['checked'])) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - print ''.length_accountg($acc->account_number).''; + + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$acc->account_number); + + print ''.length_accountg($accountingaccount->getNomUrl(0,1,1,'',1)).''; + if (! $i) $totalarray['nbfield']++; } // Accountancy journal - if (! empty($arrayfields['b.accountancy_journal']['checked'])) + if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - print ''.length_accountg($acc->accountancy_journal).''; - if (! $i) $totalarray['nbfield']++; + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($acc->fk_accountancy_journal); + + print ''.$accountingjournal->getNomUrl(0,1,1,'',1).''; + if (! $i) $totalarray['nbfield']++; } // Transactions to reconcile diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index 6c4b41333f1..abf6d23d22e 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -89,7 +89,7 @@ $variousstatic = new PaymentVarious($db); $accountstatic = new Account($db); $sql = "SELECT v.rowid, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank,"; -$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel,"; +$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id"; @@ -217,7 +217,7 @@ if ($result) $accountstatic->ref=$obj->bref; $accountstatic->number=$obj->bnumber; $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->accountancy_journal=$obj->accountancy_journal; + $accountstatic->fk_accountancy_journal=$obj->fk_accountancy_journal; $accountstatic->label=$obj->blabel; print $accountstatic->getNomUrl(1); } diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index e1bf1645de0..a87b566d0d6 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -25,12 +25,14 @@ /** * Class to manage generation of HTML components for accounting management */ -class FormAccounting +class FormAccounting extends Form { + + private $options_cache = array(); + var $db; var $error; - /** * Constructor * @@ -41,6 +43,89 @@ class FormAccounting $this->db = $db; } + /** + * Return list of journals with label by nature + * + * @param string $selectid Preselected pcg_type + * @param string $htmlname Name of field in html form + * @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) + * @param int $showempty Add an empty field + * @param array $event Event options + * @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code + * @param int $select_out Set value returned by select. 0=rowid (default), 1=code + * @param string $morecss More css non HTML object + * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. + * + * @return string String with HTML select + */ + function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') + { + global $conf; + + $out = ''; + + $options = array(); + if ($usecache && ! empty($this->options_cache[$usecache])) + { + $options = $this->options_cache[$usecache]; + $selected=$selectid; + } + else + { + $sql = "SELECT rowid, code, label, nature, entity, active"; + $sql.= " FROM " . MAIN_DB_PREFIX . "accounting_journal"; + $sql.= " WHERE active = 1"; + $sql.= " AND entity = ".$conf->entity; + //if ($nature && is_numeric($nature)) $sql .= " AND nature = ".$nature; + $sql.= " ORDER BY code"; + + dol_syslog(get_class($this) . "::select_journal", LOG_DEBUG); + $resql = $this->db->query($sql); + + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_journal ".$this->error, LOG_ERR); + return -1; + } + + $out = ajax_combobox($htmlname, $event); + + $selected = 0; + while ($obj = $this->db->fetch_object($resql)) + { + $label = $obj->code . ' - ' . $obj->label; + + $select_value_in = $obj->rowid; + $select_value_out = $obj->rowid; + + // Try to guess if we have found default value + if ($select_in == 1) { + $select_value_in = $obj->code; + } + if ($select_out == 1) { + $select_value_out = $obj->code; + } + // Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid + if ($selectid != '' && $selectid == $select_value_in) { + //var_dump("Found ".$selectid." ".$select_value_in); + $selected = $select_value_out; + } + + $options[$select_value_out] = $label; + } + $this->db->free($resql); + + if ($usecache) + { + $this->options_cache[$usecache] = $options; + } + } + + $out .= Form::selectarray($htmlname, $options, $select, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); + + return $out; + } + /** * Return list of accounting category. * Use mysoc->country_id or mysoc->country_code so they must be defined. diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 8d90892cfb6..5dada97908b 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -126,7 +126,9 @@ class FormFile { $out .= ''; } - $out .= 'global->MAIN_USE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout == 'phone')?' name="userfile"':' name="userfile[]" multiple'); $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':''); $out .= '>'; $out .= ' '; diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 7d0fe1a41e6..e050bf8e3eb 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -131,18 +131,15 @@ class doc_generic_project_odt extends ModelePDFProjects ); // Retrieve extrafields - if (is_array($object->array_options) && count($object->array_options)) - { - $extrafieldkey=$object->element; + $extrafieldkey=$object->element; - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); - $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); - $object->fetch_optionals($object->id,$extralabels); - - $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); - } + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); + $object->fetch_optionals($object->id,$extralabels); + $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); + return $resarray; } @@ -185,39 +182,50 @@ class doc_generic_project_odt extends ModelePDFProjects function get_substitutionarray_project_contacts($contact,$outputlangs) { global $conf; + $pc='projcontacts_'; // prefix to avoid typos - // adding phone numbers if external - $phone_pro = ''; - $phone_perso = ''; - $phone_mobile = ''; + $ret = array( + $pc.'id'=>$contact['id'], + $pc.'rowid'=>$contact['rowid'], + $pc.'role'=>$contact['libelle'], + $pc.'lastname'=>$contact['lastname'], + $pc.'firstname'=>$contact['firstname'], + $pc.'civility'=>$contact['civility'], + $pc.'fullcivname'=>$contact['fullname'], + $pc.'socname'=>$contact['socname'], + $pc.'email'=>$contact['email'] + ); - $ct = new Contact($this->db); if ($contact['source']=='external') { + $ret[$pc.'isInternal'] = ''; // not internal + $ct = new Contact($this->db); $ct->fetch($contact['id']); - $phone_pro = $ct->phone_pro; - $phone_perso = $ct->phone_perso; - $phone_mobile = $ct->phone_mobile; + $ret[$pc.'phone_pro'] = $ct->phone_pro; + $ret[$pc.'phone_perso'] = $ct->phone_perso; + $ret[$pc.'phone_mobile'] = $ct->phone_mobile; + + // fetch external user extrafields + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($ct->table_element, true); + $extrafields_num = $ct->fetch_optionals($ct->id, $extralabels); + //dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG); + foreach($ct->array_options as $efkey => $efval) { + dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG); + $ret[$pc.$efkey] = $efval; // add nothing else because it already comes as 'options_XX' + } } elseif ($contact['source']=='internal') { + $ret[$pc.'isInternal'] = '1'; // this is an internal user + $ct = new User($this->db); $ct->fetch($contact['id']); - $phone_pro = $ct->office_phone; - $phone_mobile = $ct->user_mobile; + $ret[$pc.'phone_pro'] = $ct->office_phone; + $ret[$pc.'phone_perso'] = ''; + $ret[$pc.'phone_mobile'] = $ct->user_mobile; + // do internal users have extrafields ? } - - return array( - 'projcontacts_id'=>$contact['id'], - 'projcontacts_rowid'=>$contact['rowid'], - 'projcontacts_role'=>$contact['libelle'], - 'projcontacts_lastname'=>$contact['lastname'], - 'projcontacts_firstname'=>$contact['firstname'], - 'projcontacts_fullcivname'=>$contact['fullname'], - 'projcontacts_socname'=>$contact['socname'], - 'projcontacts_email'=>$contact['email'], - 'projcontacts_phone_pro'=>$phone_pro, - 'projcontacts_phone_perso'=>$phone_perso, - 'projcontacts_phone_mobile'=>$phone_mobile - ); + return $ret; } /** diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 2942a8903ab..d9912edfca1 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -326,7 +326,7 @@ class Fichinter extends CommonObject function fetch($rowid,$ref='') { $sql = "SELECT f.rowid, f.ref, f.description, f.fk_soc, f.fk_statut,"; - $sql.= " f.datec, f.dateo, f.datee, f.datet,"; + $sql.= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,"; $sql.= " f.date_valid as datev,"; $sql.= " f.tms as datem,"; $sql.= " f.duree, f.fk_projet, f.note_public, f.note_private, f.model_pdf, f.extraparams, fk_contrat"; @@ -360,6 +360,8 @@ class Fichinter extends CommonObject $this->modelpdf = $obj->model_pdf; $this->fk_contrat = $obj->fk_contrat; + $this->user_creation= $obj->fk_user_author; + $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; @@ -537,7 +539,30 @@ class Fichinter extends CommonObject } } - + /** + * Returns amount based on user thm + * + * @return float amount + */ + function getAmount() { + global $db; + + $amount = 0; + + $this->author = new User($db); + $this->author->fetch($this->user_creation); + + $thm = $this->author->thm; + + foreach($this->lines as &$line) { + + $amount+=$line->qty * $thm; + + } + + return $amount; + } + /** * Returns the label status * diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 1798eb19059..496c4660895 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -640,7 +640,7 @@ class FactureFournisseur extends CommonInvoice function fetch_lines() { $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx'; - $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 '; + $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn '; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; $sql.= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc'; @@ -649,6 +649,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ' WHERE fk_facture_fourn='.$this->id; $sql.= ' ORDER BY f.rang, f.rowid'; + dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $resql_rows = $this->db->query($sql); if ($resql_rows) @@ -687,6 +688,7 @@ class FactureFournisseur extends CommonInvoice $line->total_tva = $obj->total_tva; $line->total_localtax1 = $obj->total_localtax1; $line->total_localtax2 = $obj->total_localtax2; + $line->fk_facture_fourn = $obj->fk_facture_fourn; $line->total_ttc = $obj->total_ttc; $line->fk_product = $obj->fk_product; $line->product_type = $obj->product_type; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index b13bd6e649a..58ad642266e 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -264,4 +264,11 @@ UPDATE llx_accounting_journal SET nature = 3 where code = 'AC' and nature = 2; UPDATE llx_accounting_journal SET nature = 4 where (code = 'BK' or code = 'BQ') and nature = 3; +ALTER TABLE llx_bank_account CHANGE COLUMN accountancy_journal fk_accountancy_journal integer; +--ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); + + + + + diff --git a/htdocs/install/mysql/tables/llx_accounting_journal.sql b/htdocs/install/mysql/tables/llx_accounting_journal.sql index a435de3cd80..348654b56dc 100644 --- a/htdocs/install/mysql/tables/llx_accounting_journal.sql +++ b/htdocs/install/mysql/tables/llx_accounting_journal.sql @@ -23,6 +23,6 @@ create table llx_accounting_journal entity integer DEFAULT 1, code varchar(32) NOT NULL, label varchar(128) NOT NULL, - nature smallint DEFAULT 0 NOT NULL, -- type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) + nature smallint DEFAULT 1 NOT NULL, -- type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new) active smallint DEFAULT 0 )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_bank_account.key.sql b/htdocs/install/mysql/tables/llx_bank_account.key.sql index c91762a322e..986ca7ea550 100644 --- a/htdocs/install/mysql/tables/llx_bank_account.key.sql +++ b/htdocs/install/mysql/tables/llx_bank_account.key.sql @@ -19,3 +19,5 @@ ALTER TABLE llx_bank_account ADD UNIQUE uk_bank_account_label (label,entity); + +-- ALTER TABLE llx_bank_account ADD CONSTRAINT bank_fk_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); diff --git a/htdocs/install/mysql/tables/llx_bank_account.sql b/htdocs/install/mysql/tables/llx_bank_account.sql index 7730ab79ef6..6db2857ddae 100644 --- a/htdocs/install/mysql/tables/llx_bank_account.sql +++ b/htdocs/install/mysql/tables/llx_bank_account.sql @@ -24,39 +24,39 @@ create table llx_bank_account ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - datec datetime, - tms timestamp, - ref varchar(12) NOT NULL, - label varchar(30) NOT NULL, - entity integer DEFAULT 1 NOT NULL, -- multi company id - fk_user_author integer, - fk_user_modif integer, - bank varchar(60), - code_banque varchar(128), - code_guichet varchar(6), - number varchar(255), - cle_rib varchar(5), - bic varchar(11), - iban_prefix varchar(34), -- full iban. 34 according to ISO 13616 - country_iban varchar(2), -- deprecated - cle_iban varchar(2), - domiciliation varchar(255), - state_id integer DEFAULT NULL, - fk_pays integer NOT NULL, - proprio varchar(60), - owner_address varchar(255), - courant smallint DEFAULT 0 NOT NULL, - clos smallint DEFAULT 0 NOT NULL, - rappro smallint DEFAULT 1, - url varchar(128), - account_number varchar(32), -- bank accountancy number - accountancy_journal varchar(16) DEFAULT NULL, -- bank accountancy journal - currency_code varchar(3) NOT NULL, - min_allowed integer DEFAULT 0, - min_desired integer DEFAULT 0, - comment text, -- TODO rename in note_private - note_public text, - model_pdf varchar(255), - import_key varchar(14) + rowid integer AUTO_INCREMENT PRIMARY KEY, + datec datetime, + tms timestamp, + ref varchar(12) NOT NULL, + label varchar(30) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_user_author integer, + fk_user_modif integer, + bank varchar(60), + code_banque varchar(128), + code_guichet varchar(6), + number varchar(255), + cle_rib varchar(5), + bic varchar(11), + iban_prefix varchar(34), -- full iban. 34 according to ISO 13616 + country_iban varchar(2), -- deprecated + cle_iban varchar(2), + domiciliation varchar(255), + state_id integer DEFAULT NULL, + fk_pays integer NOT NULL, + proprio varchar(60), + owner_address varchar(255), + courant smallint DEFAULT 0 NOT NULL, + clos smallint DEFAULT 0 NOT NULL, + rappro smallint DEFAULT 1, + url varchar(128), + account_number varchar(32), -- bank accountancy number + fk_accountancy_journal integer, -- bank accountancy journal + currency_code varchar(3) NOT NULL, + min_allowed integer DEFAULT 0, + min_desired integer DEFAULT 0, + comment text, -- TODO rename in note_private + note_public text, + model_pdf varchar(255), + import_key varchar(14) )ENGINE=innodb; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 9eb4135397f..92fe19676c0 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -61,7 +61,8 @@ ChangeAndLoad=Change and load Addanaccount=Add an accounting account AccountAccounting=Accounting account AccountAccountingShort=Account -ShowAccoutingAccount=Show accounting account +ShowAccountingAccount=Show accounting account +ShowAccountingJournal=Show accounting journal AccountAccountingSuggest=Accounting account suggested MenuDefaultAccounts=Default accounts MenuVatAccounts=Vat accounts diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 09a3fecc4bd..02bf6c5a9ba 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -333,7 +333,8 @@ $listofreferent=array( 'class'=>'Fichinter', 'table'=>'fichinter', 'datefieldname'=>'date_valid', - 'disableamount'=>1, + 'disableamount'=>0, + 'margin'=>'minus', 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, 'lang'=>'interventions', 'buttonnew'=>'AddIntervention', @@ -559,6 +560,7 @@ foreach ($listofreferent as $key => $value) if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); if ($tablename == 'don' || $tablename == 'chargesociales') $total_ht_by_line=$element->amount; elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty); + else if($tablename == 'fichinter') $total_ht_by_line=$element->getAmount(); elseif ($tablename == 'projet_task') { if ($idofelementuser) @@ -583,6 +585,7 @@ foreach ($listofreferent as $key => $value) if ($qualifiedfortotal) $total_ht = $total_ht + $total_ht_by_line; if ($tablename == 'don' || $tablename == 'chargesociales') $total_ttc_by_line=$element->amount; + else if($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty); elseif ($tablename == 'projet_task') { @@ -948,6 +951,7 @@ foreach ($listofreferent as $key => $value) $total_ht_by_line=null; $othermessage=''; if ($tablename == 'don' || $tablename == 'chargesociales') $total_ht_by_line=$element->amount; + else if($tablename == 'fichinter') $total_ht_by_line=$element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty); elseif (in_array($tablename, array('projet_task'))) { @@ -988,6 +992,7 @@ foreach ($listofreferent as $key => $value) { $total_ttc_by_line=null; if ($tablename == 'don' || $tablename == 'chargesociales') $total_ttc_by_line=$element->amount; + else if($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty); elseif ($tablename == 'projet_task') {