From 65dafeee55f643e7ef6b40145bade1bb3cc9c928 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 19 Apr 2015 23:15:24 +0200 Subject: [PATCH] Uniformize feature between invoice and merging tool --- htdocs/compta/facture/mergepdftool.php | 54 ++++++++++++-- htdocs/compta/sociales/charges.php | 92 +++++++++++++----------- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/menus/init_menu_auguria.sql | 4 +- htdocs/core/menus/standard/eldy.lib.php | 9 +-- htdocs/langs/en_US/main.lang | 1 + 6 files changed, 110 insertions(+), 52 deletions(-) diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php index dfa1207e423..b4d310f2710 100644 --- a/htdocs/compta/facture/mergepdftool.php +++ b/htdocs/compta/facture/mergepdftool.php @@ -52,13 +52,16 @@ $filter = GETPOST("filtre"); if (GETPOST('button_search')) { $filter=GETPOST('filtre',2); - if ($filter != 'payed:0') $option=''; + //if ($filter != 'payed:0') $option=''; } if ($option == 'late') $filter = 'paye:0'; if ($option == 'unpaidall') $filter = 'paye:0'; if ($mode == 'sendremind' && $filter == '') $filter = 'paye:0'; if ($filter == '') $filter = 'paye:0'; +$search_user = GETPOST('search_user','int'); +$search_sale = GETPOST('search_sale','int'); + // Security check if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user,'facture',$id,''); @@ -72,6 +75,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both { $search_ref=""; $search_ref_supplier=""; + $search_user = ""; + $search_sale = ""; $search_label=""; $search_company=""; $search_amount_no_tax=""; @@ -79,6 +84,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both $year=""; $month=""; $filter=""; + $option=""; } @@ -445,6 +451,13 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ",".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture "; +// We'll need this table joined to the select in order to filter by sale +if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_user > 0) +{ + $sql.=", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql.=", ".MAIN_DB_PREFIX."c_type_contact as tc"; +} $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.type IN (0,1,3,5)"; @@ -480,6 +493,11 @@ else if ($year > 0) { $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; } +if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$search_sale; +if ($search_user > 0) +{ + $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".$search_user; +} $sql.= " GROUP BY s.nom, s.rowid, s.email, f.rowid, f.facnumber, f.ref_client, f.increment, f.total, f.tva, f.total_ttc, f.localtax1, f.localtax2, f.revenuestamp,"; $sql.= " f.datef, f.date_lim_reglement, f.paye, f.fk_statut, f.type, fk_mode_reglement"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; @@ -520,8 +538,8 @@ if ($resql) //else $titre.=' ('.$langs->trans("All").')'; $link=''; - if (empty($option) || $option == 'late') $link.=($link?' - ':'').''.$langs->trans("ShowUnpaidAll").''; - if (empty($option) || $option == 'unpaidall') $link.=($link?' - ':'').''.$langs->trans("ShowUnpaidLateOnly").''; + //if (empty($option) || $option == 'late') $link.=($link?' - ':'').''.$langs->trans("ShowUnpaidAll").''; + //if (empty($option) || $option == 'unpaidall') $link.=($link?' - ':'').''.$langs->trans("ShowUnpaidLateOnly").''; $param.=(! empty($option)?"&option=".$option:""); @@ -595,6 +613,30 @@ if ($resql) $i = 0; print ''; + + // If the user can view prospects other than his' + $moreforfilter=''; + if ($user->rights->societe->client->voir || $socid) + { + $langs->load("commercial"); + $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; + $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); + $moreforfilter.='       '; + } + // If the user can view prospects other than his' + if ($user->rights->societe->client->voir || $socid) + { + $moreforfilter.=$langs->trans('LinkedToSpecificUsers'). ': '; + $moreforfilter.=$form->select_dolusers($search_user,'search_user',1); + } + if ($moreforfilter) + { + print ''; + print ''; + } + print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"f.facnumber","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans('RefCustomer'),$_SERVER["PHP_SELF"],'f.ref_client','',$param,'',$sortfield,$sortorder); @@ -631,7 +673,10 @@ if ($resql) $syear = $year; $formother->select_year($syear?$syear:-1,'year',1, 20, 5); print ''; - print ''; + // Late + print ''; print ''; print ''; print '\n"; - $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type; + $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type; print "\n"; print '\n"; print ""; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f2e4980ea47..1c41454a16c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3229,7 +3229,7 @@ abstract class CommonObject if (!empty($hidemargininfos)) print ''; } - print '
'; + print $moreforfilter; + print '
 '; + print ' '.$langs->trans("Late"); + print ''; $form->select_types_paiements($search_paymentmode, 'search_paymentmode'); @@ -808,7 +853,6 @@ if ($resql) $delallowed=$user->rights->facture->lire; print '
'; - print ''; // We disable multilang because we concat already existing pdf. $formfile->show_documents('unpaid','',$filedir,$urlsource,$genallowed,$delallowed,'',1,1,0,48,1,$param,$langs->trans("PDFMerge"),$langs->trans("PDFMerge")); } diff --git a/htdocs/compta/sociales/charges.php b/htdocs/compta/sociales/charges.php index 251bd6f7f6a..740f6f3bf5e 100644 --- a/htdocs/compta/sociales/charges.php +++ b/htdocs/compta/sociales/charges.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2013 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -69,7 +69,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') } else { - setEventMessage($chargesociales->error, 'errors'); + setEventMessages($chargesociales->error, $chargesociales->errors, 'errors'); } } @@ -101,6 +101,11 @@ if ($action == 'add' && $user->rights->tax->charges->creer) setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount")), 'errors'); $action = 'create'; } + elseif (! is_numeric($amount)) + { + setEventMessage($langs->trans("ErrorFieldMustBeANumeric",$langs->transnoentities("Amount")), 'errors'); + $action = 'create'; + } else { $chargesociales=new ChargeSociales($db); @@ -114,7 +119,8 @@ if ($action == 'add' && $user->rights->tax->charges->creer) $id=$chargesociales->create($user); if ($id <= 0) { - setEventMessage($chargesociales->error, 'errors'); + setEventMessages($chargesociales->error, $chargesociales->errors, 'errors'); + $action='create'; } } } @@ -158,8 +164,9 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->cr } } - // Action clone object +// Action clone object if ($action == 'confirm_clone' && $confirm != 'yes') { $action=''; } + if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->charges->creer)) { $db->begin(); @@ -226,7 +233,6 @@ llxHeader("",$langs->trans("SocialContribution"),$help_url); if ($action == 'create') { print_fiche_titre($langs->trans("NewSocialContribution")); - print "
\n"; $var=false; @@ -234,53 +240,59 @@ if ($action == 'create') print ''; print ''; - print ""; - print ""; - print ''; - print "\n"; - - print ''; - - print ''; + dol_fiche_head(); + print '
'; - print ' '; - print ''; - print $langs->trans("Label"); - print ''; - print $langs->trans("Type"); - print ''; - print $langs->trans("PeriodEndDate"); - print ''; - print $langs->trans("Amount"); - print ''; - print $langs->trans("DateDue"); - print ''; - print ' '; - print '
 
'; + print ""; // Label + print ''; print ''; - - // Type - print ''; + print ''; + // Type + print ''; + print ''; - + print ''; // Date end period - print ''; + print ''; + print ''; - - print ''; - - print ''; + // Amount + print ''; + print ''; + print ''; + print ''; + // Date due + print ''; + print ''; + print ''; - - print ''; - print ''; + print "\n"; print '
'; + print $langs->trans("Label"); + print ''; + print '
'; + print $langs->trans("Type"); + print ''; $formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode")?GETPOST("actioncode"):'','actioncode',1); print '
'; + print '
'; + print $langs->trans("PeriodEndDate"); + print ''; print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1); print ''; + print '
'; + print $langs->trans("Amount"); + print '
'; + print $langs->trans("DateDue"); + print ''; print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1); print '
'; + dol_fiche_end(); + + print '
'; + print ''; + print '
'; + print ''; } @@ -392,7 +404,7 @@ if ($id > 0) print "
"; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$labeltype.' '.$objp->num_paiement."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."
'; + print '
'; print ''; print ''; print ''; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index fd4d41ce6a7..27ea9515162 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -165,8 +165,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- Accountancy - Customer invoice insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1700__+MAX_llx_menu__, 'accountancy', 'customer_bills', 6__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills', 'BillsCustomers', 0, 'bills', '$user->rights->facture->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1701__+MAX_llx_menu__, 'accountancy', '', 1700__+MAX_llx_menu__, '/compta/facture.php?action=create&leftmenu=customers_bills', 'NewBill', 1, 'bills', '$user->rights->facture->creer', '', 2, 3, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1702__+MAX_llx_menu__, 'accountancy', '', 1700__+MAX_llx_menu__, '/compta/facture/fiche-rec.php?leftmenu=customers_bills', 'Repeatable', 1, 'bills', '$user->rights->facture->lire', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1705__+MAX_llx_menu__, 'accountancy', '', 1700__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills', 'List', 1, 'bills', '$user->rights->facture->lire', '', 2, 5, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1705__+MAX_llx_menu__, 'accountancy', '', 1700__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills', 'List', 1, 'bills', '$user->rights->facture->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1702__+MAX_llx_menu__, 'accountancy', '', 1700__+MAX_llx_menu__, '/compta/facture/fiche-rec.php?leftmenu=customers_bills', 'ListOfTemplates', 1, 'bills', '$user->rights->facture->lire', '', 2, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1720__+MAX_llx_menu__, 'accountancy', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills&search_status=0', 'BillShortStatusDraft', 2, 'bills', '$user->rights->facture->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->facture->enabled', __HANDLER__, 'left', 1721__+MAX_llx_menu__, 'accountancy', '', 1705__+MAX_llx_menu__, '/compta/facture/list.php?leftmenu=customers_bills&search_status=1', 'BillShortStatusNotPaid', 2, 'bills', '$user->rights->facture->lire', '', 2, 2, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index fc193f2ecda..6e0d436d767 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -743,7 +743,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $langs->load("bills"); $newmenu->add("/compta/facture/list.php",$langs->trans("BillsCustomers"),0,$user->rights->facture->lire, '', $mainmenu, 'customers_bills'); $newmenu->add("/compta/facture.php?action=create",$langs->trans("NewBill"),1,$user->rights->facture->creer); - $newmenu->add("/compta/facture/fiche-rec.php",$langs->trans("Repeatables"),1,$user->rights->facture->lire); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills",$langs->trans("List"),1,$user->rights->facture->lire); if (empty($leftmenu) || ($leftmenu == 'customers_bills')) @@ -753,6 +752,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills&search_status=2",$langs->trans("BillShortStatusPaid"),2,$user->rights->facture->lire); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills&search_status=3",$langs->trans("BillShortStatusCanceled"),2,$user->rights->facture->lire); } + $newmenu->add("/compta/facture/fiche-rec.php",$langs->trans("ListOfTemplates"),1,$user->rights->facture->lire); $newmenu->add("/compta/paiement/list.php",$langs->trans("Payments"),1,$user->rights->facture->lire); @@ -762,9 +762,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } $newmenu->add("/compta/paiement/rapport.php",$langs->trans("Reportings"),2,$user->rights->facture->lire); - $newmenu->add("/compta/facture/mergepdftool.php",$langs->trans("MergingPDFTool"),1,$user->rights->facture->lire); - $newmenu->add("/compta/facture/stats/index.php", $langs->trans("Statistics"),1,$user->rights->facture->lire); + + $newmenu->add("/compta/facture/mergepdftool.php",$langs->trans("MergingPDFTool"),1,$user->rights->facture->lire); } // Suppliers @@ -846,8 +846,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Social contributions if (! empty($conf->tax->enabled)) { - $newmenu->add("/compta/sociales/index.php?leftmenu=tax_social",$langs->trans("MenuSocialContributions"),1,$user->rights->tax->charges->lire); + $newmenu->add("/compta/sociales/index.php?leftmenu=tax_social",$langs->trans("MenuSocialContributions"),1,$user->rights->tax->charges->lire); if (empty($leftmenu) || preg_match('/^tax_social/i',$leftmenu)) $newmenu->add("/compta/sociales/charges.php?leftmenu=tax_social&action=create",$langs->trans("MenuNewSocialContribution"), 2, $user->rights->tax->charges->creer); + if (empty($leftmenu) || preg_match('/^tax_social/i',$leftmenu)) $newmenu->add("/compta/sociales/index.php?leftmenu=tax_social",$langs->trans("List"),2,$user->rights->tax->charges->lire); if (empty($leftmenu) || preg_match('/^tax_social/i',$leftmenu)) $newmenu->add("/compta/charges/index.php?leftmenu=tax_social&mainmenu=accountancy&mode=sconly",$langs->trans("Payments"), 2, $user->rights->tax->charges->lire); // VAT if (empty($conf->global->TAX_DISABLE_VAT_MENUS)) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 85e1e931574..37b535012c8 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -703,6 +703,7 @@ ShowTransaction=Show transaction GoIntoSetupToChangeLogo=Go into Home - Setup - Company to change logo or go into Home - Setup - Display to hide. Deny=Deny Denied=Denied +ListOfTemplates=List of templates # Week day Monday=Monday Tuesday=Tuesday
'.$langs->trans('Margins').''.$langs->trans('SellingPrice').'