From 94b393e760bf0f532b06337ab97bdf88c16ae5a8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 5 Nov 2011 22:32:25 +0100 Subject: [PATCH 1/6] Fix: show icon if edit in place is possible --- htdocs/core/ajax/loadinplace.php | 2 +- htdocs/core/ajax/saveinplace.php | 2 +- htdocs/core/class/html.form.class.php | 36 ++++++----- htdocs/core/js/editinplace.js | 84 ++++++++++++++++++++++++-- htdocs/theme/auguria/style.css.php | 17 ++++-- htdocs/theme/bureau2crea/style.css.php | 27 ++++++--- htdocs/theme/cameleo/style.css.php | 17 ++++-- htdocs/theme/eldy/style.css.php | 17 ++++-- 8 files changed, 159 insertions(+), 43 deletions(-) diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 639bd5ca5ca..e4ea090d0cf 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -46,7 +46,7 @@ if((isset($_GET['field']) && ! empty($_GET['field'])) { $element = GETPOST('element'); $table_element = GETPOST('table_element'); - $field = GETPOST('field'); + $field = substr(GETPOST('field'), 4); // remove prefix val_ $fk_element = GETPOST('fk_element'); $type = GETPOST('type'); diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 954067d37ee..2c7f87897b0 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -47,7 +47,7 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) { $element = GETPOST('element'); $table_element = GETPOST('table_element'); - $field = GETPOST('field'); + $field = substr(GETPOST('field'), 4); // remove prefix val_ $fk_element = GETPOST('fk_element'); $value = GETPOST('value'); $type = GETPOST('type'); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 648938a7c8c..b54817341dc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -79,19 +79,27 @@ class Form */ function editfieldkey($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string') { - global $conf,$langs; - - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) return $langs->trans($text); - else - { - $ret=''; - $ret.=''; - if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; - $ret.='
'; - $ret.=$langs->trans($text); - $ret.=''.img_edit($langs->trans('Edit'),1).'
'; - return $ret; + global $conf,$langs; + + $ret=''; + + if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) + { + $tmp=explode(':',$typeofdata); + $ret.= "\n".'
'; + $ret.= $langs->trans($text); + $ret.= '
'."\n"; + } + else + { + $ret.=''; + if (GETPOST('action') != 'edit'.$htmlname && $perm) $ret.=''; + $ret.='
'; + $ret.=$langs->trans($text); + $ret.=''.img_edit($langs->trans('Edit'),1).'
'; } + + return $ret; } /** @@ -215,9 +223,9 @@ class Form } } - $out.= '
'; + $out.= "\n".'
'; $out.= $value; - $out.= '
'; + $out.= '
'."\n"; } else { diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js index c3ee9146565..8b09731cca5 100644 --- a/htdocs/core/js/editinplace.js +++ b/htdocs/core/js/editinplace.js @@ -11,7 +11,7 @@ $(document).ready(function() { var table_element = $('#jeditable_table_element').html(); var fk_element = $('#jeditable_fk_element').html(); - $('.edit_textarea').editable(urlSaveInPlace, { + $('.editval_textarea').editable(urlSaveInPlace, { type : 'textarea', rows : 4, id : 'field', @@ -44,7 +44,19 @@ $(document).ready(function() { } } }); - $('.edit_ckeditor').editable(urlSaveInPlace, { + $('.editkey_textarea').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_textarea').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + + $('.editval_ckeditor').editable(urlSaveInPlace, { type : 'ckeditor', id : 'field', onblur : 'ignore', @@ -74,7 +86,19 @@ $(document).ready(function() { } } }); - $('.edit_text').editable(urlSaveInPlace, { + $('.editkey_ckeditor').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_ckeditor').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + + $('.editval_text').editable(urlSaveInPlace, { type : 'text', id : 'field', width : 300, @@ -100,7 +124,19 @@ $(document).ready(function() { } } }); - $('.edit_numeric').editable(urlSaveInPlace, { + $('.editkey_text').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_text').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + + $('.editval_numeric').editable(urlSaveInPlace, { type : 'text', id : 'field', width : 100, @@ -126,7 +162,19 @@ $(document).ready(function() { } } }); - $('.edit_datepicker').editable(urlSaveInPlace, { + $('.editkey_numeric').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_numeric').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + + $('.editval_datepicker').editable(urlSaveInPlace, { type : 'datepicker', id : 'field', onblur : 'ignore', @@ -155,7 +203,19 @@ $(document).ready(function() { } } }); - $('.edit_select').editable(urlSaveInPlace, { + $('.editkey_datepicker').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_datepicker').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + + $('.editval_select').editable(urlSaveInPlace, { type : 'select', id : 'field', onblur : 'ignore', @@ -191,6 +251,18 @@ $(document).ready(function() { } } }); + $('.editkey_select').hover( + function () { + $( '#val_' + $(this).attr('id') ).addClass("editval_hover"); + }, + function () { + $( '#val_' + $(this).attr('id') ).removeClass("editval_hover"); + } + ); + $('.editkey_select').click(function() { + $( '#val_' + $(this).attr('id') ).click(); + }); + $('.edit_autocomplete').editable(urlSaveInPlace, { type : 'autocomplete', id : 'field', diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php index 4451b2ec24a..c3fbae9bae8 100644 --- a/htdocs/theme/auguria/style.css.php +++ b/htdocs/theme/auguria/style.css.php @@ -1625,16 +1625,25 @@ table.cal_event td { border: 0px; padding-: 0px; padding-) right center no-repeat; +.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select { + background: url() right top no-repeat; cursor: pointer; } -.edit_datepicker:hover { - background: white url() right center no-repeat; +.editkey_datepicker { + background: url() right center no-repeat; cursor: pointer; } +.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover { + background: white; + cursor: pointer; +} + +.editval_hover { + background: white; +} + /* ============================================================================== */ /* Admin Menu */ diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php index 78901d45668..be308f8e78b 100644 --- a/htdocs/theme/bureau2crea/style.css.php +++ b/htdocs/theme/bureau2crea/style.css.php @@ -1,9 +1,9 @@ - * Copyright (C) 2006 Rodolphe Quiedeville - * Copyright (C) 2007-2010 Regis Houssin - * Copyright (C) 2011 Philippe Grand - * Copyright (C) 2011 Juanjo Menent +/* Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2007-2010 Regis Houssin + * Copyright (C) 2011 Philippe Grand + * Copyright (C) 2011 Juanjo Menent * * 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 @@ -1844,16 +1844,25 @@ table.cal_event td { border: 0px; padding-: 0px; padding-) right center no-repeat; +.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select { + background: url() right top no-repeat; cursor: pointer; } -.edit_datepicker:hover { - background: white url() right center no-repeat; +.editkey_datepicker { + background: url() right center no-repeat; cursor: pointer; } +.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover { + background: white; + cursor: pointer; +} + +.editval_hover { + background: white; +} + /* ============================================================================== */ /* Admin Menu */ diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php index 94d7b4a4eaf..a4476e1924a 100644 --- a/htdocs/theme/cameleo/style.css.php +++ b/htdocs/theme/cameleo/style.css.php @@ -1792,16 +1792,25 @@ table.cal_event td { border: 0px; padding-: 0px; padding-) right center no-repeat; +.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select { + background: url() right top no-repeat; cursor: pointer; } -.edit_datepicker:hover { - background: white url() right center no-repeat; +.editkey_datepicker { + background: url() right center no-repeat; cursor: pointer; } +.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover { + background: white; + cursor: pointer; +} + +.editval_hover { + background: white; +} + /* ============================================================================== */ /* Admin Menu */ diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 8f68fcbca1b..408d5fb0c65 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1704,16 +1704,25 @@ table.cal_event td { border: 0px; padding-: 0px; padding-) right top no-repeat; +.editkey_textarea, .editkey_ckeditor, .editkey_text, .editkey_numeric, .editkey_select { + background: url() right top no-repeat; cursor: pointer; } -.edit_datepicker:hover { - background: white url() right center no-repeat; +.editkey_datepicker { + background: url() right center no-repeat; cursor: pointer; } +.editval_textarea:hover, .editval_ckeditor:hover, .editval_text:hover, .editval_numeric:hover, .editval_select:hover, .editval_datepicker:hover { + background: white; + cursor: pointer; +} + +.editval_hover { + background: white; +} + /* ============================================================================== */ /* Admin Menu */ From 029c405b7d2501194e58d43e2cb70d6cb4994d4b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 6 Nov 2011 00:14:08 +0100 Subject: [PATCH 2/6] Fix: hide edit in place icon if MAIN_EDIT_ALSO_INLINE is not defined --- htdocs/core/class/html.form.class.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4658c615b7d..b75f21603f8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -85,10 +85,17 @@ class Form if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) { - $tmp=explode(':',$typeofdata); - $ret.= "\n".'
'; - $ret.= $langs->trans($text); - $ret.= '
'."\n"; + if ($perm) + { + $tmp=explode(':',$typeofdata); + $ret.= '
'; + $ret.= $langs->trans($text); + $ret.= '
'."\n"; + } + else + { + $ret.= $langs->trans($text); + } } else { @@ -230,7 +237,7 @@ class Form } } - $out.= "\n".'
'; + $out.= '
'; $out.= $value; $out.= '
'."\n"; } From 75ed34452091782b3001a78d93636fda491c6f6e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 6 Nov 2011 09:51:55 +0100 Subject: [PATCH 3/6] Fix: invalid EOL char --- htdocs/core/modules/modTax.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index cc18764e2a6..de015e2348c 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004-2009 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2009 Regis Houssin +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2011 Regis Houssin * * 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 From 38c4c88b5f1aa90b6b6cbe9a02fd292fd3e87cdf Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 6 Nov 2011 10:00:45 +0100 Subject: [PATCH 4/6] Fix: Avoid function calls in a FOR loop test part --- htdocs/core/lib/functions.lib.php | 8 ++++---- htdocs/core/lib/functions2.lib.php | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 272b106faf0..4c822b7aa64 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -100,7 +100,8 @@ if (! function_exists('json_decode')) { $comment = false; - for ($i=0; $i Date: Sun, 6 Nov 2011 10:11:23 +0100 Subject: [PATCH 5/6] Fix: Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead. --- .../triggers/interface_modLdap_Ldapsynchro.class.php | 6 +++--- htdocs/fourn/class/fournisseur.class.php | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/triggers/interface_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_modLdap_Ldapsynchro.class.php index f8e22bf722d..949854e0961 100644 --- a/htdocs/core/triggers/interface_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_modLdap_Ldapsynchro.class.php @@ -375,7 +375,7 @@ class InterfaceLdapsynchro dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if ($conf->ldap->enabled && $conf->global->LDAP_MEMBER_ACTIVE) { - # If status field is setup to be synchronized + // If status field is setup to be synchronized if ($conf->global->LDAP_FIELD_MEMBER_STATUS) { $ldap=new Ldap(); @@ -399,7 +399,7 @@ class InterfaceLdapsynchro dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if ($conf->ldap->enabled && $conf->global->LDAP_MEMBER_ACTIVE) { - # If subscriptions fields are setup to be synchronized + // If subscriptions fields are setup to be synchronized if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE || $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT || $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE @@ -458,7 +458,7 @@ class InterfaceLdapsynchro dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if ($conf->ldap->enabled && $conf->global->LDAP_MEMBER_ACTIVE) { - # If password field is setup to be synchronized + // If password field is setup to be synchronized if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) { $ldap=new Ldap(); diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index 8a3fb8bfd52..1275570d6b3 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -246,12 +246,12 @@ class Fournisseur extends Societe } /** - * Return a link on thirdparty (with picto) - * - * @param withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only) - * @param option Target of link ('', 'customer', 'prospect', 'supplier') - * @param maxlen Max length of text - * @return string String with URL + * Return a link on thirdparty (with picto) + * + * @param int $withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only) + * @param string $option Target of link ('', 'customer', 'prospect', 'supplier') + * @param int $maxlen Max length of text + * @return string String with URL */ function getNomUrl($withpicto=0,$option='supplier',$maxlen=0) { From ca63f3d8e9840655035ad0d088ff8654ea60e16a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 6 Nov 2011 11:11:43 +0100 Subject: [PATCH 6/6] Fix: uniform code and reindent --- htdocs/adherents/admin/adherent.php | 86 +- htdocs/compta/bank/account.php | 1364 +++++++++++++-------------- 2 files changed, 723 insertions(+), 727 deletions(-) diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index fe8dc327f41..a144f8259c4 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -34,11 +34,10 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php"); $langs->load("admin"); $langs->load("members"); -if (!$user->admin) -accessforbidden(); +if (! $user->admin) accessforbidden(); -$typeconst=array('yesno','texte','chaine'); +$type=array('yesno','texte','chaine'); $action = GETPOST("action"); @@ -46,33 +45,31 @@ $action = GETPOST("action"); // Action mise a jour ou ajout d'une constante if ($action == 'update' || $action == 'add') { - $const=GETPOST("constname"); - $value=GETPOST("constvalue"); - - if (($const=='ADHERENT_CARD_TYPE' || $const=='ADHERENT_ETIQUETTE_TYPE') - && $value == -1) $value=''; - if ($const=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice - { - if ($value) $value=0; - else $value=1; - } - - - if (in_array($const,array('ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL'))) $value=$_POST["constvalue".$const]; - $type=$_POST["consttype"]; - $constnote=GETPOST("constnote"); - $res=dolibarr_set_const($db,$const,$value,$typeconst[$type],0,$constnote,$conf->entity); - - if (! $res > 0) $error++; - - if (! $error) - { - $mesg = "".$langs->trans("SetupSaved").""; - } - else - { - $mesg = "".$langs->trans("Error").""; - } + $constname=GETPOST("constname"); + $constvalue=GETPOST("constvalue"); + + if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE') && $constvalue == -1) $constvalue=''; + if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice + { + if ($constvalue) $constvalue=0; + else $constvalue=1; + } + + if (in_array($constname,array('ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL'))) $constvalue=$_POST["constvalue".$constname]; + $consttype=$_POST["consttype"]; + $constnote=GETPOST("constnote"); + $res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = '
'.$langs->trans("SetupSaved").'
'; + } + else + { + $mesg = '
'.$langs->trans("Error").'
'; + } } // Action activation d'un sous module du module adherent @@ -211,11 +208,12 @@ if ($conf->global->ADHERENT_USE_MAILMAN) $lien=img_picto($langs->trans("Active"),'tick').' '; $lien.=''.$langs->trans("Disable").''; // Edition des varibales globales - $constantes=array('ADHERENT_MAILMAN_LISTS', - 'ADHERENT_MAILMAN_ADMINPW', - 'ADHERENT_MAILMAN_URL', - 'ADHERENT_MAILMAN_UNSUB_URL' - ); + $constantes=array( + 'ADHERENT_MAILMAN_LISTS', + 'ADHERENT_MAILMAN_ADMINPW', + 'ADHERENT_MAILMAN_URL', + 'ADHERENT_MAILMAN_UNSUB_URL' + ); print_fiche_titre("Mailman mailing list system",$lien,''); // JQuery activity @@ -254,12 +252,14 @@ if ($conf->global->ADHERENT_USE_SPIP) $lien=img_picto($langs->trans("Active"),'tick').' '; $lien.=''.$langs->trans("Disable").''; // Edition des varibales globales - $constantes=array('ADHERENT_USE_SPIP_AUTO', - 'ADHERENT_SPIP_SERVEUR', - 'ADHERENT_SPIP_DB', - 'ADHERENT_SPIP_USER', - 'ADHERENT_SPIP_PASS' - ); + $constantes=array( + 'ADHERENT_USE_SPIP_AUTO', + 'ADHERENT_SPIP_SERVEUR', + 'ADHERENT_SPIP_DB', + 'ADHERENT_SPIP_USER', + 'ADHERENT_SPIP_PASS' + ); + print_fiche_titre("SPIP CMS",$lien,''); form_constantes($constantes); print '
'; @@ -282,7 +282,7 @@ $constantes=array( 'ADHERENT_CARD_TEXT', 'ADHERENT_CARD_TEXT_RIGHT', 'ADHERENT_CARD_FOOTER_TEXT' -); + ); print_fiche_titre($langs->trans("MembersCards"),'',''); @@ -323,8 +323,8 @@ $constantes=array( 'ADHERENT_MAIL_RESIL_SUBJECT', 'ADHERENT_MAIL_RESIL', 'ADHERENT_MAIL_FROM', + ); -); print_fiche_titre($langs->trans("Other"),'',''); form_constantes($constantes); diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 697541f3904..8f4c72389f1 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -3,7 +3,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2011 Laurent Destailleur * Copytight (C) 2004 Christophe Combelles - * Copytight (C) 2005-2010 Regis Houssin + * Copytight (C) 2005-2011 Regis Houssin * Copytight (C) 2010-2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -69,51 +69,50 @@ $dateop=-1; if ($action == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights->banque->modifier) { - - 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) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Date")); - if (! $operation) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Type")); - if (! $amount) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Amount")); - - if (! $mesg) - { - $acct=new Account($db); - $acct->fetch($account); - $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); - if ($insertid > 0) - { - Header("Location: account.php?account=" . $account."&action=addline"); - exit; - } - else - { - dol_print_error($db,$acct->error); - } - } - else - { - $action='addline'; - } + 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) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Date")); + if (! $operation) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Type")); + if (! $amount) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Amount")); + + if (! $mesg) + { + $acct=new Account($db); + $acct->fetch($account); + $insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); + if ($insertid > 0) + { + Header("Location: ".$_SERVER['PHP_SELF']."?account=" . $account."&action=addline"); + exit; + } + else + { + dol_print_error($db,$acct->error); + } + } + else + { + $action='addline'; + } } if ($action == 'confirm_delete' && $_POST["confirm"]=='yes' && $user->rights->banque->modifier) { - $accline=new AccountLine($db); - $accline->fetch($_GET["rowid"]); - $result=$accline->delete(); + $accline=new AccountLine($db); + $accline->fetch($_GET["rowid"]); + $result=$accline->delete(); } @@ -134,653 +133,650 @@ $html = new Form($db); if ($account || $_GET["ref"]) { - if ($vline) - { - $viewline = $vline; - } - else - { - $viewline = empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?20:$conf->global->MAIN_SIZE_LISTE_LIMIT; - } - $acct = new Account($db); - if ($account) - { - $result=$acct->fetch($account); - } - if ($_GET["ref"]) - { - $result=$acct->fetch(0,$_GET["ref"]); - $account=$acct->id; - } - - // Chargement des categories bancaires dans $options - $nbcategories=0; - - $sql = "SELECT rowid, label"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " ORDER BY label"; - - $result = $db->query($sql); - if ($result) - { - $var=True; - $num = $db->num_rows($result); - $i = 0; - $options = ""; - while ($i < $num) - { - $obj = $db->fetch_object($result); - $options .= "\n"; - $nbcategories++; - $i++; - } - $db->free($result); - } - - // 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 ($_REQUEST["req_desc"]) - { - $sql_rech.= " AND b.label like '%".$db->escape($_REQUEST["req_desc"])."%'"; - $param.='&req_desc='.urlencode($_REQUEST["req_desc"]); - $mode_search = 1; - } - if ($_REQUEST["req_debit"]) - { - $sql_rech.=" AND b.amount = -".price2num($_REQUEST["req_debit"]); - $param.='&req_debit='.urlencode($_REQUEST["req_debit"]); - $mode_search = 1; - } - if ($_REQUEST["req_credit"]) - { - $sql_rech.=" AND b.amount = ".price2num($_REQUEST["req_credit"]); - $param.='&req_credit='.urlencode($_REQUEST["req_credit"]); - $mode_search = 1; - } - if ($thirdparty) - { - $sql_rech.=" AND s.nom LIKE '%".$db->escape($thirdparty)."%'"; - $param.='&thirdparty='.urlencode($thirdparty); - $mode_search = 1; - } - if ($_REQUEST["paiementtype"]) - { - $sql_rech.=" AND b.fk_type = '".$db->escape($_REQUEST["paiementtype"])."'"; - $param.='&paiementtype='.urlencode($_REQUEST["paiementtype"]); - $mode_search = 1; - } - - $sql = "SELECT count(*) as nb"; - $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 = ".$acct->id; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity = ".$conf->entity; - $sql.= $sql_rech; - - dol_syslog("account.php count transactions - sql=".$sql); - $result=$db->query($sql); - if ($result) - { - $obj = $db->fetch_object($result); - $nbline = $obj->nb; - $total_lines = $nbline; - - if ($nbline > $viewline ) - { - $limit = $nbline - $viewline ; - } - else - { - $limit = $viewline; - } - - $db->free($result); - } - else { - dol_print_error($db); - } - - if ($page > 0) - { - $limitsql = $nbline - ($page * $viewline); - if ($limitsql < $viewline) - { - $limitsql = $viewline; - } - $nbline = $limitsql; - } - else - { - $page = 0; - $limitsql = $nbline; - } - //print $limitsql.'-'.$page.'-'.$viewline; - - // Onglets - $head=bank_prepare_head($acct); - dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); - - print ''; - - // Ref - print ''; - print ''; - - // Label - print ''; - print ''; - - print '
'.$langs->trans("Ref").''; - print $html->showrefnav($acct,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$acct->label.'
'; - - print '
'; - - if ($mesg) print '
'.$mesg.'
'; - - - /** - * Search form + if ($vline) + { + $viewline = $vline; + } + else + { + $viewline = empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?20:$conf->global->MAIN_SIZE_LISTE_LIMIT; + } + $acct = new Account($db); + if ($account) + { + $result=$acct->fetch($account); + } + if ($_GET["ref"]) + { + $result=$acct->fetch(0,$_GET["ref"]); + $account=$acct->id; + } + + // Chargement des categories bancaires dans $options + $nbcategories=0; + + $sql = "SELECT rowid, label"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; + $sql.= " WHERE entity = ".$conf->entity; + $sql.= " ORDER BY label"; + + $result = $db->query($sql); + if ($result) + { + $var=True; + $num = $db->num_rows($result); + $i = 0; + $options = ''; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $options.= ''."\n"; + $nbcategories++; + $i++; + } + $db->free($result); + } + + // 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 ($_REQUEST["req_desc"]) + { + $sql_rech.= " AND b.label LIKE '%".$db->escape($_REQUEST["req_desc"])."%'"; + $param.='&req_desc='.urlencode($_REQUEST["req_desc"]); + $mode_search = 1; + } + if ($_REQUEST["req_debit"]) + { + $sql_rech.=" AND b.amount = -".price2num($_REQUEST["req_debit"]); + $param.='&req_debit='.urlencode($_REQUEST["req_debit"]); + $mode_search = 1; + } + if ($_REQUEST["req_credit"]) + { + $sql_rech.=" AND b.amount = ".price2num($_REQUEST["req_credit"]); + $param.='&req_credit='.urlencode($_REQUEST["req_credit"]); + $mode_search = 1; + } + if ($thirdparty) + { + $sql_rech.=" AND s.nom LIKE '%".$db->escape($thirdparty)."%'"; + $param.='&thirdparty='.urlencode($thirdparty); + $mode_search = 1; + } + if ($_REQUEST["paiementtype"]) + { + $sql_rech.=" AND b.fk_type = '".$db->escape($_REQUEST["paiementtype"])."'"; + $param.='&paiementtype='.urlencode($_REQUEST["paiementtype"]); + $mode_search = 1; + } + + $sql = "SELECT count(*) as nb"; + $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 = ".$acct->id; + $sql.= " AND b.fk_account = ba.rowid"; + $sql.= " AND ba.entity = ".$conf->entity; + $sql.= $sql_rech; + + dol_syslog("account.php count transactions - sql=".$sql, LOG_DEBUG); + $result=$db->query($sql); + if ($result) + { + $obj = $db->fetch_object($result); + $nbline = $obj->nb; + $total_lines = $nbline; + + if ($nbline > $viewline ) $limit = $nbline - $viewline ; + else $limit = $viewline; + + $db->free($result); + } + else + { + dol_print_error($db); + } + + if ($page > 0) + { + $limitsql = $nbline - ($page * $viewline); + if ($limitsql < $viewline) $limitsql = $viewline; + $nbline = $limitsql; + } + else + { + $page = 0; + $limitsql = $nbline; + } + //print $limitsql.'-'.$page.'-'.$viewline; + + // Onglets + $head=bank_prepare_head($acct); + dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); + + print ''; + + // Ref + print ''; + print ''; + + // Label + print ''; + print ''; + + print '
'.$langs->trans("Ref").''; + print $html->showrefnav($acct,'ref','',1,'ref'); + print '
'.$langs->trans("Label").''.$acct->label.'
'; + + print '
'; + + dol_htmloutput_errors($mesg); + + /** + * Search form + */ + $param.='&account='.$acct->id; + + // Define transaction list navigation string + $navig=''; + $navig.='
'; + $nbpage=floor($total_lines/$viewline)+($total_lines % $viewline > 0?1:0); // Nombre de page total + //print 'nbpage='.$nbpage.' viewline='.$viewline.' limitsql='.$limitsql; + if ($limitsql > $viewline) $navig.=''.img_previous().''; + $navig.= $langs->trans("Page")." "; // ' Page '; + $navig.=''; + $navig.=''; + $navig.=''; + $navig.=''; + $navig.=''; + $navig.=''; + $navig.=''; + $navig.=''; + $navig.='/'.$nbpage.' '; + if ($total_lines > $limitsql ) + { + $navig.= ''.img_next().''; + } + $navig.='
'; + //var_dump($navig); + + // Confirmation delete + if ($action == 'delete') + { + $text=$langs->trans('ConfirmDeleteTransaction'); + $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?account='.$acct->id.'&rowid='.$_GET["rowid"],$langs->trans('DeleteTransaction'),$text,'confirm_delete'); + if ($ret == 'html') print '
'; + } + + print ''; + + // Show title + if ($action != 'addline' && $action != 'delete') + { + print ''; + } + + // Form to add a transaction with no invoice + if ($user->rights->banque->modifier && $action == 'addline') + { + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ""; + + print ''."\n"; + } + + /* + * Affiche tableau des transactions bancaires + */ + + // Ligne de titre tableau des ecritures + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + print "\n"; + + /* + * Another solution + * create temporary table solde type=heap select amount from llx_bank limit 100 ; + * select sum(amount) from solde ; */ - $param.='&account='.$acct->id; - - - // Define transaction list navigation string - $navig=''; - $navig.=''; - $nbpage=floor($total_lines/$viewline)+($total_lines % $viewline > 0?1:0); // Nombre de page total - //print 'nbpage='.$nbpage.' viewline='.$viewline.' limitsql='.$limitsql; - if ($limitsql > $viewline) - { - $navig.=''.img_previous().''; - } - $navig.= $langs->trans("Page")." "; // ' Page '; - $navig.=''; - $navig.=''; - $navig.=''; - $navig.=''; - $navig.=''; - $navig.=''; - $navig.=''; - $navig.=''; - $navig.='/'.$nbpage.' '; - if ($total_lines > $limitsql ) - { - $navig.= ''.img_next().''; - } - $navig.=''; - //var_dump($navig); - - // Confirmation delete - if ($action == 'delete') - { - $text=$langs->trans('ConfirmDeleteTransaction'); - $ret=$html->form_confirm($_SERVER['PHP_SELF'].'?account='.$acct->id.'&rowid='.$_GET["rowid"],$langs->trans('DeleteTransaction'),$text,'confirm_delete'); - if ($ret == 'html') print '
'; - } - - - print '
'.$navig.'
'.$langs->trans("AddBankRecordLong").'
'.$langs->trans("Date").' '.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").' 
'; + $html->select_date($dateop,'op',0,0,0,'transaction'); + print ''; + $html->select_types_paiements((isset($_POST["operation"])?$_POST["operation"]:''),'operation','1,2',2,1); + print ''; + print ''; + print ''; + if ($nbcategories) + { + print '
'.$langs->trans("Category").': '; + } + print '
'; + print '
'; + print ''; + print '
 
'.$langs->trans("Date").''.$langs->trans("Value").''.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("ThirdParty").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("BankBalance").''; + if ($acct->type != 2 && $acct->rappro) print $langs->trans("AccountStatementShort"); + else print ' '; + print '
  '; + //$filtertype=array('TIP'=>'TIP','PRE'=>'PRE',...) + $filtertype=''; + print $html->select_types_paiements($_REQUEST['paiementtype'],'paiementtype',$filtertype,2,1,1,8); + print ' 
'; - - // Show title - if ($action != 'addline' && $action != 'delete') - { - print ''; - } - - - // Form to add a transaction with no invoice - if ($user->rights->banque->modifier && $action == 'addline') - { - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ""; - - print "\n"; - } - - /* - * Affiche tableau des transactions bancaires - * - */ - - // Ligne de titre tableau des ecritures - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - 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"; - if ($mode_search) - { - $sql.= ", s.rowid as socid, s.nom as thirdparty"; - } - if ($mode_search && $conf->adherent->enabled) - { - - } - if ($mode_search && $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 && $conf->tax->enabled) - { - $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"; - } - if ($mode_search && $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=".$acct->id; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity = ".$conf->entity; - $sql.= $sql_rech; - $sql.= $db->order("b.datev, b.datec", "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 - sql=".$sql); - $result = $db->query($sql); - if ($result) - { - $now=dol_now(); - $nows=dol_print_date($now,'%Y%m%d'); - - //$html->load_cache_types_paiements(); - //$html->cache_types_paiements - - $var=true; - - $num = $db->num_rows($result); - $i = 0; $total = 0; $sep = 0; - - while ($i < $num) - { - $objp = $db->fetch_object($result); - $total = price2num($total + $objp->amount,'MT'); - if ($i >= ($nbline - $viewline)) - { - $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) // Yes, we show a subtotal - { - $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"; - } - else - { - print "\n"; - } - - // Balance - if ($action != 'search') - { - if ($total >= 0) - { - print ''; - } - else - { - print ''; - } - } - else - { - print ''; - } - - // Transaction reconciliated or edit link - if ($objp->rappro && $acct->canBeConciliated() > 0) // If line not conciliated and account can be conciliated - { - print ""; - } - else - { - print ''; - } - - print ""; - - } - - $i++; - } - - // Show total - if ($page == 0 && ! $mode_search) - { - print ''; - print ''; - print ''; - print ''; - } - $db->free($result); - } - else - { - dol_print_error($db); - } - - - print "
'.$navig.'
'.$langs->trans("AddBankRecordLong").'
'.$langs->trans("Date").' '.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").' 
'; - $html->select_date($dateop,'op',0,0,0,'transaction'); - print ''; - $html->select_types_paiements((isset($_POST["operation"])?$_POST["operation"]:''),'operation','1,2',2,1); - print ''; - print ''; - print ''; - if ($nbcategories) - { - print '
'.$langs->trans("Category").': '; - } - print '
'; - print '
'; - print ''; - print '
 
'.$langs->trans("Date").''.$langs->trans("Value").''.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("ThirdParty").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("BankBalance").''; - if ($acct->type != 2 && $acct->rappro) print $langs->trans("AccountStatementShort"); - else print ' '; - print '
  '; - //$filtertype=array('TIP'=>'TIP','PRE'=>'PRE',...) - $filtertype=''; - print $html->select_types_paiements($_REQUEST['paiementtype'],'paiementtype',$filtertype,2,1,1,8); - 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; - // $label=$langs->getTradFromKey("PaymentTypeShort".$objp->fk_type); - - if ($objp->fk_type == 'SOLD') $label=' '; - 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 = $acct->get_url($objp->rowid); - foreach($links as $key=>$val) - { - if ($links[$key]['type']=='payment') { - $paymentstatic->id=$links[$key]['url_id']; - print ' '.$paymentstatic->getNomUrl(2); - } - else if ($links[$key]['type']=='payment_supplier') { - $paymentsupplierstatic->id=$links[$key]['url_id']; - $paymentsupplierstatic->ref=$links[$key]['url_id']; - print ' '.$paymentsupplierstatic->getNomUrl(2); - } - else if ($links[$key]['type']=='company') { - } - else if ($links[$key]['type']=='payment_sc') - { - //print ' - '; - print ''; - print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; - //print $langs->trans("SocialContributionPayment"); - print ''; - - } - else if ($links[$key]['type']=='payment_vat') - { - $paymentvatstatic->id=$links[$key]['url_id']; - $paymentvatstatic->ref=$links[$key]['url_id']; - print ' '.$paymentvatstatic->getNomUrl(2); - } - else if ($links[$key]['type']=='banktransfert') { - // Do not show this link (avoid confusion). Can already be accessed from transaction detail - } - else if ($links[$key]['type']=='member') { - } - else if ($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->nom=$links[$key]['label']; - print $societestatic->getNomUrl(1,'',16); - } - 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']=='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 "num_releve&account=$acct->id\">$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 ($acct->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 ''; - print img_delete(); - print ''; - } - print '
'; - if ($sep) print ' '; - else print $langs->trans("CurrentBalance"); - print ''.price($total).' 
"; - - print "\n
\n"; - - /* - * Boutons actions - */ - - if ($action != 'delete') - { - print '
'; - - if ($acct->type != 2 && $acct->rappro) // If not cash account and can be reconciliate - { - if ($user->rights->banque->consolidate) - { - print ''.$langs->trans("Conciliate").''; - } - else - { - print "trans("NotEnoughPermissions")."\" href=\"#\">".$langs->trans("Conciliate").""; - } - } - - if ($action != 'addline') - { - if ($user->rights->banque->modifier) - { - print ''.$langs->trans("AddBankRecord").''; - } - else - { - print "trans("NotEnoughPermissions")."\" href=\"#\">".$langs->trans("AddBankRecord").""; - } - } - - print '
'; - } - - print '
'; - + + $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"; + if ($mode_search) + { + $sql.= ", s.rowid as socid, s.nom as thirdparty"; + } + /* + if ($mode_search && $conf->adherent->enabled) + { + + } + if ($mode_search && $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 && $conf->tax->enabled) + { + $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"; + } + if ($mode_search && $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=".$acct->id; + $sql.= " AND b.fk_account = ba.rowid"; + $sql.= " AND ba.entity = ".$conf->entity; + $sql.= $sql_rech; + $sql.= $db->order("b.datev, b.datec", "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 - sql=".$sql, LOG_DEBUG); + $result = $db->query($sql); + if ($result) + { + $now=dol_now(); + $nows=dol_print_date($now,'%Y%m%d'); + + //$html->load_cache_types_paiements(); + //$html->cache_types_paiements + + $var=true; + + $num = $db->num_rows($result); + $i = 0; $total = 0; $sep = 0; + + while ($i < $num) + { + $objp = $db->fetch_object($result); + $total = price2num($total + $objp->amount,'MT'); + if ($i >= ($nbline - $viewline)) + { + $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) // Yes, we show a subtotal + { + $sep = 1 ; + print ''; + print $langs->trans("CurrentBalance"); + print ''; + print ''.price($total - $objp->amount).''; + print " "; + print ''; + } + + print ''; + + print ''.dol_print_date($db->jdate($objp->do),"day")."\n"; + + print ''.dol_print_date($db->jdate($objp->dv),"day"); + print "\n"; + + // Payment type + print ""; + $label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type; + // $label=$langs->getTradFromKey("PaymentTypeShort".$objp->fk_type); + + if ($objp->fk_type == 'SOLD') $label=' '; + print $label; + print "\n"; + + // Num + print ''.($objp->num_chq?$objp->num_chq:"")."\n"; + + // Description + print ''; + // 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 = $acct->get_url($objp->rowid); + foreach($links as $key=>$val) + { + if ($links[$key]['type']=='payment') + { + $paymentstatic->id=$links[$key]['url_id']; + print ' '.$paymentstatic->getNomUrl(2); + } + else if ($links[$key]['type']=='payment_supplier') + { + $paymentsupplierstatic->id=$links[$key]['url_id']; + $paymentsupplierstatic->ref=$links[$key]['url_id']; + print ' '.$paymentsupplierstatic->getNomUrl(2); + } + else if ($links[$key]['type']=='company') + { + + } + else if ($links[$key]['type']=='payment_sc') + { + //print ' - '; + print ''; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + //print $langs->trans("SocialContributionPayment"); + print ''; + } + else if ($links[$key]['type']=='payment_vat') + { + $paymentvatstatic->id=$links[$key]['url_id']; + $paymentvatstatic->ref=$links[$key]['url_id']; + print ' '.$paymentvatstatic->getNomUrl(2); + } + else if ($links[$key]['type']=='banktransfert') + { + // Do not show this link (avoid confusion). Can already be accessed from transaction detail + } + else if ($links[$key]['type']=='member') + { + + } + else if ($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 ''; + + // Add third party column + print ''; + foreach($links as $key=>$val) + { + if ($links[$key]['type']=='company') + { + $societestatic->id=$links[$key]['url_id']; + $societestatic->nom=$links[$key]['label']; + print $societestatic->getNomUrl(1,'',16); + } + 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']=='member') + { + $memberstatic->id=$links[$key]['url_id']; + $memberstatic->ref=$links[$key]['label']; + print $memberstatic->getNomUrl(1,16,'card'); + } + } + print ''; + + // Amount + if ($objp->amount < 0) + { + print ''.price($objp->amount * -1).' '."\n"; + } + else + { + print '  '.price($objp->amount).''."\n"; + } + + // Balance + if ($action != 'search') + { + if ($total >= 0) + { + print ' '.price($total).''; + } + else + { + print ' '.price($total).''; + } + } + else + { + print '-'; + } + + // Transaction reconciliated or edit link + if ($objp->rappro && $acct->canBeConciliated() > 0) // If line not conciliated and account can be conciliated + { + print ''; + print ''; + print img_edit(); + print ''; + print "  "; + print ''.$objp->num_releve.''; + print ""; + } + else + { + print ''; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + print img_edit(); + print ''; + } + else + { + print ''; + print img_view(); + print ''; + } + if ($acct->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 ''; + print img_delete(); + print ''; + } + print ''; + } + + print ""; + } + + $i++; + } + + // Show total + if ($page == 0 && ! $mode_search) + { + print ''; + if ($sep) print ' '; + else print $langs->trans("CurrentBalance"); + print ''; + print ''.price($total).''; + print ' '; + print ''; + } + $db->free($result); + } + else + { + dol_print_error($db); + } + + print ""; + + print "\n\n"; + + /* + * Boutons actions + */ + + if ($action != 'delete') + { + print '
'; + + if ($acct->type != 2 && $acct->rappro) // If not cash account and can be reconciliate + { + if ($user->rights->banque->consolidate) + { + print ''.$langs->trans("Conciliate").''; + } + else + { + print ''.$langs->trans("Conciliate").''; + } + } + + if ($action != 'addline') + { + if ($user->rights->banque->modifier) + { + print ''.$langs->trans("AddBankRecord").''; + } + else + { + print ''.$langs->trans("AddBankRecord").''; + } + } + + print '
'; + } + + print '
'; } else { - print $langs->trans("ErrorBankAccountNotFound"); + print $langs->trans("ErrorBankAccountNotFound"); } $db->close(); llxFooter(); -?> +?> \ No newline at end of file