Merge pull request #7938 from aspangaro/7.0-b3

FIX : Debug various_payment
This commit is contained in:
Laurent Destailleur 2017-12-10 20:59:45 +01:00 committed by GitHub
commit 3415ce4664
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 118 additions and 75 deletions

View File

@ -160,6 +160,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
$search_date_creation_end = ''; $search_date_creation_end = '';
$search_date_modification_start = ''; $search_date_modification_start = '';
$search_date_modification_end = ''; $search_date_modification_end = '';
$search_debit = '';
$search_credit = '';
} }
// Must be after the remove filter action, before the export. // Must be after the remove filter action, before the export.
@ -248,6 +250,14 @@ if (! empty($search_date_modification_end)) {
$tmp=dol_getdate($search_date_modification_end); $tmp=dol_getdate($search_date_modification_end);
$param .= '&date_modification_endmonth=' . $tmp['mon'] . '&date_modification_endday=' . $tmp['mday'] . '&date_modification_endyear=' . $tmp['year']; $param .= '&date_modification_endmonth=' . $tmp['mon'] . '&date_modification_endday=' . $tmp['mday'] . '&date_modification_endyear=' . $tmp['year'];
} }
if (! empty($search_debit)) {
$filter['t.debit'] = $search_debit;
$param .= '&search_debit=' . $search_debit;
}
if (! empty($search_credit)) {
$filter['t.credit'] = $search_credit;
$param .= '&search_credit=' . $search_credit;
}
if ($action == 'delbookkeeping') { if ($action == 'delbookkeeping') {
@ -507,12 +517,16 @@ if (! empty($arrayfields['t.label_operation']['checked']))
// Debit // Debit
if (! empty($arrayfields['t.debit']['checked'])) if (! empty($arrayfields['t.debit']['checked']))
{ {
print '<td class="liste_titre center">&nbsp;</td>'; print '<td class="liste_titre" align="right">';
print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
print '</td>';
} }
// Credit // Credit
if (! empty($arrayfields['t.credit']['checked'])) if (! empty($arrayfields['t.credit']['checked']))
{ {
print '<td class="liste_titre center">&nbsp;</td>'; print '<td class="liste_titre" align="right">';
print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
print '</td>';
} }
// Code journal // Code journal
if (! empty($arrayfields['t.code_journal']['checked'])) if (! empty($arrayfields['t.code_journal']['checked']))

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com> /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -266,12 +266,12 @@ class PaymentVarious extends CommonObject
$this->fk_user_modif=''; $this->fk_user_modif='';
} }
/** /**
* Create in database * Create in database
* *
* @param User $user User that create * @param User $user User that create
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function create($user) function create($user)
{ {
global $conf,$langs; global $conf,$langs;
@ -338,6 +338,7 @@ class PaymentVarious extends CommonObject
if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'";
$sql.= ", '".$this->db->escape($this->label)."'"; $sql.= ", '".$this->db->escape($this->label)."'";
$sql.= ", '".$this->db->escape($this->accountancy_code)."'"; $sql.= ", '".$this->db->escape($this->accountancy_code)."'";
$sql.= ", ".($this->fk_project > 0? $this->fk_project : 0);
$sql.= ", ".$user->id; $sql.= ", ".$user->id;
$sql.= ", '".$this->db->idate($now)."'"; $sql.= ", '".$this->db->idate($now)."'";
$sql.= ", NULL"; $sql.= ", NULL";
@ -407,10 +408,10 @@ class PaymentVarious extends CommonObject
} }
} }
// Call trigger // Call trigger
$result=$this->call_trigger('PAYMENT_VARIOUS_CREATE',$user); $result=$this->call_trigger('PAYMENT_VARIOUS_CREATE',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
else $error++; else $error++;
@ -437,8 +438,8 @@ class PaymentVarious extends CommonObject
/** /**
* Update link between payment various and line generate into llx_bank * Update link between payment various and line generate into llx_bank
* *
* @param int $id_bank Id bank account * @param int $id_bank Id bank account
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update_fk_bank($id_bank) function update_fk_bank($id_bank)
{ {
@ -517,18 +518,18 @@ class PaymentVarious extends CommonObject
/** /**
* Send name clicable (with possibly the picto) * Send name clicable (with possibly the picto)
* *
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param string $option link option * @param string $option link option
* @return string Chaine with URL * @return string Chaine with URL
*/ */
function getNomUrl($withpicto=0,$option='') function getNomUrl($withpicto=0,$option='')
{ {
global $langs; global $langs;
$result=''; $result='';
$label=$langs->trans("ShowVariousPayment").': '.$this->ref; $label=$langs->trans("ShowVariousPayment").': '.$this->ref;
$linkstart = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkstart = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>'; $linkend='</a>';
$result .= $linkstart; $result .= $linkstart;
@ -542,8 +543,8 @@ class PaymentVarious extends CommonObject
/** /**
* Information on record * Information on record
* *
* @param int $id Id of record * @param int $id Id of record
* @return void * @return void
*/ */
function info($id) function info($id)
{ {

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com> /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,9 +16,9 @@
*/ */
/** /**
* \file htdocs/compta/bank/various_expenses/card.php * \file htdocs/compta/bank/various_expenses/card.php
* \ingroup bank * \ingroup bank
* \brief Page of various expenses * \brief Page of various expenses
*/ */
require '../../../main.inc.php'; require '../../../main.inc.php';
@ -40,8 +40,8 @@ $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy"));
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha'); $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
$accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0;
$label=GETPOST("label","alpha"); $label=GETPOST("label","alpha");

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com> /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -17,9 +17,9 @@
*/ */
/** /**
* \file htdocs/compta/bank/various_payment/document.php * \file htdocs/compta/bank/various_payment/document.php
* \ingroup banque * \ingroup bank
* \brief Page of linked files onto various_payment * \brief Page of linked files onto various payment
*/ */
require '../../../main.inc.php'; require '../../../main.inc.php';
@ -28,9 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
$langs->load("other"); $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy"));
$langs->load("bank");
$langs->load("companies");
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
@ -38,9 +36,9 @@ $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha'); $confirm = GETPOST('confirm','alpha');
// Security check // Security check
$socid = GETPOST("socid","int");
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'salaries', $id, ''); $result = restrictedArea($user, 'banque', '', '', '');
// Get parameters // Get parameters
$sortfield = GETPOST('sortfield','alpha'); $sortfield = GETPOST('sortfield','alpha');
@ -74,8 +72,9 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
$form = new Form($db); $form = new Form($db);
llxHeader("",$langs->trans("VariousPayment")); $title = $langs->trans("VariousPayment") . ' - ' . $langs->trans("Documents");
$help_url = '';
llxHeader("",$title,$help_url);
if ($object->id) if ($object->id)
{ {
@ -83,6 +82,46 @@ if ($object->id)
dol_fiche_head($head, 'documents', $langs->trans("VariousPayment"), 0, 'payment'); dol_fiche_head($head, 'documents', $langs->trans("VariousPayment"), 0, 'payment');
$morehtmlref='<div class="refidno">';
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.=$langs->trans('Project') . ' ';
if ($user->rights->tax->charges->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/index.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
// Construit liste des fichiers // Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
@ -92,30 +131,22 @@ if ($object->id)
$totalsize+=$file['size']; $totalsize+=$file['size'];
} }
print '<table class="border" width="100%">';
print '<table class="border" width="100%">'; print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/index.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; print '</div>';
// Ref print '<div class="clearboth"></div>';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
print '</td></tr>';
// Societe dol_fiche_end();
//print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</td></tr>";
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
$modulepart = 'banque';
$permission = $user->rights->banque->modifier;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
$modulepart = 'banque';
$permission = $user->rights->banque->modifier;
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
} }
else else
{ {

View File

@ -17,9 +17,9 @@
*/ */
/** /**
* \file htdocs/compta/bank/various_payment/index.php * \file htdocs/compta/bank/various_payment/index.php
* \ingroup bank * \ingroup bank
* \brief List of various payments * \brief List of various payments
*/ */
require '../../../main.inc.php'; require '../../../main.inc.php';
@ -92,7 +92,7 @@ $form = new Form($db);
$variousstatic = new PaymentVarious($db); $variousstatic = new PaymentVarious($db);
$accountstatic = new Account($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, v.accountancy_code,"; $sql = "SELECT v.rowid, v.sens, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code,";
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,"; $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,";
$sql.= " pst.code as payment_code"; $sql.= " pst.code as payment_code";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v";
@ -102,9 +102,9 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.row
$sql.= " WHERE v.entity IN (".getEntity('payment_various').")"; $sql.= " WHERE v.entity IN (".getEntity('payment_various').")";
// Search criteria // Search criteria
if ($search_ref) $sql.=" AND v.rowid=".$search_ref; if ($search_ref) $sql.=" AND v.rowid=".$search_ref;
if ($search_label) $sql.=natural_search(array('v.label'), $search_label); if ($search_label) $sql.=natural_search(array('v.label'), $search_label);
if ($search_amount_deb) $sql.=natural_search("v.amount", $search_amount_deb, 1); if ($search_amount_deb) $sql.=natural_search("v.amount", $search_amount_deb, 1);
if ($search_amount_cred) $sql.=natural_search("v.amount", $search_amount_cred, 1); if ($search_amount_cred) $sql.=natural_search("v.amount", $search_amount_cred, 1);
if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account;
if ($filtre) { if ($filtre) {

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com> /* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,9 +16,9 @@
*/ */
/** /**
* \file htdocs/compta/bank/various_payment/info.php * \file htdocs/compta/bank/various_payment/info.php
* \ingroup salaries * \ingroup bank
* \brief Page with info about salaries contribution * \brief Page with info about various payment
*/ */
require '../../../main.inc.php'; require '../../../main.inc.php';
@ -26,18 +26,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$langs->load("compta"); $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy"));
$langs->load("bills");
$langs->load("salaries");
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$action=GETPOST('action','aZ09'); $action=GETPOST('action','aZ09');
// Security check // Security check
$socid = GETPOST('socid','int'); $socid = GETPOST("socid","int");
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'salaries', '', '', ''); $result = restrictedArea($user, 'banque', '', '', '');
/* /*
* View * View