Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2020-10-13 11:52:34 +02:00
commit 85f15b5f69
5 changed files with 418 additions and 235 deletions

View File

@ -4,7 +4,8 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2016 Frédéric France <frederic.france@free.fr> * Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com> * Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
* * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
@ -26,6 +27,12 @@
*/ */
require '../../main.inc.php'; 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.'/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.formsocialcontrib.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@ -37,15 +44,9 @@ $langs->loadLangs(array('compta', 'banks', 'bills'));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'sclist'; $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_ref = GETPOST('search_ref', 'int');
$search_label = GETPOST('search_label', 'alpha'); $search_label = GETPOST('search_label', 'alpha');
@ -57,14 +58,16 @@ $search_year_lim = GETPOST('search_year_lim', 'int');
$search_project_ref = GETPOST('search_project_ref', 'alpha'); $search_project_ref = GETPOST('search_project_ref', 'alpha');
$search_project = GETPOST('search_project', 'alpha'); $search_project = GETPOST('search_project', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $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; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortfield) $sortfield = "cs.date_ech"; if (!$sortfield) $sortfield = "cs.date_ech";
if (!$sortorder) $sortorder = "DESC"; if (!$sortorder) $sortorder = "DESC";
@ -84,24 +87,51 @@ if (!GETPOSTISSET('search_typeid'))
$search_typeid = GETPOST('search_typeid', 'int'); $search_typeid = GETPOST('search_typeid', 'int');
} }
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 $arrayfields = array(
{ 'cs.rowid' =>array('label'=>"Ref", 'checked'=>1, 'position'=>10),
$search_ref = ""; 'cs.libelle' =>array('label'=>"Label", 'checked'=>1, 'position'=>20),
$search_label = ""; 'cs.fk_type' =>array('label'=>"Type", 'checked'=>1, 'position'=>30),
$search_amount = ""; '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_status = '';
$search_typeid = ""; $search_typeid = '';
$year = ""; $year = '';
$search_day_lim = ''; $search_day_lim = '';
$search_year_lim = ''; $search_year_lim = '';
$search_month_lim = ''; $search_month_lim = '';
$search_project_ref = ''; $search_project_ref = '';
$search_project = ''; $search_project = '';
$toselect = '';
$search_array_options = array(); $search_array_options = array();
}
} }
/* /*
* View * View
*/ */
@ -114,8 +144,8 @@ if (!empty($conf->projet->enabled)) $projectstatic = new Project($db);
llxHeader('', $langs->trans("SocialContributions")); llxHeader('', $langs->trans("SocialContributions"));
$sql = "SELECT cs.rowid as id, cs.fk_type as type, "; $sql = "SELECT cs.rowid, cs.fk_type as type, ";
$sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode,"; $sql .= " cs.amount, cs.date_ech, cs.libelle, 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,"; 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 .= " c.libelle as type_label,";
$sql .= " SUM(pc.amount) as alreadypayed"; $sql .= " SUM(pc.amount) as alreadypayed";
@ -162,113 +192,180 @@ if ($result)
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if (!$resql)
{ {
$num = $db->num_rows($resql); dol_print_error($db);
$i = 0; llxFooter();
$db->close();
exit;
}
$param = ''; $num = $db->num_rows($resql);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); $i = 0;
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 = ''; $param = '';
if ($user->rights->tax->charges->creer) 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'); $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create');
} }
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="search_status" value="'.$search_status.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="search_status" value="'.$search_status.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$center = ''; $center = '';
if ($year) if ($year)
{ {
$center = ($year ? "<a href='list.php?year=".($year - 1)."'>".img_previous()."</a> ".$langs->trans("Year")." $year <a href='list.php?year=".($year + 1)."'>".img_next()."</a>" : ""); $center = '<a href="list.php?year='.($year - 1).'">'.img_previous().'</a>';
} $center .= ' '.$langs->trans("Year").' '.$year;
$center .= ' <a href="list.php?year='.($year + 1).'">'.img_next().'</a>';
}
print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1); 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)) if (empty($mysoc->country_id) && empty($mysoc->country_code))
{ {
print '<div class="error">'; print '<div class="error">';
$langs->load("errors"); $langs->load("errors");
$countrynotdefined = $langs->trans("ErrorSetACountryFirst"); $countrynotdefined = $langs->trans("ErrorSetACountryFirst");
print $countrynotdefined; print $countrynotdefined;
print '</div>'; print '</div>';
} else {
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre_filter">'; print '</form>';
// Ref 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 '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">'."\n";
print '<tr class="liste_titre_filter">';
// Filters: Line number (placeholder)
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
print '<td class="liste_titre">';
print '</td>';
}
// Filter: Ref
if (!empty($arrayfields['cs.rowid']['checked'])) {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat maxwidth75" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">'; print '<input class="flat maxwidth75" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>'; print '</td>';
// Label }
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
// Type // Filter: Label
if (!empty($arrayfields['cs.rowid']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="flat maxwidth100" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
print '</td>';
}
// Filter: Type
if (!empty($arrayfields['cs.fk_type']['checked'])) {
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
$formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone', 1); $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth100onsmartphone', 1);
print '</td>'; print '</td>';
// Ref Project }
if (!empty($conf->projet->enabled)) print '<td class="liste_titre"><input type="text" class="flat" size="6" name="search_project_ref" value="'.$search_project_ref.'"></td>';
// Date // Filter: Project ref
print '<td class="liste_titre">&nbsp;</td>'; if (!empty($arrayfields['p.ref']['checked'])) {
// Period end date print '<td class="liste_titre">';
print '<input type="text" class="flat" size="6" name="search_project_ref" value="'.$search_project_ref.'">';
print '</td>';
}
// Filter: Date (placeholder)
if (!empty($arrayfields['cs.date_ech']['checked'])) {
print '<td class="liste_titre">';
print '</td>';
}
// Filter: Period end date
if (!empty($arrayfields['cs.periode']['checked'])) {
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_lim" value="'.dol_escape_htmltag($search_day_lim).'">'; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_day_lim" value="'.dol_escape_htmltag($search_day_lim).'">';
print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_lim" value="'.dol_escape_htmltag($search_month_lim).'">'; print '<input class="flat valignmiddle width25" type="text" size="1" maxlength="2" name="search_month_lim" value="'.dol_escape_htmltag($search_month_lim).'">';
$formother->select_year($search_year_lim ? $search_year_lim : -1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); $formother->select_year($search_year_lim ? $search_year_lim : -1, 'search_year_lim', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle');
print '</td>'; print '</td>';
// Amount }
// Filter: Amount
if (!empty($arrayfields['cs.amount']['checked'])) {
print '<td class="liste_titre right">'; print '<td class="liste_titre right">';
print '<input class="flat maxwidth75" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">'; print '<input class="flat maxwidth75" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
print '</td>'; print '</td>';
// Status }
// Filter: Status
if (!empty($arrayfields['cs.paye']['checked'])) {
print '<td class="liste_titre maxwidthonsmartphone right">'; print '<td class="liste_titre maxwidthonsmartphone right">';
$liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid")); $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid"));
print $form->selectarray('search_status', $liststatus, $search_status, 1); print $form->selectarray('search_status', $liststatus, $search_status, 1);
print '</td>'; print '</td>';
}
print '<td class="liste_titre maxwidthsearch">'; // Fields from hook
$searchpicto = $form->showFilterAndCheckAddButtons(0); $parameters = array('arrayfields'=>$arrayfields);
print $searchpicto; $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
print '</td>'; print $hookmanager->resPrint;
print "</tr>\n";
print '<tr class="liste_titre">'; // Filter: Buttons
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "id", "", $param, "", $sortfield, $sortorder); print '<td class="liste_titre maxwidthsearch">';
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "cs.libelle", "", $param, 'class="left"', $sortfield, $sortorder); print $form->showFilterAndCheckAddButtons(0);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); print '</td>';
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 "</tr>\n";
$i = 0; print '</tr>';
$totalarray = array();
while ($i < min($num, $limit)) print '<tr class="liste_titre">';
{ 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 '</tr>';
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$chargesociale_static->id = $obj->id; $chargesociale_static->id = $obj->rowid;
$chargesociale_static->ref = $obj->id; $chargesociale_static->ref = $obj->rowid;
$chargesociale_static->label = $obj->label; $chargesociale_static->label = $obj->libelle;
$chargesociale_static->type_label = $obj->type_label; $chargesociale_static->type_label = $obj->type_label;
if (!empty($conf->projet->enabled)) { if (!empty($conf->projet->enabled)) {
$projectstatic->id = $obj->project_id; $projectstatic->id = $obj->project_id;
@ -278,23 +375,34 @@ if ($resql)
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Ref // Line number
print "<td>".$chargesociale_static->getNomUrl(1, '20')."</td>\n"; if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
print '<td>'.(($offset * $limit) + $i).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
}
// Ref
if (!empty($arrayfields['cs.rowid']['checked'])) {
print '<td>'.$chargesociale_static->getNomUrl(1, '20').'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Label // Label
print "<td>".dol_trunc($obj->label, 42)."</td>\n"; if (!empty($arrayfields['cs.libelle']['checked'])) {
print '<td>'.dol_trunc($obj->libelle, 42).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
}
// Type // Type
print "<td>".$obj->type_label."</td>\n"; if (!empty($arrayfields['cs.fk_type']['checked'])) {
print '<td>'.$obj->type_label.'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
}
// Project Ref // Project ref
if (!empty($conf->projet->enabled)) { if (!empty($arrayfields['p.ref']['checked'])) {
print '<td class="nowrap">'; print '<td class="nowrap">';
if ($obj->project_id > 0) if ($obj->project_id > 0) {
{
print $projectstatic->getNomUrl(1); print $projectstatic->getNomUrl(1);
} }
print '</td>'; print '</td>';
@ -302,48 +410,52 @@ if ($resql)
} }
// Date // Date
if (!empty($arrayfields['cs.date_ech']['checked'])) {
print '<td width="110" align="center">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>'; print '<td width="110" align="center">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
}
// Date end period // Date end period
if (!empty($arrayfields['cs.periode']['checked'])) {
print '<td class="center">'; print '<td class="center">';
if ($obj->periode) if ($obj->periode) {
{ print '<a href="list.php?year='.strftime("%Y", $db->jdate($obj->periode)).'">';
print '<a href="list.php?year='.strftime("%Y", $db->jdate($obj->periode)).'">'.dol_print_date($db->jdate($obj->periode), 'day').'</a>'; print dol_print_date($db->jdate($obj->periode), 'day');
} else { print '</a>';
print '&nbsp;';
} }
print "</td>\n"; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
}
// Amount // Amount
if (!empty($arrayfields['cs.amount']['checked'])) {
print '<td class="nowrap right">'.price($obj->amount).'</td>'; print '<td class="nowrap right">'.price($obj->amount).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
$totalarray['val']['totalttcfield'] += $obj->amount; $totalarray['val']['totalttcfield'] += $obj->amount;
}
// Status
if (!empty($arrayfields['cs.paye']['checked'])) {
print '<td class="nowrap right">'.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>'; print '<td class="nowrap right">'.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
}
// Buttons
print '<td></td>'; print '<td></td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
print '</tr>'; print '</tr>';
$i++; $i++;
}
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print '</table>';
print '</div>';
}
print '</form>';
} else {
dol_print_error($db);
} }
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print '</table>';
print '</div>';
print '</form>';
// End of page // End of page
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -2665,10 +2665,10 @@ if ($action == 'create')
print '</td><td colspan="2">'; print '</td><td colspan="2">';
if ($action == 'editmode') if ($action == 'editmode')
{ {
$form->formTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'transport_mode_id', 1, 1); $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'transport_mode_id', 1, 1);
} }
else { else {
$form->formTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'none'); $form->formSelectTransportMode($_SERVER['PHP_SELF'].'?id='.$object->id, $object->transport_mode_id, 'none');
} }
print '</td></tr>'; print '</td></tr>';

View File

@ -42,6 +42,7 @@ $catname = GETPOST('catname', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$printer1 = GETPOST('printer1', 'alpha'); $printer1 = GETPOST('printer1', 'alpha');
$printer2 = GETPOST('printer2', 'alpha'); $printer2 = GETPOST('printer2', 'alpha');
$printer3 = GETPOST('printer3', 'alpha');
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
@ -64,6 +65,14 @@ if ($action == "SavePrinter2") {
dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_2", $printedcategories, 'chaine', 0, '', $conf->entity);
} }
if ($action == "SavePrinter3") {
$printedcategories = ";";
if (is_array($printer3)) foreach ($printer3 as $cat) {
$printedcategories = $printedcategories.$cat.";";
}
dolibarr_set_const($db, "TAKEPOS_PRINTED_CATEGORIES_3", $printedcategories, 'chaine', 0, '', $conf->entity);
}
/* /*
* View * View
@ -206,6 +215,33 @@ if ($nbofentries > 0)
print '</table></td>'; print '</table></td>';
print '</tr>'; print '</tr>';
} }
//Printer3
print '<table class="liste nohover" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Printer").' 3</td><td></td><td class="right">';
print '</td></tr>';
$nbofentries = (count($data) - 1);
print '<form action="orderprinters.php">';
if ($nbofentries > 0)
{
print '<tr class="pair"><td colspan="3">';
print '<input type="hidden" name="action" value="SavePrinter3">';
foreach ($data as $row) {
if (strpos($conf->global->TAKEPOS_PRINTED_CATEGORIES_3, ';'.$row["rowid"].';') !== false) $checked = 'checked'; else $checked = '';
if ($row["fk_menu"] == 0) print '<input type="checkbox" name="printer3[]" value="'.$row["rowid"].'" '.$checked.'>'.$row["label"].'<br>';
}
print '</td></tr>';
} else {
print '<tr class="pair">';
print '<td colspan="3"><table class="nobordernopadding"><tr class="nobordernopadding"><td>'.img_picto_common('', 'treemenu/branchbottom.gif').'</td>';
print '<td valign="middle">';
print $langs->trans("NoCategoryYet");
print '</td>';
print '<td>&nbsp;</td>';
print '</table></td>';
print '</tr>';
}
print "</table>"; print "</table>";
print '<input type="submit" value="'.$langs->trans("Save").'"></form>'; print '<input type="submit" value="'.$langs->trans("Save").'"></form>';

View File

@ -87,6 +87,7 @@ if (GETPOST('action', 'alpha') == 'set')
$res = dolibarr_set_const($db, "TAKEPOS_PRINTER_TO_USE".$terminaltouse, GETPOST('TAKEPOS_PRINTER_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_PRINTER_TO_USE".$terminaltouse, GETPOST('TAKEPOS_PRINTER_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER1_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER1_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER2_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER2_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER3_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
@ -242,6 +243,10 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") {
print '<td>'; print '<td>';
print $form->selectarray('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}), 1); print $form->selectarray('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal}), 1);
print '</td></tr>'; print '</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 3</td>';
print '<td>';
print $form->selectarray('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal}), 1);
print '</td></tr>';
} }
$printer->listPrintersTemplates(); $printer->listPrintersTemplates();
$templates = array(); $templates = array();

View File

@ -532,8 +532,10 @@ if ($action == "order" and $placeid != 0)
$footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>'; $footerorder = '</tbody></table>'.dol_print_date(dol_now(), 'dayhour').'<br></html>';
$order_receipt_printer1 = ""; $order_receipt_printer1 = "";
$order_receipt_printer2 = ""; $order_receipt_printer2 = "";
$order_receipt_printer3 = "";
$catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1);
$catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2);
$catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3);
foreach ($invoice->lines as $line) foreach ($invoice->lines as $line)
{ {
if ($line->special_code == "4") { if ($line->special_code == "4") {
@ -588,6 +590,34 @@ if ($action == "order" and $placeid != 0)
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed
$db->query($sql); $db->query($sql);
$invoice->fetch($placeid); //Reload object after set lines as printed $invoice->fetch($placeid); //Reload object after set lines as printed
$linestoprint = 0;
foreach ($invoice->lines as $line)
{
if ($line->special_code == "4") {
continue;
}
$c = new Categorie($db);
$existing = $c->containing($line->fk_product, Categorie::TYPE_PRODUCT, 'id');
$result = array_intersect($catsprinter3, $existing);
$count = count($result);
if ($count > 0) {
$linestoprint++;
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='3' where rowid=".$line->id; //Set to print on printer 3
$db->query($sql);
$order_receipt_printer3 .= '<tr>'.$line->product_label.'<td class="right">'.$line->qty;
if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer3 .= "<br>(".$line->array_options['options_order_notes'].")";
$order_receipt_printer3 .= '</td></tr>';
}
}
if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter" && $linestoprint > 0) {
$invoice->fetch($placeid); //Reload object before send to printer
$printer->orderprinter = 3;
$ret = $printer->sendToPrinter($invoice, $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$_SESSION["takeposterminal"]}, $conf->global->{'TAKEPOS_ORDER_PRINTER3_TO_USE'.$_SESSION["takeposterminal"]}); // PRINT TO PRINTER 3
}
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed
$db->query($sql);
$invoice->fetch($placeid); //Reload object after set lines as printed
} }
$sectionwithinvoicelink = ''; $sectionwithinvoicelink = '';