From 36f279837fdb8b7c22fa4c0bf92b031d675fa771 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 19 Mar 2017 08:17:32 +0100 Subject: [PATCH] Update work --- .../bank/class/paymentvarious.class.php | 7 +- htdocs/compta/bank/ligne.php | 8 +- htdocs/compta/bank/various_payment/card.php | 4 +- .../compta/bank/various_payment/document.php | 127 +++++++++ htdocs/compta/bank/various_payment/index.php | 253 ++++++++++++++++++ htdocs/compta/bank/various_payment/info.php | 65 +++++ htdocs/core/lib/bank.lib.php | 45 ++++ 7 files changed, 504 insertions(+), 5 deletions(-) create mode 100644 htdocs/compta/bank/various_payment/document.php create mode 100644 htdocs/compta/bank/various_payment/index.php create mode 100644 htdocs/compta/bank/various_payment/info.php diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 9dc505aa393..94bf08867e4 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -163,7 +163,7 @@ class PaymentVarious extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid"; - $sql.= " WHERE s.rowid = ".$id; + $sql.= " WHERE v.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); @@ -309,11 +309,13 @@ class PaymentVarious extends CommonObject $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_various ("; $sql.= " datep"; $sql.= ", datev"; + $sql.= ", sens"; $sql.= ", amount"; $sql.= ", fk_typepayment"; $sql.= ", num_payment"; if ($this->note) $sql.= ", note"; $sql.= ", label"; + $sql.= ", accountancy_code"; $sql.= ", fk_user_author"; $sql.= ", datec"; $sql.= ", fk_bank"; @@ -322,12 +324,13 @@ class PaymentVarious extends CommonObject $sql.= " VALUES ("; $sql.= "'".$this->db->idate($this->datep)."'"; $sql.= ", '".$this->db->idate($this->datev)."'"; + $sql.= ", '".$this->sens."'"; $sql.= ", ".$this->amount; - $sql.= ", ".($this->salary > 0 ? $this->salary : "null"); $sql.= ", '".$this->type_payment."'"; $sql.= ", '".$this->num_payment."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; $sql.= ", '".$this->db->escape($this->label)."'"; + $sql.= ", '".$this->accountancy_code."'"; $sql.= ", '".$user->id."'"; $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", NULL"; diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 609a3f47bd1..e5c6e81eba8 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015-2016 Alexandre Spangaro + * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Marcos García * @@ -378,6 +378,12 @@ if ($result) print img_object($langs->trans('ShowUser'),'user').' '; print $langs->trans("User"); print ''; + } + else if ($links[$key]['type']=='payment_various') { + print ''; + print img_object($langs->trans('ShowVariousPayment'),'payment').' '; + print $langs->trans("SalaryPayment"); + print ''; } else { print ''; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 4e95cd0b402..0c2b5256c2c 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -308,13 +308,13 @@ if ($action == 'create') if ($id) { - $head=various_payement_prepare_head($object); + $head=various_payment_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("VariousPayment"), 0, 'payment'); print ''; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; print ""; print '
'.$langs->trans("Ref").''; diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php new file mode 100644 index 00000000000..3fa15deb9c2 --- /dev/null +++ b/htdocs/compta/bank/various_payment/document.php @@ -0,0 +1,127 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/compta/bank/various_payment/document.php + * \ingroup banque + * \brief Page of linked files onto various_payment + */ + +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +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.'/compta/bank/class/paymentvarious.class.php'; + +$langs->load("other"); +$langs->load("bank"); +$langs->load("companies"); + +$id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'salaries', $id, ''); + + +// Get parameters +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; + + +$object = new PaymentVarious($db); +$object->fetch($id, $ref); + +$upload_dir = $conf->banque->dir_output.'/'.dol_sanitizeFileName($object->id); +$modulepart='banque'; + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; + + +/* + * View + */ + +$form = new Form($db); + +llxHeader("",$langs->trans("VariousPayment")); + + +if ($object->id) +{ + $head=various_payment_prepare_head($object); + + dol_fiche_head($head, 'documents', $langs->trans("VariousPayment"), 0, 'payment'); + + + // Construit liste des fichiers + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Societe + //print ""; + + print ''; + print ''; + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); + print '
".$langs->trans("Company")."".$object->client->getNomUrl(1)."
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print ''; + + $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 +{ + print $langs->trans("ErrorUnknown"); +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php new file mode 100644 index 00000000000..1747e5db855 --- /dev/null +++ b/htdocs/compta/bank/various_payment/index.php @@ -0,0 +1,253 @@ + + * + * 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/various_payment/index.php + * \ingroup bank + * \brief List of various payments + */ + +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + +$langs->load("compta"); +$langs->load("salaries"); +$langs->load("bills"); + +// Security check +$socid = GETPOST("socid","int"); +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'banque', '', '', ''); + +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$search_ref = GETPOST('search_ref','int'); +$search_user = GETPOST('search_user','alpha'); +$search_label = GETPOST('search_label','alpha'); +$search_amount = GETPOST('search_amount','alpha'); +$search_account = GETPOST('search_account','int'); + +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield="v.datep"; +if (! $sortorder) $sortorder="DESC"; +$optioncss = GETPOST('optioncss','alpha'); + +$filtre=$_GET["filtre"]; + +if (empty($_REQUEST['typeid'])) +{ + $newfiltre=str_replace('filtre=','',$filtre); + $filterarray=explode('-',$newfiltre); + foreach($filterarray as $val) + { + $part=explode(':',$val); + if ($part[0] == 'v.fk_typepayment') $typeid=$part[1]; + } +} +else +{ + $typeid=$_REQUEST['typeid']; +} + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +{ + $search_ref=""; + $search_label=""; + $search_amount=""; + $search_account=''; + $typeid=""; +} + +/* + * View + */ + +llxHeader(); + +$form = new Form($db); +$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.= " 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"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; +$sql.= " WHERE v.entity = ".$conf->entity; + +// Search criteria +if ($search_ref) $sql.=" AND v.rowid=".$search_ref; +if ($search_label) $sql.=natural_search(array('v.label'), $search_label); +if ($search_amount) $sql.=natural_search("v.amount", $search_amount, 1); +if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; +if ($filtre) { + $filtre=str_replace(":","=",$filtre); + $sql .= " AND ".$filtre; +} +if ($typeid) { + $sql .= " AND v.fk_typepayment=".$typeid; +} +$sql.= $db->order($sortfield,$sortorder); + +//$sql.= " GROUP BY u.rowid, u.lastname, u.firstname, v.rowid, v.fk_user, v.amount, v.label, v.datev, v.fk_typepayment, v.num_payment, pst.code"; +$totalnboflines=0; +$result=$db->query($sql); +if ($result) +{ + $totalnboflines = $db->num_rows($result); +} +$sql.= $db->plimit($limit+1,$offset); + +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows($result); + $i = 0; + $total = 0 ; + $var=true; + + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($typeid) $param.='&typeid='.$typeid; + if ($optioncss != '') $param.='&optioncss='.$optioncss; + + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($langs->trans("SalariesPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num, $totalnboflines, 'title_accountancy.png', 0, '', '', $limit); + + print '
'; + print ''."\n"; + + print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"v.rowid","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"],"v.label","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"v.datep","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); + if (! empty($conf->banque->enabled)) print_liste_field_titre($langs->trans("BankAccount"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("PayedByThisPayment"),$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); + print "\n"; + + print ''; + // Ref + print ''; + // Label + print ''; + // Date + print ''; + // Type + print ''; + // Account + if (! empty($conf->banque->enabled)) + { + print ''; + } + // Amount + print ''; + + print ''; + + print "\n"; + + while ($i < min($num,$limit)) + { + $obj = $db->fetch_object($result); + $var=!$var; + print ""; + + $variousstatic->id=$obj->rowid; + $variousstatic->ref=$obj->rowid; + // Ref + print "\n"; + // Label payment + print "\n"; + // Date payment + print '\n"; + // Type + print ''; + // Account + if (! empty($conf->banque->enabled)) + { + print ''; + } + // Amount + print ""; + print ""; + print "\n"; + + $total = $total + $obj->amount; + + $i++; + } + + $colspan=5; + if (! empty($conf->banque->enabled)) $colspan++; + print ''; + print '"; + print ""; + + print "
'; + print ''; + print ' '; + $form->select_types_paiements($typeid,'typeid','',0,0,1,16); + print ''; + $form->select_comptes($search_account,'search_account',0,'',1); + print ''; + $searchpicto=$form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
".$variousstatic->getNomUrl(1)."".dol_trunc($obj->label,40)."'.dol_print_date($db->jdate($obj->datep),'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''; + if ($obj->fk_bank > 0) + { + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id=$obj->bid; + $accountstatic->ref=$obj->bref; + $accountstatic->number=$obj->bnumber; + $accountstatic->accountancy_number=$obj->account_number; + $accountstatic->accountancy_journal=$obj->accountancy_journal; + $accountstatic->label=$obj->blabel; + print $accountstatic->getNomUrl(1); + } + else print ' '; + print '".price($obj->amount)."
'.$langs->trans("Total").''.price($total)."
"; + print '
'; + print '
'; + + $db->free($result); +} +else +{ + dol_print_error($db); +} + + +llxFooter(); +$db->close(); diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php new file mode 100644 index 00000000000..73c1baa5c02 --- /dev/null +++ b/htdocs/compta/bank/various_payment/info.php @@ -0,0 +1,65 @@ + + * + * 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/various_payment/info.php + * \ingroup salaries + * \brief Page with info about salaries contribution + */ + +require '../../../main.inc.php'; +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/functions2.lib.php'; + +$langs->load("compta"); +$langs->load("bills"); +$langs->load("salaries"); + +$id=GETPOST('id','int'); +$action=GETPOST("action"); + +// Security check +$socid = GETPOST('socid','int'); +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'salaries', '', '', ''); + + +/* + * View + */ + +llxHeader("",$langs->trans("VariousPayment")); + +$object = new PaymentVarious($db); +$result = $object->fetch($id); +$object->info($id); + +$head = various_payment_prepare_head($object); + +dol_fiche_head($head, 'info', $langs->trans("VariousPayment"), 0, 'payment'); + + +print '
'; +dol_print_object_info($object); +print '
'; + +print ''; + +llxFooter(); + +$db->close(); diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index 47d3539e3ba..8e9fb7bc77a 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -134,6 +134,51 @@ function bank_admin_prepare_head($object) return $head; } +/** + * Prepare array with list of tabs + * + * @param Object $object Object related to tabs + * @return array Array of tabs to shoc + */ +function various_payment_prepare_head($object) { + + global $db, $langs, $conf; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$object->id; + $head[$h][1] = $langs->trans("Card"); + $head[$h][2] = 'card'; + $h++; + + // 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,$h,'various_payment'); + + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->banque->dir_output . "/" . dol_sanitizeFileName($object->ref); + $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$')); + $nbLinks=Link::count($db, $object->element, $object->id); + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id; + $head[$h][1] = $langs->trans('Documents'); + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; + $head[$h][2] = 'documents'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/info.php?id='.$object->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + + complete_head_from_modules($conf,$langs,$object,$head,$h,'various_payment', 'remove'); + + return $head; +} + /** * Check SWIFT informations for a bank account *