Merge branch 'develop' of github.com:Dolibarr/dolibarr into develop

This commit is contained in:
Laurent Destailleur 2016-12-10 11:52:11 +01:00
commit f6c42053a4
10 changed files with 225 additions and 98 deletions

View File

@ -30,10 +30,10 @@
*/
class FormVentilation extends Form
{
private $options_cache = array();
/**
* Return select filter with date of transaction
*
@ -87,21 +87,22 @@ class FormVentilation extends Form
if ($usecache && ! empty($this->options_cache[$usecache]))
{
$options = $this->options_cache[$usecache];
$selected=$selectid;
}
else
{
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
$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 = " . $conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1";
$sql .= " ORDER BY aa.account_number";
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);
@ -109,16 +110,16 @@ class FormVentilation extends Form
}
$out = ajax_combobox($htmlname, $event);
$selected = 0;
while ($obj = $this->db->fetch_object($resql))
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;
// Try to guess if we have found default value
if ($select_in == 1) {
$select_value_in = $obj->account_number;
@ -132,19 +133,19 @@ class FormVentilation extends Form
//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, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
return $out;
}
@ -303,7 +304,7 @@ class FormVentilation extends Form
function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html')
{
global $conf;
$out_array = array();
$sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear";
@ -342,7 +343,7 @@ class FormVentilation extends Form
function selectjournal_accountancy_bookkepping($selected = '', $htmlname = 'journalid', $useempty = 0, $output_format = 'html')
{
global $conf,$langs;
$out_array = array();
$sql = "SELECT DISTINCT code_journal";

View File

@ -27,6 +27,7 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php';
$langs->load("compta");
$langs->load("banks");
@ -38,7 +39,7 @@ $refund=GETPOST("refund","int");
if (empty($refund)) $refund=0;
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
@ -179,8 +180,9 @@ if ($action == 'delete')
/*
* View
*/
llxHeader();
$title=$langs->trans("VAT") . " - " . $langs->trans("Card");
$help_url='';
llxHeader("",$title,$helpurl);
$form = new Form($db);
@ -236,13 +238,13 @@ if ($action == 'create')
print '</label>';
print '</div>';
print "<br>\n";
dol_fiche_head();
print '<table class="border" width="100%">';
print "<tr>";
print '<td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
print '<td class="titlefieldcreate fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
print $form->select_date($datep,"datep",'','','','add',1,1);
print '</td></tr>';
@ -263,7 +265,7 @@ if ($action == 'create')
if (! empty($conf->banque->enabled))
{
print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>';
print '<tr><td class="fieldrequired">'.$langs->trans("BankAccount").'</td><td>';
$form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1); // Affiche liste des comptes courant
print '</td></tr>';
}
@ -273,12 +275,12 @@ if ($action == 'create')
$form->select_types_paiements(GETPOST("type_payment"), "type_payment");
print "</td>\n";
print "</tr>";
// Number
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '<td><input name="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
// Other attributes
$parameters=array('colspan' => ' colspan="1"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
@ -296,20 +298,10 @@ if ($action == 'create')
print '</form>';
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
// View mode
if ($id)
{
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id;
$head[$h][1] = $langs->trans('Card');
$head[$h][2] = 'card';
$h++;
$head=vat_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("VATPayment"), 0, 'payment');
@ -317,7 +309,7 @@ if ($id)
print '<table class="border" width="100%">';
print "<tr>";
print '<td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
print '<td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="3">';
print $object->ref;
print '</td></tr>';
@ -325,19 +317,19 @@ if ($id)
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
print "<tr>";
print '<td>'.$langs->trans("DatePayment").'</td><td colspan="3">';
print '<td>'.$langs->trans("DatePayment").'</td><td>';
print dol_print_date($object->datep,'day');
print '</td></tr>';
print '<tr><td>';
print $form->editfieldkey("DateValue", 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day');
print '</td><td colspan="3">';
print '</td><td>';
print $form->editfieldval("DateValue", 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day');
//print dol_print_date($object->datev,'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="3">'.price($object->amount).'</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
if (! empty($conf->banque->enabled))
{
@ -348,7 +340,7 @@ if ($id)
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<td colspan="3">';
print '<td>';
print $bankline->getNomUrl(1,0,'showall');
print '</td>';
print '</tr>';
@ -356,14 +348,12 @@ if ($id)
}
// Other attributes
$parameters=array('colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
$reshook=$hookmanager->executeHooks('formObjectOptions','',$object,$action); // Note that $action and $object may have been modified by hook
print '</table>';
dol_fiche_end();
/*
* Action buttons
*/

View File

@ -671,4 +671,52 @@ class Tva extends CommonObject
return $result;
}
/**
* Informations of vat payment object
*
* @param int $id Id of vat payment
* @return int <0 if KO, >0 if OK
*/
function info($id)
{
$sql = "SELECT t.rowid, t.tms as datec, t.fk_user_creat";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " WHERE t.rowid = ".$id;
dol_syslog(get_class($this)."::info", LOG_DEBUG);
$result=$this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_creat) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_creat);
$this->user_creation = $cuser;
}
if ($obj->fk_user_modif) {
$muser = new User($this->db);
$muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->datec);
$this->import_key = $obj->import_key;
}
$this->db->free($result);
}
else
{
dol_print_error($this->db);
}
}
}

View File

@ -0,0 +1,64 @@
<?php
/* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/tva/info.php
* \ingroup tax
* \brief Page with info about vat
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("compta");
$langs->load("bills");
$id=GETPOST('id','int');
$action=GETPOST("action");
// Security check
$socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
/*
* View
*/
$title=$langs->trans("VAT") . " - " . $langs->trans("Info");
$help_url='';
llxHeader("",$title,$helpurl);
$object = new Tva($db);
$object->fetch($id);
$object->info($id);
$head = vat_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("VATPayment"), 0, 'payment');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
llxFooter();
$db->close();

View File

@ -42,9 +42,11 @@ if ($resql) // This can fail when class is used on old database (during migra
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]=$keyforelement;
if ($obj->type!='separate') {
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]=$keyforelement;
}
}
}
// End add axtra fields

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
*
* 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
@ -41,16 +41,6 @@ function loan_prepare_head($object)
$head[$tab][2] = 'card';
$tab++;
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1);
$head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id;
$head[$tab][1] = $langs->trans("Notes");
if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>';
$head[$tab][2] = 'note';
$tab++;
}
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
@ -68,6 +58,16 @@ function loan_prepare_head($object)
$head[$tab][2] = 'documents';
$tab++;
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1);
$head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id;
$head[$tab][1] = $langs->trans("Notes");
if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>';
$head[$tab][2] = 'note';
$tab++;
}
$head[$tab][0] = DOL_URL_ROOT.'/loan/info.php?id='.$object->id;
$head[$tab][1] = $langs->trans("Info");
$head[$tab][2] = 'info';

View File

@ -0,0 +1,57 @@
<?php
/* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/lib/vat.lib.php
* \ingroup tax
* \brief Library for tax module (VAT)
*/
/**
* Prepare array with list of tabs
*
* @param Object $object Object related to tabs
* @return array Array of tabs to show
*/
function vat_prepare_head($object)
{
global $db, $langs, $conf;
$tab = 0;
$head = array();
$head[$tab][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id;
$head[$tab][1] = $langs->trans('Card');
$head[$tab][2] = 'card';
$tab++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $tab,'vat');
$head[$tab][0] = DOL_URL_ROOT.'/compta/tva/info.php?id='.$object->id;
$head[$tab][1] = $langs->trans("Info");
$head[$tab][2] = 'info';
$tab++;
complete_head_from_modules($conf,$langs,$object,$head,$tab,'vat','remove');
return $head;
}

View File

@ -1427,26 +1427,6 @@ else
// Other attributes
//$cols = 3;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
// Public note
print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
print '<td valign="top">';
$doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
print '</td></tr>';
// Private note
if (empty($user->societe_id)) {
print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePrivate') . '</td>';
print '<td valign="top">';
$doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
print '</td></tr>';
}
print '</table>';
@ -1624,14 +1604,6 @@ else
print '</tr>';
*/
print '<tr>';
print '<td>'.$langs->trans("NotePublic").'</td>';
print '<td>'.$object->note_public.'</td>';
print '</tr>';
print '<tr>';
print '<td>'.$langs->trans("NotePrivate").'</td>';
print '<td>'.$object->note_private.'</td>';
print '</tr>';
// Amount
print '<tr>';
print '<td>'.$langs->trans("AmountHT").'</td>';
@ -2280,7 +2252,7 @@ print '<div class="fichehalfleft">';
* Generate documents
*/
if($user->rights->expensereport->export && $action != 'edit')
if($user->rights->expensereport->export && $action != 'create' && $action != 'edit')
{
$filename = dol_sanitizeFileName($object->ref);
$filedir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref);

View File

@ -300,7 +300,7 @@ if ($search_ref) $sql .= natural_search('cf.ref', $search_ref);
if ($search_refsupp) $sql.= natural_search("cf.ref_supplier", $search_refsupp);
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_request_author) $sql.= " AND u.login LIKE '%".$db->escape($search_request_author)."%'";
if ($search_request_author) $sql.=natural_search(array('u.lastname','u.firstname','u.login'), $search_request_author) ;
if ($billed != '' && $billed >= 0) $sql .= " AND cf.billed = ".$billed;
//Required triple check because statut=0 means draft filter
@ -379,7 +379,6 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
}
$sql.= $db->plimit($limit+1, $offset);
$resql = $db->query($sql);
if ($resql)
{
@ -503,7 +502,7 @@ if ($resql)
if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['cf.fk_author']['checked'])) print_liste_field_titre($arrayfields['cf.fk_author']['label'],$_SERVER["PHP_SELF"],"u.login","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['cf.fk_author']['checked'])) print_liste_field_titre($arrayfields['cf.fk_author']['label'],$_SERVER["PHP_SELF"],"cf.fk_author","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['cf.date_commande']['checked'])) print_liste_field_titre($arrayfields['cf.date_commande']['label'],$_SERVER["PHP_SELF"],"cf.date_commande","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['cf.date_delivery']['checked'])) print_liste_field_titre($arrayfields['cf.date_delivery']['label'],$_SERVER["PHP_SELF"],'cf.date_livraison','',$param, 'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['cf.total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.total_ht']['label'],$_SERVER["PHP_SELF"],"cf.total_ht","",$param,'align="right"',$sortfield,$sortorder);
@ -757,7 +756,7 @@ if ($resql)
$userstatic->firstname = $obj->firstname;
$userstatic->login = $obj->login;
$userstatic->photo = $obj->photo;
if (! empty($arrayfields['s.nom']['checked']))
if (! empty($arrayfields['u.login']['checked']))
{
print "<td>";
if ($userstatic->id) print $userstatic->getNomUrl(1);

View File

@ -399,12 +399,6 @@ if ($id > 0)
// Rate
print '<tr><td>'.$langs->trans("Rate").'</td><td>'.$object->rate.' %</td></tr>';
// Note Private
print '<tr><td>'.$langs->trans('NotePrivate').'</td><td>'.nl2br($object->note_private).'</td></tr>';
// Note Public
print '<tr><td>'.$langs->trans('NotePublic').'</td><td>'.nl2br($object->note_public).'</td></tr>';
// Accountancy account capital
print '<tr><td class="nowrap">';
print $langs->trans("LoanAccountancyCapitalCode");