--- /tmp/dsg/dolibarr/htdocs/compta/sociales/github_card.php +++ /tmp/dsg/dolibarr/htdocs/compta/sociales/client_card.php @@ -27,11 +27,11 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (!empty($conf->projet->enabled)) { +if (!empty($conf->projet->enabled)) +{ include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } @@ -124,10 +124,13 @@ { $object->fetch($id); $result = $object->delete($user); - if ($result > 0) { + if ($result > 0) + { header("Location: list.php"); exit; - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -136,39 +139,47 @@ // Add social contribution if ($action == 'add' && $user->rights->tax->charges->creer) { - $amount = price2num(GETPOST('amount'), 'MT'); + $amount = price2num(GETPOST('amount')); if (!$dateech) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $action = 'create'; - } elseif (!$dateperiod) + } + elseif (!$dateperiod) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors'); $action = 'create'; - } elseif (!$actioncode > 0) + } + elseif (!$actioncode > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors'); $action = 'create'; - } elseif (empty($amount)) + } + elseif (empty($amount)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); $action = 'create'; - } elseif (!is_numeric($amount)) { + } + elseif (!is_numeric($amount)) + { setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors'); $action = 'create'; - } else { + } + else + { $object->type = $actioncode; $object->label = GETPOST('label', 'alpha'); $object->date_ech = $dateech; - $object->periode = $dateperiod; - $object->amount = $amount; - $object->mode_reglement_id = (int) GETPOST('mode_reglement_id', 'int'); - $object->fk_account = (int) GETPOST('fk_account', 'int'); - $object->fk_project = (int) GETPOST('fk_project', 'int'); + $object->periode = $dateperiod; + $object->amount = $amount; + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->fk_account = GETPOST('fk_account', 'int'); + $object->fk_project = GETPOST('fk_project'); $id = $object->create($user); - if ($id <= 0) { + if ($id <= 0) + { setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; } @@ -178,33 +189,39 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->creer) { - $amount = price2num(GETPOST('amount'), 'MT'); + $amount = price2num(GETPOST('amount')); if (!$dateech) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); $action = 'edit'; - } elseif (!$dateperiod) + } + elseif (!$dateperiod) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors'); $action = 'edit'; - } elseif (empty($amount)) + } + elseif (empty($amount)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); $action = 'edit'; - } elseif (!is_numeric($amount)) + } + elseif (!is_numeric($amount)) { setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors'); $action = 'create'; - } else { + } + else + { $result = $object->fetch($id); $object->date_ech = $dateech; - $object->periode = $dateperiod; - $object->amount = $amount; + $object->periode = $dateperiod; + $object->amount = price2num($amount); $result = $object->update($user); - if ($result <= 0) { + if ($result <= 0) + { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -228,14 +245,16 @@ if (GETPOST('clone_label', 'alphanohtml')) { $object->label = GETPOST('clone_label', 'alphanohtml'); - } else { + } + else { $object->label = $langs->trans("CopyOf").' '.$object->label; } if (GETPOST('clone_for_next_month', 'int')) { $object->periode = dol_time_plus_duree($object->periode, 1, 'm'); $object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm'); - } else { + } + else { $newdateperiod = dol_mktime(0, 0, 0, GETPOST('clone_periodmonth', 'int'), GETPOST('clone_periodday', 'int'), GETPOST('clone_periodyear', 'int')); $newdateech = dol_mktime(0, 0, 0, GETPOST('clone_date_echmonth', 'int'), GETPOST('clone_date_echday', 'int'), GETPOST('clone_date_echyear', 'int')); if ($newdateperiod) $object->periode = $newdateperiod; @@ -252,14 +271,18 @@ header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; - } else { + } + else + { $id = $originalId; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } } - } else { + } + else + { $db->rollback(); dol_print_error($db, $object->error); } @@ -292,7 +315,7 @@ print ''; print ''; - print dol_get_fiche_head(); + dol_fiche_head(); print ''; @@ -301,7 +324,7 @@ print ''; - print ''; + print ''; print ''; print ''; @@ -320,7 +343,7 @@ print $langs->trans("Date"); print ''; print ''; print "\n"; @@ -366,18 +389,18 @@ if (!empty($conf->banque->enabled)) { print ''; } print '
'; print $langs->trans("Label"); print '
'; - print $form->selectDate(!empty($dateech) ? $dateech : '-1', 'ech', 0, 0, 0, 'charge', 1, 1); + print $form->selectDate(!empty($dateech) ? $dateech : '-1', 'ech', 0, 0, 0, 'charge', 1); print '
'.$langs->trans('BankAccount').''; - $form->select_comptes($fk_account, 'fk_account', 0, '', 2); + $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print '
'; - print dol_get_fiche_end(); + dol_fiche_end(); print '
'; print ''; print '     '; - print ''; + print ''; print '
'; print ''; @@ -408,7 +431,9 @@ if (!empty($conf->global->TAX_ADD_CLON_FOR_NEXT_MONTH_CHECKBOX)) { $formquestion[] = array('type' => 'checkbox', 'name' => 'clone_for_next_month', 'label' => $langs->trans("CloneTaxForNextMonth"), 'value' => 1); - } else { + } + else + { $formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1); $formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1); } @@ -436,7 +461,7 @@ print ''; } - print dol_get_fiche_head($head, 'card', $langs->trans("SocialContribution"), -1, 'bill'); + dol_fiche_head($head, 'card', $langs->trans("SocialContribution"), -1, 'bill'); $morehtmlref = '
'; // Ref customer @@ -477,8 +502,6 @@ } $morehtmlref .= '
'; - $morehtmlright = ''; - $linkback = ''.$langs->trans("BackToList").''; $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status @@ -512,7 +535,9 @@ if ($action == 'edit') { print $form->selectDate($object->periode, 'period', 0, 0, 0, 'charge', 1); - } else { + } + else + { print dol_print_date($object->periode, "day"); } print ""; @@ -521,10 +546,11 @@ if ($action == 'edit') { print ''.$langs->trans("AmountTTC").""; - print ''; + print ''; print ""; - } else { - print ''.$langs->trans("AmountTTC").''.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).''; + } + else { + print ''.$langs->trans("AmountTTC").''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).''; } // Mode of payment @@ -581,8 +607,8 @@ $sql .= " c.code as type_code,c.libelle as paiement_type,"; $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal'; $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id"; $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql .= " WHERE p.fk_charge = ".$id; @@ -605,13 +631,11 @@ print ''.$langs->trans("RefPayment").''; print ''.$langs->trans("Date").''; print ''.$langs->trans("Type").''; - if (!empty($conf->banque->enabled)) { - print ''.$langs->trans('BankAccount').''; - } + if (!empty($conf->banque->enabled)) { + print ''.$langs->trans('BankAccount').''; + } print ''.$langs->trans("Amount").''; print ''; - - $paymentsocialcontributiontmp = new PaymentSocialContribution($db); if ($num > 0) { @@ -619,14 +643,8 @@ { $objp = $db->fetch_object($resql); - $paymentsocialcontributiontmp->id = $objp->rowid; - $paymentsocialcontributiontmp->ref = $objp->rowid; - $paymentsocialcontributiontmp->datep = $db->jdate($objp->dp); - print ''; - print $paymentsocialcontributiontmp->getNomUrl(1); - print ''; - + print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp), 'day')."\n"; $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "".$labeltype.' '.$objp->num_payment."\n"; @@ -656,7 +674,9 @@ $totalpaye += $objp->amount; $i++; } - } else { + } + else + { print ''.$langs->trans("None").''; print ''; print ''; @@ -675,7 +695,9 @@ print ''; $db->free($resql); - } else { + } + else + { dol_print_error($db); } @@ -685,14 +707,14 @@ print '
'; - print dol_get_fiche_end(); + dol_fiche_end(); if ($action == 'edit') { print '
'; - print ''; + print ''; print '   '; - print ''; + print ''; print '
'; } @@ -710,13 +732,13 @@ // Reopen if ($object->paye && $user->rights->tax->charges->creer) { - print '
'.$langs->trans("ReOpen").'
'; + print "
id&action=reopen\">".$langs->trans("ReOpen")."
"; } // Edit if ($object->paye == 0 && $user->rights->tax->charges->creer) { - print '
'.$langs->trans("Modify").'
'; + print "
id&action=edit\">".$langs->trans("Modify")."
"; } // Emit payment @@ -728,24 +750,26 @@ // Classify 'paid' if ($object->paye == 0 && round($resteapayer) <= 0 && $user->rights->tax->charges->creer) { - print '
'.$langs->trans("ClassifyPaid").'
'; + print "
id&action=paid\">".$langs->trans("ClassifyPaid")."
"; } // Clone if ($user->rights->tax->charges->creer) { - print '
'.$langs->trans("ToClone")."
"; + print "
id&action=clone\">".$langs->trans("ToClone")."
"; } // Delete if ($user->rights->tax->charges->supprimer) { - print '
'.$langs->trans("Delete").'
'; + print "
id&action=delete\">".$langs->trans("Delete")."
"; } print ""; } - } else { + } + else + { /* Social contribution not found */ dol_print_error('', $object->error); } --- /tmp/dsg/dolibarr/htdocs/compta/sociales/github_document.php +++ /tmp/dsg/dolibarr/htdocs/compta/sociales/client_document.php @@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; if (!empty($conf->projet->enabled)) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page @@ -57,7 +57,7 @@ $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { - $page = 0; + $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; @@ -81,10 +81,10 @@ if ($action == 'setlib' && $user->rights->tax->charges->creer) { - $object->fetch($id); - $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY'); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); + $object->fetch($id); + $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); } @@ -103,28 +103,28 @@ { $alreadypayed = $object->getSommePaiement(); - $head = tax_prepare_head($object); + $head = tax_prepare_head($object); - print dol_get_fiche_head($head, 'documents', $langs->trans("SocialContribution"), -1, 'bill'); + dol_fiche_head($head, 'documents', $langs->trans("SocialContribution"), -1, 'bill'); $morehtmlref = '
'; // Label of social contribution $morehtmlref .= $form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); - // Project + // Project if (!empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' : '; - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ''; - $morehtmlref .= $proj->ref; - $morehtmlref .= ''; - } else { - $morehtmlref .= ''; - } + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' : '; + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } } $morehtmlref .= '
'; @@ -137,34 +137,36 @@ print '
'; print '
'; - // Build file list - $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']; - } + // Build file list + $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 ''; + print '
'; - print ''; - print ''; - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).'
'; + print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; + print ''.$langs->trans("TotalSizeOfAttachedFiles").''.dol_print_size($totalsize, 1, 1).''; + print ''; - print '
'; + print ''; - print '
'; + print '
'; - print dol_get_fiche_end(); + dol_fiche_end(); - $modulepart = 'tax'; - $permission = $user->rights->tax->charges->creer; - $permtoedit = $user->rights->fournisseur->facture->creer; - $param = '&id='.$object->id; - include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { - print $langs->trans("ErrorUnknown"); + $modulepart = 'tax'; + $permission = $user->rights->tax->charges->creer; + $permtoedit = $user->rights->fournisseur->facture->creer; + $param = '&id='.$object->id; + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ + print $langs->trans("ErrorUnknown"); } // End of page --- /tmp/dsg/dolibarr/htdocs/compta/sociales/github_info.php +++ /tmp/dsg/dolibarr/htdocs/compta/sociales/client_info.php @@ -75,7 +75,7 @@ $head = tax_prepare_head($object); -print dol_get_fiche_head($head, 'info', $langs->trans("SocialContribution"), -1, 'bill'); +dol_fiche_head($head, 'info', $langs->trans("SocialContribution"), -1, 'bill'); $morehtmlref = '
'; // Label of social contribution --- /tmp/dsg/dolibarr/htdocs/compta/sociales/github_list.php +++ /tmp/dsg/dolibarr/htdocs/compta/sociales/client_list.php @@ -4,8 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2016 Frédéric France * Copyright (C) 2020 Pierre Ardoin - * Copyright (C) 2020 Tobias Sekan - + * * 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 @@ -21,18 +20,12 @@ */ /** - * \file htdocs/compta/sociales/list.php - * \ingroup tax - * \brief Page to list all social contributions + * \file htdocs/compta/sociales/list.php + * \ingroup tax + * \brief Page to list all social contributions */ require '../../main.inc.php'; - -// Security check -$socid = isset($_GET["socid"]) ? $_GET["socid"] : ''; -if ($user->socid) $socid = $user->socid; -$result = restrictedArea($user, 'tax', '', '', 'charges'); - require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -42,32 +35,36 @@ // Load translation files required by the page $langs->loadLangs(array('compta', 'banks', 'bills')); -$action = GETPOST('action', 'aZ09'); -$massaction = GETPOST('massaction', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); -$optioncss = GETPOST('optioncss', 'alpha'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist'; - -$search_ref = GETPOST('search_ref', 'int'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); +$toselect = GETPOST('toselect', 'array'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'sclist'; + +// Security check +$socid = isset($_GET["socid"]) ? $_GET["socid"] : ''; +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'tax', '', '', 'charges'); + +$search_ref = GETPOST('search_ref', 'int'); $search_label = GETPOST('search_label', 'alpha'); -$search_amount = GETPOST('search_amount', 'alpha'); -$search_status = GETPOST('search_status', 'int'); +$search_amount = GETPOST('search_amount', 'alpha'); +$search_status = GETPOST('search_status', 'int'); $search_day_lim = GETPOST('search_day_lim', 'int'); $search_month_lim = GETPOST('search_month_lim', 'int'); $search_year_lim = GETPOST('search_year_lim', 'int'); $search_project_ref = GETPOST('search_project_ref', 'alpha'); -$search_project = GETPOST('search_project', 'alpha'); - -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); +$search_project = GETPOST('search_project', 'alpha'); + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); - -if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; - if (!$sortfield) $sortfield = "cs.date_ech"; if (!$sortorder) $sortorder = "DESC"; @@ -83,54 +80,29 @@ $part = explode(':', $val); if ($part[0] == 'cs.fk_type') $search_typeid = $part[1]; } -} else { +} +else +{ $search_typeid = GETPOST('search_typeid', 'int'); } -$arrayfields = array( - 'cs.rowid' =>array('label'=>"Ref", 'checked'=>1, 'position'=>10), - 'cs.libelle' =>array('label'=>"Label", 'checked'=>1, 'position'=>20), - 'cs.fk_type' =>array('label'=>"Type", 'checked'=>1, 'position'=>30), - 'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>40, 'enable'=>(!empty($conf->projet->enabled))), - 'cs.date_ech' =>array('label'=>"Date", 'checked'=>1, 'position'=>50), - 'cs.periode' =>array('label'=>"PeriodEndDate", 'checked'=>1, 'position'=>60), - 'cs.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70), - 'cs.paye' =>array('label'=>"Status", 'checked'=>1, 'position'=>80), -); -$arrayfields = dol_sort_array($arrayfields, 'position'); - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('sclist')); -$object = new ChargeSociales($db); - -/* - * Actions - */ - -$parameters = array('socid'=>$socid); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - -if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - - // All tests are required to be compatible with all browsers - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - $search_ref = ''; - $search_label = ''; - $search_amount = ''; - $search_status = ''; - $search_typeid = ''; - $year = ''; - $search_day_lim = ''; - $search_year_lim = ''; - $search_month_lim = ''; - $search_project_ref = ''; - $search_project = ''; - $search_array_options = array(); - } -} +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers +{ + $search_ref = ""; + $search_label = ""; + $search_amount = ""; + $search_status = ''; + $search_typeid = ""; + $year = ""; + $search_day_lim = ''; + $search_year_lim = ''; + $search_month_lim = ''; + $search_project_ref = ''; + $search_project = ''; + $toselect = ''; + $search_array_options = array(); +} + /* * View @@ -144,8 +116,8 @@ llxHeader('', $langs->trans("SocialContributions")); -$sql = "SELECT cs.rowid, cs.fk_type as type, "; -$sql .= " cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode,"; +$sql = "SELECT cs.rowid as id, cs.fk_type as type, "; +$sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode,"; if (!empty($conf->projet->enabled)) $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,"; $sql .= " c.libelle as type_label,"; $sql .= " SUM(pc.amount) as alreadypayed"; @@ -165,19 +137,19 @@ //$sql.= dolSqlDateFilter("cs.periode", 0, 0, $year); if ($year > 0) { - $sql .= " AND ("; - // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, - // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql .= " (cs.periode IS NOT NULL AND date_format(cs.periode, '%Y') = '".$db->escape($year)."') "; - $sql .= "OR (cs.periode IS NULL AND date_format(cs.date_ech, '%Y') = '".$db->escape($year)."')"; - $sql .= ")"; + $sql .= " AND ("; + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " (cs.periode IS NOT NULL AND date_format(cs.periode, '%Y') = '".$year."') "; + $sql .= "OR (cs.periode IS NULL AND date_format(cs.date_ech, '%Y') = '".$year."')"; + $sql .= ")"; } if ($filtre) { - $filtre = str_replace(":", "=", $filtre); - $sql .= " AND ".$filtre; + $filtre = str_replace(":", "=", $filtre); + $sql .= " AND ".$filtre; } if ($search_typeid) { - $sql .= " AND cs.fk_type=".$db->escape($search_typeid); + $sql .= " AND cs.fk_type=".$db->escape($search_typeid); } $sql .= " GROUP BY cs.rowid, cs.fk_type, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, c.libelle"; if (!empty($conf->projet->enabled)) $sql .= ", p.rowid, p.ref, p.title"; @@ -187,274 +159,198 @@ $result = $db->query($sql); if ($result) { - $totalnboflines = $db->num_rows($result); + $totalnboflines = $db->num_rows($result); } $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); -if (!$resql) +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); + if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); + if ($search_typeid) $param .= '&search_typeid='.urlencode($search_typeid); + if ($search_status != '' && $search_status != '-1') $param .= '&search_status='.urlencode($search_status); + if ($year) $param .= '&year='.urlencode($year); + + $newcardbutton = ''; + if ($user->rights->tax->charges->creer) + { + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create'); + } + + print '
'; + if ($optioncss != '') print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $center = ''; + if ($year) + { + $center = ($year ? "".img_previous()." ".$langs->trans("Year")." $year ".img_next()."" : ""); + } + + print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1); + + if (empty($mysoc->country_id) && empty($mysoc->country_code)) + { + print '
'; + $langs->load("errors"); + $countrynotdefined = $langs->trans("ErrorSetACountryFirst"); + print $countrynotdefined; + print '
'; + } + else + { + print '
'; + print ''."\n"; + + print ''; + // Ref + print ''; + // Label + print ''; + // Type + print ''; + // Ref Project + if (!empty($conf->projet->enabled)) print ''; + // Date + print ''; + // Period end date + print ''; + // Amount + print ''; + // Status + print ''; + + print ''; + print "\n"; + + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "id", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "cs.libelle", "", $param, 'class="left"', $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); + if (!empty($conf->projet->enabled)) print_liste_field_titre('ProjectRef', $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "periode", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cs.paye", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + print "\n"; + + $i = 0; + $totalarray = array(); + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + + $chargesociale_static->id = $obj->id; + $chargesociale_static->ref = $obj->id; + $chargesociale_static->label = $obj->label; + $chargesociale_static->type_label = $obj->type_label; + if (!empty($conf->projet->enabled)) { + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; + } + + print ''; + + // Ref + print "\n"; + if (!$i) $totalarray['nbfield']++; + + // Label + print "\n"; + if (!$i) $totalarray['nbfield']++; + + // Type + print "\n"; + if (!$i) $totalarray['nbfield']++; + + // Project Ref + if (!empty($conf->projet->enabled)) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Date + print ''; + if (!$i) $totalarray['nbfield']++; + + // Date end period + print '\n"; + if (!$i) $totalarray['nbfield']++; + + // Amount + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; + $totalarray['val']['totalttcfield'] += $obj->amount; + + print ''; + if (!$i) $totalarray['nbfield']++; + + print ''; + + if (!$i) $totalarray['nbfield']++; + + print ''; + $i++; + } + + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + + print '
'; + print ''; + print ''; + $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone'); + print ' '; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year_lim ? $search_year_lim : -1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + print ''; + print ''; + print ''; + $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid")); + print $form->selectarray('search_status', $liststatus, $search_status, 1); + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
".$chargesociale_static->getNomUrl(1, '20')."".dol_trunc($obj->label, 42)."".$obj->type_label."'; + if ($obj->project_id > 0) + { + print $projectstatic->getNomUrl(1); + } + print ''.dol_print_date($db->jdate($obj->date_ech), 'day').''; + if ($obj->periode) + { + print 'jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').''; + } + else + { + print ' '; + } + print "'.price($obj->amount).''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'
'; + print '
'; + } + print '
'; +} +else { dol_print_error($db); - llxFooter(); - $db->close(); - exit; -} - -$num = $db->num_rows($resql); -$i = 0; - -$param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); -if ($search_label) $param .= '&search_label='.urlencode($search_label); -if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); -if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); -if ($search_typeid) $param .= '&search_typeid='.urlencode($search_typeid); -if ($search_status != '' && $search_status != '-1') $param .= '&search_status='.urlencode($search_status); -if ($year) $param .= '&year='.urlencode($year); - -$newcardbutton = ''; -if ($user->rights->tax->charges->creer) -{ - $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create'); -} - -print '
'; -if ($optioncss != '') print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -$center = ''; -if ($year) -{ - $center = ''.img_previous().''; - $center .= ' '.$langs->trans("Year").' '.$year; - $center .= ' '.img_next().''; -} - -print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1); - -if (empty($mysoc->country_id) && empty($mysoc->country_code)) -{ - print '
'; - $langs->load("errors"); - $countrynotdefined = $langs->trans("ErrorSetACountryFirst"); - print $countrynotdefined; - print '
'; - - print '
'; - llxFooter(); - $db->close(); -} - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); - -print '
'; -print ''."\n"; - -print ''; - -// Filters: Line number (placeholder) -if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; -} - -// Filter: Ref -if (!empty($arrayfields['cs.rowid']['checked'])) { - print ''; -} - -// Filter: Label -if (!empty($arrayfields['cs.rowid']['checked'])) { - print ''; -} - -// Filter: Type -if (!empty($arrayfields['cs.fk_type']['checked'])) { - print ''; -} - -// Filter: Project ref -if (!empty($arrayfields['p.ref']['checked'])) { - print ''; -} - -// Filter: Date (placeholder) -if (!empty($arrayfields['cs.date_ech']['checked'])) { - print ''; -} - -// Filter: Period end date -if (!empty($arrayfields['cs.periode']['checked'])) { - print ''; -} - -// Filter: Amount -if (!empty($arrayfields['cs.amount']['checked'])) { - print ''; -} - -// Filter: Status -if (!empty($arrayfields['cs.paye']['checked'])) { - print ''; -} - -// Fields from hook -$parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -// Filter: Buttons -print ''; - -print ''; - -print ''; -if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['cs.rowid']['checked'])) print_liste_field_titre($arrayfields['cs.rowid']['label'], $_SERVER["PHP_SELF"], "cs.rowid", '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['cs.libelle']['checked'])) print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle", '', $param, 'class="left"', $sortfield, $sortorder); -if (!empty($arrayfields['cs.fk_type']['checked'])) print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type", '', $param, 'class="left"', $sortfield, $sortorder); -if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['cs.date_ech']['checked'])) print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech", '', $param, 'align="center"', $sortfield, $sortorder); -if (!empty($arrayfields['cs.periode']['checked'])) print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, 'align="center"', $sortfield, $sortorder); -if (!empty($arrayfields['cs.amount']['checked'])) print_liste_field_titre($arrayfields['cs.amount']['label'], $_SERVER["PHP_SELF"], "cs.amount", '', $param, 'class="right"', $sortfield, $sortorder); -if (!empty($arrayfields['cs.paye']['checked'])) print_liste_field_titre($arrayfields['cs.paye']['label'], $_SERVER["PHP_SELF"], "cs.paye", '', $param, 'class="right"', $sortfield, $sortorder); - -// Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); -print ''; - -$i = 0; -$totalarray = array(); -while ($i < min($num, $limit)) -{ - $obj = $db->fetch_object($resql); - - $chargesociale_static->id = $obj->rowid; - $chargesociale_static->ref = $obj->rowid; - $chargesociale_static->label = $obj->libelle; - $chargesociale_static->type_label = $obj->type_label; - if (!empty($conf->projet->enabled)) { - $projectstatic->id = $obj->project_id; - $projectstatic->ref = $obj->project_ref; - $projectstatic->title = $obj->project_label; - } - - print ''; - - // Line number - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Ref - if (!empty($arrayfields['cs.rowid']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Label - if (!empty($arrayfields['cs.libelle']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Type - if (!empty($arrayfields['cs.fk_type']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Project ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Date - if (!empty($arrayfields['cs.date_ech']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Date end period - if (!empty($arrayfields['cs.periode']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Amount - if (!empty($arrayfields['cs.amount']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; - $totalarray['val']['totalttcfield'] += $obj->amount; - } - - // Status - if (!empty($arrayfields['cs.paye']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Buttons - print ''; - if (!$i) $totalarray['nbfield']++; - - print ''; - $i++; -} - -// Show total line -include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - -print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone', 1); - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($search_year_lim ? $search_year_lim : -1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); - print ''; - print ''; - print ''; - $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); - print ''; -print $form->showFilterAndCheckAddButtons(0); -print '
'.(($offset * $limit) + $i).''.$chargesociale_static->getNomUrl(1, '20').''.dol_trunc($obj->libelle, 42).''.$obj->type_label.''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''.dol_print_date($db->jdate($obj->date_ech), 'day').''; - if ($obj->periode) { - print 'jdate($obj->periode)).'">'; - print dol_print_date($db->jdate($obj->periode), 'day'); - print ''; - } - print ''.price($obj->amount).''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'
'; -print '
'; -print ''; +} // End of page llxFooter(); --- /tmp/dsg/dolibarr/htdocs/compta/sociales/github_payments.php +++ /tmp/dsg/dolibarr/htdocs/compta/sociales/client_payments.php @@ -1,11 +1,10 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2011-2016 Alexandre Spangaro - * Copyright (C) 2011-2014 Juanjo Menent + * Copyright (C) 2011-2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2019 Nicolas ZABOURI * * 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 @@ -22,7 +21,7 @@ */ /** - * \file htdocs/compta/charges/index.php + * \file htdocs/compta/sociales/payments.php * \ingroup compta * \brief Page to list payments of special expenses */ @@ -33,14 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; - - -$hookmanager = new HookManager($db); - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('specialexpensesindex')); // Load translation files required by the page $langs->loadLangs(array('compta', 'bills')); @@ -49,8 +40,10 @@ if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); +$mode = GETPOST("mode", 'alpha'); $year = GETPOST("year", 'int'); -$search_sc_type = GETPOST('search_sc_type', 'int'); +$filtre = GETPOST("filtre", 'alpha'); +if (!$year && $mode != 'sconly') { $year = date("Y", time()); } $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -60,26 +53,8 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "cs.date_ech"; +if (!$sortfield) $sortfield = "pc.datep"; if (!$sortorder) $sortorder = "DESC"; - -if (empty($conf->tax->enabled) || empty($user->rights->tax->charges->lire)) -{ - accessforbidden(); -} - - -/* - * Actions - */ - -// Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers -{ - $search_sc_type = ''; - //$toselect = ''; - //$search_array_options = array(); -} /* @@ -90,22 +65,19 @@ $socialcontrib = new ChargeSociales($db); $payment_sc_static = new PaymentSocialContribution($db); $sal_static = new PaymentSalary($db); -$accountstatic = new Account($db); -$formsocialcontrib = new FormSocialContrib($db); - -$title = $langs->trans("SocialContributionsPayments"); - -llxHeader('', $title); - + +llxHeader('', $langs->trans("SpecialExpensesArea")); + +$title = $langs->trans("SpecialExpensesArea"); +if ($mode == 'sconly') $title = $langs->trans("SocialContributionsPayments"); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if ($sortfield) $param .= '&sortfield='.urlencode($sortfield); -if ($sortorder) $param .= '&sortorder='.urlencode($sortorder); -if ($year) $param .= '&year='.urlencode($year); -if ($search_sc_type) $param .= '&search_sc_type='.urlencode($search_sc_type); -$num = 0; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($mode == 'sconly') $param = '&mode=sconly'; +if ($sortfield) $param .= '&sortfield='.$sortfield; +if ($sortorder) $param .= '&sortorder='.$sortorder; + print '
'; if ($optioncss != '') print ''; @@ -114,187 +86,401 @@ print ''; print ''; print ''; - -$sql = "SELECT c.id, c.libelle as label,"; -$sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; -$sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; -$sql .= " pct.code as payment_code,"; -$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; -$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; -$sql .= " ".MAIN_DB_PREFIX."chargesociales as cs"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pc.fk_bank = b.rowid"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; -$sql .= " WHERE cs.fk_type = c.id"; -$sql .= " AND cs.entity IN (".getEntity("tax").")"; -if ($search_sc_type > 0) { - $sql .= " AND cs.fk_type = ".((int) $search_sc_type); -} -if ($year > 0) { - $sql .= " AND ("; - // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, - // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire - $sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; - $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; - $sql .= ")"; -} -if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) { - $sql .= $db->order($sortfield, $sortorder); -} - -// Count total nb of records -$nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { +print ''; + +if ($mode != 'sconly') +{ + $center = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); +} +else +{ + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit); +} + +if ($year) $param .= '&year='.$year; + +if ($mode != 'sconly') +{ + print $langs->trans("DescTaxAndDividendsArea").'
'; + print "
"; +} + +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +{ + // Social contributions only + if ($mode != 'sconly') + { + print load_fiche_titre($langs->trans("SocialContributionsPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); + } + + print ''; + print ''; + print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("LabelContrib", $_SERVER["PHP_SELF"], "c.libelle", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("TypeContrib", $_SERVER["PHP_SELF"], "cs.fk_type", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'width="140px"', $sortfield, $sortorder); + print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print "\n"; + + $sql = "SELECT c.id, c.libelle as type_label,"; + $sql .= " cs.rowid, cs.libelle as label, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; + $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment,"; + $sql .= " pct.code as payment_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; + $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs,"; + $sql .= " ".MAIN_DB_PREFIX."paiementcharge as pc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON pc.fk_typepaiement = pct.id"; + $sql .= " WHERE cs.fk_type = c.id AND pc.fk_charge = cs.rowid"; + $sql .= " AND cs.entity = ".$conf->entity; + if ($year > 0) + { + $sql .= " AND ("; + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " (cs.periode IS NOT NULL AND cs.periode between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; + $sql .= " OR (cs.periode IS NULL AND cs.date_ech between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; + $sql .= ")"; + } + if (preg_match('/^cs\./', $sortfield) || preg_match('/^c\./', $sortfield) || preg_match('/^pc\./', $sortfield) || preg_match('/^pct\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); + //$sql.= $db->plimit($limit+1,$offset); + //print $sql; + + dol_syslog("compta/sociales/payments.php: select payment", LOG_DEBUG); $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 - $page = 0; - $offset = 0; - } -} -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; -} else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); - - $resql = $db->query($sql); - if (!$resql) { + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $total = 0; + $totalnb = 0; + $totalpaye = 0; + + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + + $payment_sc_static->id = $obj->pid; + $payment_sc_static->ref = $obj->pid; + + print ''; + // Ref payment + print '\n"; + // Date payment + print ''; + // Type payment + print ''; + // Label + print ''; + // Type + print ''; + // Date + $date = $obj->periode; + if (empty($date)) $date = $obj->date_ech; + print ''; + // Expected to pay + print ''; + // Paid + print ''; + print ''; + + $total = $total + $obj->total; + $totalnb = $totalnb + $obj->nb; + $totalpaye = $totalpaye + $obj->totalpaye; + $i++; + } + print ''; + print ''; // A total here has no sense + print ''; + print ''; + print ''; + print '"; + print ""; + } + else + { dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); -} -//$sql.= $db->plimit($limit+1,$offset); -//print $sql; - -$nav = ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_payment', 0, $nav, '', $limit, 0); - -print '
'.$payment_sc_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; + if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + print $obj->num_payment.''; + $socialcontrib->id = $obj->rowid; + $socialcontrib->ref = $obj->rowid; + $socialcontrib->label = $obj->label; + print $socialcontrib->getNomUrl(1, '20'); + print ''.$obj->type_label.''.dol_print_date($date, 'day').''.price($obj->total).''; + if ($obj->totalpaye) print price($obj->totalpaye); + print '
'.$langs->trans("Total").'   '.price($totalpaye)."
'; - -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -if (!empty($conf->banque->enabled)) print ''; -print ''; -print ''; -print "\n"; - -print ''; -print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "cs.date_ech", "", $param, 'width="140px"', $sortfield, $sortorder); -print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "c.libelle", "", $param, '', $sortfield, $sortorder); -print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "cs.fk_type", "", $param, '', $sortfield, $sortorder); -print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); -print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder); -print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder); -print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); -if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); -print_liste_field_titre(''); -print "\n"; - -if (!$resql) -{ - dol_print_error($db); - exit; -} - -$i = 0; -$total = 0; -$totalnb = 0; -$totalpaye = 0; - -while ($i < min($num, $limit)) { - $obj = $db->fetch_object($resql); - print ''; - // Date - $date = $obj->periode; - if (empty($date)) $date = $obj->date_ech; - print ''; - // Label - print ''; - // Type - print ''; - // Expected to pay - print ''; - // Ref payment - $payment_sc_static->id = $obj->pid; - $payment_sc_static->ref = $obj->pid; - print '\n"; - // Date payment - print ''; - // Type payment - print ''; - // Account - if (!empty($conf->banque->enabled)) - { - print ''; - } - // Paid - print ''; - - print ''; - - print ''; - - $total = $total + $obj->total; - $totalnb = $totalnb + $obj->nb; - $totalpaye = $totalpaye + $obj->totalpaye; - $i++; -} - -// Total -print ''; -print ''; // A total here has no sense -print ''; -print ''; -print ''; -if (!empty($conf->banque->enabled)) print ''; -print '"; -print ''; -print ""; - -print '
'; -$formsocialcontrib->select_type_socialcontrib(GETPOSTISSET("search_sc_type") ? $search_sc_type : '', 'search_sc_type', 1, 0, 0, 'minwidth200 maxwidth300'); -print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print '
'.dol_print_date($date, 'day').''; - $socialcontrib->id = $obj->rowid; - $socialcontrib->ref = $obj->label; - $socialcontrib->label = $obj->label; - print $socialcontrib->getNomUrl(1, '20'); - print ''.$obj->label.''.price($obj->total).''.$payment_sc_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; - if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; - print $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 ''; - if ($obj->totalpaye) print price($obj->totalpaye); - print '
'.$langs->trans("Total").'   '.price($totalpaye)."
'; - + } + print ''; +} + +// VAT +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +{ + if (!$mode || $mode != 'sconly') + { + print "
"; + + $tva = new Tva($db); + + print load_fiche_titre($langs->trans("VATPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); + + $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as pv"; + $sql .= " WHERE pv.entity = ".$conf->entity; + if ($year > 0) + { + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + } + if (preg_match('/^pv\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print ''; + print ''; + print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "pv.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pv.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print "\n"; + + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total = $total + $obj->amount; + + print ''; + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; + print '\n"; + + print '\n"; + print '"; + print "\n"; + + $i++; + } + print ''; + print ''; + print ''; + print ''; + print '"; + print ""; + + print "
'.dol_print_date($db->jdate($obj->dm), 'day').'".$obj->label."'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm), 'day')."'.price($obj->amount)."
'.$langs->trans("Total").''.price($total).'  '.price($total)."
"; + $db->free($result); + } + else + { + dol_print_error($db); + } + } +} + +// Localtax +if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") +{ + $j = 1; + $numlt = 3; +} +elseif ($mysoc->localtax1_assuj == "1") +{ + $j = 1; + $numlt = 2; +} +elseif ($mysoc->localtax2_assuj == "1") +{ + $j = 2; + $numlt = 3; +} +else +{ + $j = 0; + $numlt = 0; +} + +while ($j < $numlt) +{ + if (!$mode || $mode != 'sconly') + { + print "
"; + + $tva = new Tva($db); + + print load_fiche_titre($langs->transcountry(($j == 1 ? "LT1Payments" : "LT2Payments"), $mysoc->country_code).($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); + + + $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp"; + $sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv"; + $sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j; + if ($year > 0) + { + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + } + if (preg_match('/^pv/', $sortfield)) $sql .= $db->order($sortfield, $sortorder); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print ''; + print ''; + print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="120"', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "pv.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pv.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pv.datep", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print "\n"; + + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total = $total + $obj->amount; + + print ''; + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; + print '\n"; + + print '\n"; + print '"; + print "\n"; + + $i++; + } + print ''; + print '"; + print ''; + print ''; + print '"; + print ""; + + print "
'.dol_print_date($db->jdate($obj->dm), 'day').'".$obj->label."'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dp), 'day')."'.price($obj->amount)."
'.$langs->trans("Total").''.price($total)."  '.price($total)."
"; + $db->free($result); + } + else + { + dol_print_error($db); + } + } + $j++; +} + + +// Payment Salary +if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) +{ + if (!$mode || $mode != 'sconly') + { + $sal = new PaymentSalary($db); + + print "
"; + + print load_fiche_titre($langs->trans("SalariesPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); + + $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE s.entity IN (".getEntity('user').")"; + $sql .= " AND u.rowid = s.fk_user"; + if ($year > 0) + { + $sql .= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')"; + } + if (preg_match('/^s\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print ''; + print ''; + print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "s.dateep", "", $param, 'width="140px"', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print "\n"; + + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total = $total + $obj->amount; + + print ''; + + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $sal_static->id = $obj->rowid; + $sal_static->ref = $obj->rowid; + print '\n"; + + print '\n"; + print '"; + print "\n"; + + $i++; + } + print ''; + print ''; // A total here has no sense + print ''; + print ''; + print '"; + print ""; + + print "
'.dol_print_date($db->jdate($obj->dateep), 'day').'".$obj->label."'.($obj->salary ?price($obj->salary) : '')."'.$sal_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day')."'.price($obj->amount)."
'.$langs->trans("Total").'  '.price($total)."
"; + $db->free($result); + + print "
"; + } + else + { + dol_print_error($db); + } + } +} print '
'; - -$parameters = array('user' => $user); -$reshook = $hookmanager->executeHooks('dashboardSpecialBills', $parameters, $object); // Note that $action and $object may have been modified by hook // End of page llxFooter();