diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php deleted file mode 100644 index 26265316ea6..00000000000 --- a/htdocs/compta/bank/account.php +++ /dev/null @@ -1,978 +0,0 @@ - - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2004 Christophe Combelles - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2011 Juanjo Menent - * Copyright (C) 2012-2016 Marcos García - * Copyright (C) 2011-2015 Alexandre Spangaro - * Copyright (C) 2015 Florian Henry - * - * 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 . - */ - -/** - * \file htdocs/compta/bank/account.php - * \ingroup banque - * \brief List of details of bank transactions for an account - */ - -require('../../main.inc.php'); -require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.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("categories"); -$langs->load("bills"); -$langs->load("companies"); -$langs->load("salaries"); -$langs->load("loan"); -$langs->load("donations"); -$langs->load("trips"); -$langs->load("members"); - -$id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int')); -$ref = GETPOST('ref','alpha'); -$action=GETPOST('action','alpha'); -$confirm=GETPOST('confirm','alpha'); - -// Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); -$fieldtype = (! empty($ref) ? 'ref' :'rowid'); -if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'banque',$fieldvalue,'bank_account&bank_account','','',$fieldtype); - -$paiementtype=GETPOST('paiementtype','alpha',3); -$req_nb=GETPOST("req_nb",'',3); -$thirdparty=GETPOST("thirdparty",'',3); -$req_desc=GETPOST("req_desc",'',3); -$req_debit=GETPOST("req_debit",'',3); -$req_credit=GETPOST("req_credit",'',3); - -$req_stdtmonth=GETPOST('req_stdtmonth', 'int'); -$req_stdtday=GETPOST('req_stdtday', 'int'); -$req_stdtyear=GETPOST('req_stdtyear', 'int'); -$req_stdt = dol_mktime(0, 0, 0, $req_stdtmonth, $req_stdtday, $req_stdtyear); -$req_enddtmonth=GETPOST('req_enddtmonth', 'int'); -$req_enddtday=GETPOST('req_enddtday', 'int'); -$req_enddtyear=GETPOST('req_enddtyear', 'int'); -$req_enddt = dol_mktime(23, 59, 59, $req_enddtmonth, $req_enddtday, $req_enddtyear); - -$search_reconciled = GETPOST('search_reconciled'); - -$vline=GETPOST("vline"); -$page=GETPOST('page','int'); -$negpage=GETPOST('negpage','int'); -if ($negpage) -{ - $page=GETPOST("nbpage") - $negpage; - if ($page > GETPOST("nbpage")) $page = GETPOST("nbpage"); -} - -$sortfield = "b.datev, b.datec, b.rowid"; - -$object = new Account($db); - - - -/* - * 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) -{ - $error = 0; - - if (price2num($_POST["credit"]) > 0) - { - $amount = price2num($_POST["credit"]); - } - else - { - $amount = - price2num($_POST["debit"]); - } - - $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); - $operation=$_POST["operation"]; - $num_chq=$_POST["num_chq"]; - $label=$_POST["label"]; - $cat1=$_POST["cat1"]; - - if (! $dateop) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors'); - } - if (! $operation) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors'); - } - if (! $amount) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors'); - } - - if (! $error) - { - $object->fetch($id); - $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); - if ($insertid > 0) - { - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id."&action=addline"); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - else - { - $action='addline'; - } -} -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) -{ - $accline=new AccountLine($db); - $result=$accline->fetch(GETPOST("rowid")); - $result=$accline->delete(); -} - - -/* - * View - */ -$title = $langs->trans("FinancialAccount").' - '.$langs->trans("Transactions"); -$helpurl = ""; -llxHeader('',$title,$helpurl); - -$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); - -$form = new Form($db); - -if ($id > 0 || ! empty($ref)) -{ - if ($vline) - { - $viewline = $vline; - } - else - { - $viewline = empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?20:$conf->global->MAIN_SIZE_LISTE_LIMIT; - } - - $result=$object->fetch($id, $ref); - - // Load bank groups - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; - $bankcateg = new BankCateg($db); - $options = array(); - - foreach ($bankcateg->fetchAll() as $bankcategory) { - $options[$bankcategory->id] = $bankcategory->label; - } - - // Definition de sql_rech et param - $param=''; - $sql_rech=''; - $mode_search = 0; - if ($req_nb) - { - $sql_rech.= " AND b.num_chq LIKE '%".$db->escape($req_nb)."%'"; - $param.='&req_nb='.urlencode($req_nb); - $mode_search = 1; - } - if ($req_desc) - { - $sql_rech.= " AND b.label LIKE '%".$db->escape($req_desc)."%'"; - $param.='&req_desc='.urlencode($req_desc); - $mode_search = 1; - } - if ($req_debit != '') - { - $sql_rech.=" AND b.amount = -".price2num($req_debit); - $param.='&req_debit='.urlencode($req_debit); - $mode_search = 1; - } - if ($req_credit != '') - { - $sql_rech.=" AND b.amount = ".price2num($req_credit); - $param.='&req_credit='.urlencode($req_credit); - $mode_search = 1; - } - if ($thirdparty) - { - $sql_rech.=" AND s.nom LIKE '%".$db->escape($thirdparty)."%'"; - $param.='&thirdparty='.urlencode($thirdparty); - $mode_search = 1; - } - if ($paiementtype) - { - $sql_rech.=" AND b.fk_type = '".$db->escape($paiementtype)."'"; - $param.='&paiementtype='.urlencode($paiementtype); - $mode_search = 1; - } - - if ($req_stdt && $req_enddt) - { - $sql_rech.=" AND (b.datev BETWEEN '".$db->escape($db->idate($req_stdt))."' AND '".$db->escape($db->idate($req_enddt))."')"; - $param.='&req_stdtmonth='.$req_stdtmonth.'&req_stdtyear='.$req_stdtyear.'&req_stdtday='.$req_stdtday; - $param.='&req_enddtmonth='.$req_enddtmonth.'&req_enddtday='.$req_enddtday.'&req_enddtyear='.$req_enddtyear; - $mode_search = 1; - } - elseif ($req_stdt) - { - $sql_rech.=" AND b.datev >= '".$db->escape($db->idate($req_stdt))."'"; - $param.='&req_stdtmonth='.$req_stdtmonth.'&req_stdtyear='.$req_stdtyear.'&req_stdtday='.$req_stdtday; - $mode_search = 1; - } - elseif ($req_enddt) - { - $sql_rech.=" AND b.datev <= '".$db->escape($db->idate($req_enddt))."'"; - $param.='&req_enddtmonth='.$req_enddtmonth.'&req_enddtday='.$req_enddtday.'&req_enddtyear='.$req_enddtyear; - $mode_search = 1; - } - - if ($search_reconciled == 'reconciled') $sql_rech.=" AND num_releve IS NOT NULL"; - if ($search_reconciled == 'notreconciled') $sql_rech.=" AND num_releve IS NULL"; - - $sql = "SELECT count(*) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= ", ".MAIN_DB_PREFIX."bank as b"; - if ($mode_search) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='company'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; - } - $sql.= " WHERE b.fk_account = ".$object->id; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; - $sql.= $sql_rech; - - dol_syslog("account.php count transactions -", LOG_DEBUG); - $result=$db->query($sql); - if ($result) - { - $obj = $db->fetch_object($result); - $nbline = $obj->total; - $total_lines = $nbline; - - $db->free($result); - } - else - { - dol_print_error($db); - } - - //Total pages - $totalPages = ceil($total_lines/$viewline); - - if ($totalPages == 0) { - $page = 0; - } else { - - if ($page > 0) { - $limitsql = ($totalPages - $page) * $viewline; - if ($limitsql < $viewline) { - $limitsql = $viewline; - } - $nbline = $limitsql; - } else { - $page = 0; - $limitsql = $nbline; - } - } - - //print $limitsql.'-'.$page.'-'.$viewline; - - // Onglets - $head=bank_prepare_head($object); - dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - dol_fiche_end(); - - - - /* - * Buttons actions - */ - - if ($action != 'delete') - { - print '
'; - - if ($action != 'addline') - { - if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) - { - if ($user->rights->banque->modifier) { - print 'id.'&page='.$page.($vline?'&vline='.$vline:'').'">'.$langs->trans("AddBankRecord").''; - } else { - print ''.$langs->trans("AddBankRecord").''; - } - } else { - print ''.$langs->trans("AddBankRecord").''; - } - } - - if ($object->canBeConciliated() > 0) { - // If not cash account and can be reconciliate - if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; - } else { - print ''.$langs->trans("Conciliate").''; - } - } - - print '
'; - } - - print '
'; - - /** - * Search form - */ - $param.='&account='.$object->id.'&vline='.$vline; - - // Confirmation delete - if ($action == 'delete') - { - $text=$langs->trans('ConfirmDeleteTransaction'); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"),$langs->trans('DeleteTransaction'),$text,'confirm_delete'); - - } - - // Define transaction list navigation string - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $navig ='
'; - if ($limitsql > $viewline) $navig.=''.img_previous().''; - $navig.= ' "; // ' Page '; - $navig.=''; - $navig.='/'.$totalPages.' '; - if ($total_lines > $limitsql ) - { - $navig.= ''.img_next().''; - } - $navig.='
'; - - - //var_dump($navig); - - if ($action != 'addline' && $action != 'delete') - { - print '
'.$navig.'
'; - } - - // Form to add a transaction with no invoice - if ($user->rights->banque->modifier && $action == 'addline') - { - print load_fiche_titre($langs->trans("AddBankRecordLong"),'',''); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("Date").' '.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").' 
'; - $form->select_date($dateop,'op',0,0,0,'transaction'); - print ''; - $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1); - print ''; - print ''; - print ''; - if ($options) { - print '
'.$langs->trans("Rubrique").': '; - print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); - } - print '
'; - print '
'; - print ''; - print '
'; - print '
'; - print '
'; - } - - - /* - * Show list of bank transactions - */ - - print '
'; - print ''; - print ''; - print ''; - - print ''; - - // Ligne de titre tableau des ecritures - print ''; - print ''; - print_liste_field_titre($langs->trans("Value"), '', 'b.datev, b.datec, b.rowid','',$param,'',$sortfield,$sortorder); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $period_filter .= $langs->trans('From').' '.$form->select_date($req_stdt,'req_stdt',0,0,1,null,1,0,1); - $period_filter .= ' '; - $period_filter .= $langs->trans('to').' '.$form->select_date($req_enddt,'req_enddt',0,0,1,null,1,0,1); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - - /* - * Another solution - * create temporary table solde type=heap select amount from llx_bank limit 100 ; - * select sum(amount) from solde ; - */ - - $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; - $sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_bordereau,"; - $sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel"; - if ($mode_search) - { - $sql.= ", s.rowid as socid, s.nom as thirdparty"; - } - /* - if ($mode_search && ! empty($conf->adherent->enabled)) - { - - } - if ($mode_search && ! empty($conf->tax->enabled)) - { - - } - */ - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= ", ".MAIN_DB_PREFIX."bank as b"; - if ($mode_search) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu1.url_id = s.rowid"; - } - if ($mode_search && ! empty($conf->tax->enabled)) - { - // VAT - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='payment_vat'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."tva as t ON bu2.url_id = t.rowid"; - - // Salary payment - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment_salary'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as sal ON bu3.url_id = sal.rowid"; - } - if ($mode_search && ! empty($conf->adherent->enabled)) - { - // TODO Mettre jointure sur adherent pour recherche sur un adherent - //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='company'"; - //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu3.url_id = s.rowid"; - } - $sql.= " WHERE b.fk_account=".$object->id; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; - $sql.= $sql_rech; - $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); - $result = $db->query($sql); - if ($result) - { - $now=dol_now(); - $nows=dol_print_date($now,'%Y%m%d'); - - //$form->load_cache_types_paiements(); - //$form->cache_types_paiements - - $var=true; - - $num = $db->num_rows($result); - $i = 0; $total = 0; $sep = -1; $total_deb=0; $total_cred=0; - - while ($i < $num) - { - $objp = $db->fetch_object($result); - $total = price2num($total + $objp->amount,'MT'); - if ($i >= ($viewline * (($totalPages-$page)-1))) - { - $var=!$var; - - // Is it a transaction in future ? - $dos=dol_print_date($db->jdate($objp->do),'%Y%m%d'); - //print "dos=".$dos." nows=".$nows; - if ($dos < $nows) $sep=0; // 0 means there was at least one line before current date - if ($dos > $nows && ! $sep) // We have found a line in future and we already found on line before current date - { - $sep = 1 ; - print ''; - print ''; - print ""; - print ''; - } - - print ''; - - print '\n"; - - print '\n"; - - // Payment type - print '\n"; - - // Num - print '\n"; - - // Description - print ''; - - // Add third party column - print ''; - - // Amount - if ($objp->amount < 0) - { - print ''."\n"; - $total_deb +=$objp->amount; - } - else - { - print ''."\n"; - $total_cred +=$objp->amount; - } - - // Balance - if (! $mode_search) - { - if ($total >= 0) - { - print ''; - } - else - { - print ''; - } - } - else - { - print ''; - } - - // Transaction reconciliated or edit link - if ($objp->rappro && $object->canBeConciliated() > 0) // If line not conciliated and account can be conciliated - { - print '"; - } - else - { - print ''; - } - - print ''; - - print ""; - } - - $i++; - } - - // Show total - if ($page == 0 && ! $mode_search) - { - //Real account situation - print ''; - print ''; - print ''; - print ''; - print ''; - } else { - // Only total according row displays - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - $db->free($result); - } - else - { - dol_print_error($db); - } - - print "
'.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("ThirdParty").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("BankBalance").''; - if ($object->canBeConciliated() > 0) { - print $langs->trans("AccountStatementShort"); - } else { - print ' '; - } - print '
'.$period_filter.''; - //$filtertype=array('TIP'=>'TIP','PRE'=>'PRE',...) - $filtertype=''; - $form->select_types_paiements($paiementtype,'paiementtype',$filtertype,2,1,1,8); - print ' '; - $array=array('reconciled'=>$langs->trans("Reconciled"), 'notreconciled'=>$langs->trans("NotReconciled")); - print $form->selectarray('search_reconciled', $array, $search_reconciled, 1); - print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; - print '
'; - print $langs->trans("CurrentBalance"); - print ''.price($total - $objp->amount).' 
'.dol_print_date($db->jdate($objp->do),"day")."'.dol_print_date($db->jdate($objp->dv),"day"); - print "'; - $label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type; - - if ($objp->fk_type == 'SOLD') $label=' '; - if ($objp->fk_type == 'CHQ' && $objp->fk_bordereau > 0) - { - dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php'); - $bordereaustatic = new RemiseCheque($db); - $bordereaustatic->id = $objp->fk_bordereau; - $label .= ' '.$bordereaustatic->getNomUrl(2); - } - print $label; - print "'.($objp->num_chq?$objp->num_chq:"")."'; - // Show generic description - if (preg_match('/^\((.*)\)$/i',$objp->label,$reg)) - { - // Generic description because between (). We show it after translating. - print $langs->trans($reg[1]); - } - else - { - print dol_trunc($objp->label,60); - } - - // Add links after description - $links = $object->get_url($objp->rowid); - 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 ''; - foreach($links as $key=>$val) - { - if ($links[$key]['type']=='company') - { - $societestatic->id=$links[$key]['url_id']; - $societestatic->name=$links[$key]['label']; - print $societestatic->getNomUrl(1,'',16); - } - else if ($links[$key]['type']=='user') - { - $userstatic->id=$links[$key]['url_id']; - $userstatic->lastname=$links[$key]['label']; - print $userstatic->getNomUrl(1,''); - } - else if ($links[$key]['type']=='sc') - { - // sc=old value - $chargestatic->id=$links[$key]['url_id']; - if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg)) - { - if ($reg[1]=='socialcontribution') $reg[1]='SocialContribution'; - $chargestatic->lib=$langs->trans($reg[1]); - } - else - { - $chargestatic->lib=$links[$key]['label']; - } - $chargestatic->ref=$chargestatic->lib; - print $chargestatic->getNomUrl(1,16); - } - else if ($links[$key]['type']=='loan') - { - $loanstatic->id=$links[$key]['url_id']; - if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg)) - { - if ($reg[1]=='loan') $reg[1]='Loan'; - $loanstatic->label=$langs->trans($reg[1]); - } - else - { - $loanstatic->label=$links[$key]['label']; - } - $loanstatic->ref=$links[$key]['url_id']; - print $loanstatic->getLinkUrl(1,16); - } - else if ($links[$key]['type']=='member') - { - $memberstatic->id=$links[$key]['url_id']; - $memberstatic->ref=$links[$key]['label']; - print $memberstatic->getNomUrl(1,16,'card'); - } - } - print ''.price($objp->amount * -1).'   '.price($objp->amount).' '.price($total).' '.price($total).'-'; - print ''; - print img_edit(); - print ''; - print "  "; - print ''.$objp->num_releve.''; - print "'; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - print img_edit(); - print ''; - } - else - { - print ''; - print img_view(); - print ''; - } - if ($object->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 '
'; - if ($sep > 0) print ' '; // If we had at least one line in future - else print $langs->trans("CurrentBalance"); - print ' '.$object->currency_code.''.price($total).'  
'; - if ($sep > 0) print ' '; // If we had at least one line in future - else print $langs->trans("Total"); - print ' '.$object->currency_code.''.price($total_deb*-1).''.price($total_cred).''.price($total_cred-($total_deb*-1)).'  
"; - - print "
\n"; - - print '
'; -} -else -{ - print $langs->trans("ErrorBankAccountNotFound"); -} - -llxFooter(); - -$db->close(); diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php deleted file mode 100644 index f266c0a7723..00000000000 --- a/htdocs/compta/bank/rappro.php +++ /dev/null @@ -1,468 +0,0 @@ - - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2010 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Marcos García - * - * 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 . - */ - -/** - * \file htdocs/compta/bank/rappro.php - * \ingroup banque - * \brief Page to reconciliate bank transactions - */ - -require('../../main.inc.php'); -require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.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.'/fourn/class/paiementfourn.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; - -$langs->load("banks"); -$langs->load("categories"); -$langs->load("bills"); - -if (! $user->rights->banque->consolidate) accessforbidden(); - -$action=GETPOST('action', 'alpha'); -$id=GETPOST('account', 'int'); - -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="dateo"; - - -/* - * Actions - */ - -// Conciliation -if ($action == 'rappro' && $user->rights->banque->consolidate) -{ - $error=0; - - // Definition, nettoyage parametres - $num_releve=trim($_POST["num_releve"]); - - if ($num_releve) - { - $bankline=new AccountLine($db); - - if (isset($_POST['rowid']) && is_array($_POST['rowid'])) - { - foreach($_POST['rowid'] as $row) - { - if($row > 0) - { - $result=$bankline->fetch($row); - $bankline->num_releve=$num_releve; //$_POST["num_releve"]; - $result=$bankline->update_conciliation($user,$_POST["cat"]); - if ($result < 0) - { - setEventMessages($bankline->error, $bankline->errors, 'errors'); - $error++; - break; - } - } - } - } - } - else - { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorPleaseTypeBankTransactionReportName"), null, 'errors'); - } - - if (! $error) - { - header('Location: '.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$id); // To avoid to submit twice and allow back - exit; - } -} - -/* - * Action suppression ecriture - */ -if ($action == 'del') -{ - $bankline=new AccountLine($db); - - if ($bankline->fetch($_GET["rowid"]) > 0) { - $result = $bankline->delete($user); - if ($result < 0) { - dol_print_error($db, $bankline->error); - } - } else { - setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors'); - } -} - -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; -$bankcateg = new BankCateg($db); -$options = array(); - -foreach ($bankcateg->fetchAll() as $bankcategory) { - $options[$bankcategory->id] = $bankcategory->label; -} - -/* - * View - */ - -$form=new Form($db); - -llxHeader(); - -$societestatic=new Societe($db); -$chargestatic=new ChargeSociales($db); -$memberstatic=new Adherent($db); -$paymentstatic=new Paiement($db); -$paymentsupplierstatic=new PaiementFourn($db); -$paymentvatstatic=new TVA($db); -$remisestatic = new RemiseCheque($db); - -$acct = new Account($db); -$acct->fetch($id); - -$now=dol_now(); - -$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type as type"; -$sql.= ", b.fk_bordereau"; -$sql.= ", bc.ref"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; -$sql.= " WHERE rappro=0 AND fk_account=".$acct->id; -$sql.= " ORDER BY $sortfield $sortorder"; -$sql.= " LIMIT 1000"; // Limit to avoid page overload - -/// ajax adjust value date -print ' - - -'; - -$resql = $db->query($sql); -if ($resql) -{ - $var=True; - $num = $db->num_rows($resql); - - print load_fiche_titre($langs->trans("Reconciliation").': '.$acct->label.'', '', 'title_bank.png'); - print '
'; - - // Show last bank statements - $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year) - $liste=""; - $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account=".$acct->id." AND num_releve IS NOT NULL"; - $sql.= $db->order("num_releve","DESC"); - $sql.= $db->plimit($nbmax+1); - print $langs->trans("LastAccountStatements").' : '; - $resqlr=$db->query($sql); - if ($resqlr) - { - $numr=$db->num_rows($resqlr); - $i=0; - $last_ok=0; - while (($i < $numr) && ($i < $nbmax)) - { - $objr = $db->fetch_object($resqlr); - if (! $last_ok) { - $last_releve = $objr->num_releve; - $last_ok=1; - } - $i++; - $liste=''.$objr->num_releve.'   '.$liste; - } - if ($numr >= $nbmax) $liste="...   ".$liste; - print $liste; - if ($numr > 0) print '

'; - else print ''.$langs->trans("None").'

'; - } - else - { - dol_print_error($db); - } - - - print '
'; - print ''; - print ''; - print ''; - - print ''.$langs->trans("InputReceiptNumber").': '; - print ''; // The only default value is value we just entered - print '
'; - if ($options) { - print $langs->trans("EventualyAddCategory").': '; - print Form::selectarray('cat', $options, GETPOST('cat'), 1); - print '
'; - } - print '
'.$langs->trans("ThenCheckLinesAndConciliate").' "'.$langs->trans("Conciliate").'"
'; - - print '
'; - - $paramlist=''; - $paramlist.="&account=".$acct->id; - - print ''; - print ''."\n"; - print_liste_field_titre($langs->trans("DateOperationShort"),$_SERVER["PHP_SELF"],"b.dateo","",$paramlist,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateValueShort"),$_SERVER["PHP_SELF"],"b.datev","",$paramlist,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"b.fk_type","",$paramlist,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Description"),$_SERVER["PHP_SELF"],"b.label","",$paramlist,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Debit"),$_SERVER["PHP_SELF"],"b.amount","",$paramlist,' width="60 align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Credit"),$_SERVER["PHP_SELF"],"b.amount","",$paramlist,' width="60 align="right"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"","",$paramlist,' width="80 align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ToConciliate"),$_SERVER["PHP_SELF"],"","",$paramlist,' align="center" width="80" ',$sortfield,$sortorder); - print "\n"; - - - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - - $var=!$var; - print "\n"; -// print ''; -// print ''; - -// print "rowid."\">"; - - // Date op - print ''; - - // Date value - if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) - { - print ''; - } - else - { - print ''; - } - - // Type + Number - $label=($langs->trans("PaymentType".$objp->type)!="PaymentType".$objp->type)?$langs->trans("PaymentType".$objp->type):$objp->type; // $objp->type is a code - if ($label=='SOLD') $label=''; - $link=''; - if ($objp->fk_bordereau>0) { - $remisestatic->id = $objp->fk_bordereau; - $remisestatic->ref = $objp->number; - $link = ' '.$remisestatic->getNomUrl(1); - } - print ''; - - // Description - print ''; - - if ($objp->amount < 0) - { - print "\n"; - } - else - { - print "\n"; - } - - if ($objp->rappro) - { - // If line already reconciliated, we show receipt - print ""; - } - else - { - // If not already reconciliated - if ($user->rights->banque->modifier) - { - print '"; - } - else - { - print ""; - } - } - - - // Show checkbox for conciliation - if ($db->jdate($objp->do) <= $now) - { - - print '"; - } - else - { - print ''; - } - - print "\n"; - - $i++; - } - $db->free($resql); - - print "
'.dol_print_date($db->jdate($objp->do),"day").''."\n"; - print ''.dol_print_date($db->jdate($objp->dv),"day").""; - print ' '; - print ''; - print ''; - print img_edit_remove() . " "; - print ''; - print img_edit_add() .""; - print ''; - print ''; - print dol_print_date($db->jdate($objp->dv),"day"); - print ''.$label.($objp->num_chq?' '.$objp->num_chq:'').$link.''; - $reg=array(); - preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parentheses on tente recherche de traduction - if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); - else print $objp->label; - print ''; - - /* - * Ajout les liens (societe, company...) - */ - $newline=1; - $links = $acct->get_url($objp->rowid); - foreach($links as $key=>$val) - { - if ($newline == 0) print ' - '; - else if ($newline == 1) print '
'; - if ($links[$key]['type']=='payment') { - $paymentstatic->id=$links[$key]['url_id']; - print ' '.$paymentstatic->getNomUrl(2); - $newline=0; - } - elseif ($links[$key]['type']=='payment_supplier') { - $paymentsupplierstatic->id=$links[$key]['url_id']; - $paymentsupplierstatic->ref=$links[$key]['label']; - print ' '.$paymentsupplierstatic->getNomUrl(1); - $newline=0; - } - elseif ($links[$key]['type']=='company') { - $societestatic->id=$links[$key]['url_id']; - $societestatic->name=$links[$key]['label']; - print $societestatic->getNomUrl(1,'',24); - $newline=0; - } - else if ($links[$key]['type']=='sc') { - $chargestatic->id=$links[$key]['url_id']; - $chargestatic->ref=$links[$key]['url_id']; - $chargestatic->lib=$langs->trans("SocialContribution"); - print ' '.$chargestatic->getNomUrl(1); - } - else if ($links[$key]['type']=='payment_sc') - { - // We don't show anything because there is 1 payment for 1 social contribution and we already show link to social contribution - /*print ''; - print img_object($langs->trans('ShowPayment'),'payment').' '; - print $langs->trans("SocialContributionPayment"); - print '';*/ - $newline=2; - } - else if ($links[$key]['type']=='payment_vat') - { - $paymentvatstatic->id=$links[$key]['url_id']; - $paymentvatstatic->ref=$links[$key]['url_id']; - $paymentvatstatic->ref=$langs->trans("VATPayment"); - print ' '.$paymentvatstatic->getNomUrl(1); - } - else if ($links[$key]['type']=='banktransfert') { - print ''; - print img_object($langs->trans('ShowTransaction'),'payment').' '; - print $langs->trans("TransactionOnTheOtherAccount"); - print ''; - } - else if ($links[$key]['type']=='member') { - print ''; - print img_object($langs->trans('ShowMember'),'user').' '; - print $links[$key]['label']; - print ''; - } - else { - //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 ''; - $newline=0; - } - } - print '
".price($objp->amount * -1)."  ".price($objp->amount)."num_releve&account=$acct->id\">$objp->num_releve'; - - print ''; - print img_edit(); - print '  '; - - $now=dol_now(); - if ($db->jdate($objp->do) <= $now) { - print ''; - print img_delete(); - print ''; - } - else { - print " "; // We prevents the deletion because reconciliation can not be achieved until the date has elapsed and that writing appears well on the account. - } - print " '; - print 'rowid])?' checked':'').'>'; - print "'; - print $langs->trans("FutureTransaction"); - print '

\n"; - - print '

'; - - print "
\n"; - -} -else -{ - dol_print_error($db); -} - - -llxFooter(); - -$db->close(); diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 0acaecb875e..8c694a949a3 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -138,7 +138,7 @@ if (empty($num)) if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; + print ''.$langs->trans("Conciliate").''; } else { print ''.$langs->trans("Conciliate").''; } diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 4f93f9757ae..1b0ff489eba 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -307,7 +307,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM $newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire); if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate { - $newmenu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); + $newmenu->add('/compta/bank/bankentries.php?id='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); } $i++; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index c3373cd6fb2..782eb95d3d1 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1396,7 +1396,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire); if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate { - $newmenu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); + $newmenu->add('/compta/bank/bankentries.php?id='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); } $i++; }