diff --git a/build/perl/virtualmin/dolibarr.pl b/build/perl/virtualmin/dolibarr.pl index 343cebc6abe..8b6a9888db0 100644 --- a/build/perl/virtualmin/dolibarr.pl +++ b/build/perl/virtualmin/dolibarr.pl @@ -1,7 +1,7 @@ #---------------------------------------------------------------------------- # \file dolibarr.pl # \brief Dolibarr script install for Virtualmin Pro -# \author (c)2009-2019 Regis Houssin +# \author (c)2009-2020 Regis Houssin #---------------------------------------------------------------------------- @@ -30,7 +30,7 @@ return "Regis Houssin"; # script_dolibarr_versions() sub script_dolibarr_versions { -return ( "10.0.0", "9.0.3", "8.0.5", "7.0.5", "6.0.8" ); +return ( "12.0.3", "11.0.5", "10.0.7", "9.0.4", "8.0.6", "7.0.5" ); } sub script_dolibarr_release @@ -77,6 +77,16 @@ if ($ver >= 3.6) { push(@rv, "Dolibarr requires PHP version 5.3 or later"); } } +if ($ver >= 12.0) { + # Check for PHP 5.6+ + local $phpv = &get_php_version($phpver || 5, $d); + if (!$phpv) { + push(@rv, "Could not work out exact PHP version"); + } + elsif ($phpv < 5.6) { + push(@rv, "Dolibarr requires PHP version 5.6 or later"); + } + } return @rv; } @@ -376,7 +386,7 @@ sub script_dolibarr_realversion local ($d, $opts, $sinfo) = @_; local $lref = &read_file_lines("$opts->{'dir'}/filefunc.inc.php", 1); foreach my $l (@$lref) { - if ($l =~ /'DOL_VERSION','([0-9a-z\.\-]+)'/) { + if ($l =~ /'DOL_VERSION',\s?'([0-9a-z\.\-]+)'/) { return $1; } } @@ -390,6 +400,8 @@ sub script_dolibarr_check_latest { local ($ver) = @_; local @vers = &osdn_package_versions("dolibarr", + $ver >= 12.0 ? "dolibarr\\-(12\\.0\\.[0-9\\.]+)\\.tgz" : + $ver >= 11.0 ? "dolibarr\\-(11\\.0\\.[0-9\\.]+)\\.tgz" : $ver >= 10.0 ? "dolibarr\\-(10\\.0\\.[0-9\\.]+)\\.tgz" : $ver >= 9.0 ? "dolibarr\\-(9\\.0\\.[0-9\\.]+)\\.tgz" : $ver >= 8.0 ? "dolibarr\\-(8\\.0\\.[0-9\\.]+)\\.tgz" : @@ -410,7 +422,7 @@ return $ver eq $vers[0] ? undef : $vers[0]; sub script_dolibarr_site { -return 'http://www.dolibarr.org/'; +return 'https://www.dolibarr.org/'; } sub script_dolibarr_passmode diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index ec6dc9d4a88..7857773924f 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -49,7 +49,7 @@ llxHeader(); print load_fiche_titre($langs->trans("PerfDolibarr"), '', 'title_setup'); -print $langs->trans("YouMayFindPerfAdviceHere", 'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' ('.$langs->trans("Reload").')
'; +print ''.$langs->trans("YouMayFindPerfAdviceHere", 'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' ('.$langs->trans("Reload").')
'; // Recupere la version de PHP $phpversion = version_php(); diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php new file mode 100644 index 00000000000..0cf70f2bbaa --- /dev/null +++ b/htdocs/admin/system/security.php @@ -0,0 +1,143 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/system/security.php + * \brief Page to show Security information + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array("install", "other", "admin")); + +if (!$user->admin) + accessforbidden(); + +if (GETPOST('action', 'aZ09') == 'donothing') +{ + exit; +} + + +/* + * View + */ + +$form = new Form($db); +$nowstring = dol_print_date(dol_now(), 'dayhourlog'); + +llxHeader(); + +print load_fiche_titre($langs->trans("Security"), '', 'title_setup'); + +print ''.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').' ('.$langs->trans("Reload").')
'; + +// Recupere la version de PHP +$phpversion = version_php(); +print "
PHP - ".$langs->trans("Version").": ".$phpversion."
\n"; + +// Recupere la version du serveur web +print "
Web server - ".$langs->trans("Version").": ".$_SERVER["SERVER_SOFTWARE"]."
\n"; +print '
'; + + +print load_fiche_titre($langs->trans("ConfigFile"), '', ''); + +print ''.$langs->trans("dolibarr_main_prod").': '.$dolibarr_main_prod; +// dolibarr_main_prod + + +print '
'; +print '
'; + +print load_fiche_titre($langs->trans("PermissionsOnFiles"), '', ''); + +print ''.$langs->trans("PermissionOnFileInWebRoot").': '; +// TODO + + +print '
'; +print '
'; + + +print load_fiche_titre($langs->trans("Modules"), '', ''); + +// XDebug +print ''.$langs->trans("XDebug").': '; +$test = !function_exists('xdebug_is_enabled'); +if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); +else { + print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedMayExposeInformation", $langs->transnoentities("XDebug")); + print ' - '.$langs->trans("MoreInformation").' XDebug admin page'; +} +print '
'; + +// Module log +print '
'; +print ''.$langs->trans("Syslog").': '; +$test = empty($conf->syslog->enabled); +if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); +else { + print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedMayExposeInformation", $langs->transnoentities("Syslog")); + //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; +} +print '
'; + +// Module debugbar +print '
'; +print ''.$langs->trans("DebugBar").': '; +$test = empty($conf->debugbar->enabled); +if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); +else { + print img_picto('', 'error').' '.$langs->trans("ModuleActivatedDoNotUseInProduction", $langs->transnoentities("DebugBar")); + //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; +} +print '
'; +print '
'; + +print load_fiche_titre($langs->trans("SecuritySetup"), '', ''); + +//print ''.$langs->trans("PasswordEncryption").': '; +print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."   (Recommanded value: 'password_hash')
"; +print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT.'
'; +print '
'; +// TODO + +print ''.$langs->trans("AntivirusEnabledOnUpload").': '; +// TODO +print '
'; + +print ''.$langs->trans("SecurityAudit").': '; +// TODO Disabled or enabled ? +print '
'; + + + + + + + + + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 3c8ed94c2bf..4b88cc7797a 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1068,12 +1068,14 @@ if ($action == 'create') // Location if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { - print ''.$langs->trans("Location").''; + print ''.$langs->trans("Location").''; } // Assigned to print ''.$langs->trans("ActionAffectedTo").''; $listofuserid = array(); + $listofcontactid = array(); + $listofotherid = array(); if (empty($donotclearsession)) { $assignedtouser = GETPOST("assignedtouser") ?GETPOST("assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id); @@ -1090,12 +1092,6 @@ if ($action == 'create') print '
'; print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid); print '
'; - /*if (in_array($user->id,array_keys($listofuserid))) - { - print '
'; - print $langs->trans("MyAvailability").': '.$langs->trans("Busy"); - print '
'; - }*/ print ''; // Done by @@ -1108,9 +1104,9 @@ if ($action == 'create') if ($conf->categorie->enabled) { // Categories - print ''.$langs->trans("Categories").''; + print ''.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1); - print $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, '', 0, '100%'); + print $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'minwidth300 quatrevingtpercent', 0, 0); print ""; } @@ -1148,7 +1144,8 @@ if ($action == 'create') print ''.$langs->trans("ActionOnContact").''; $preselectedids = GETPOST('socpeopleassigned', 'array'); if (GETPOST('contactid', 'int')) $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int'); - print img_picto('', 'contact', 'class="paddingrightonly"').$form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); + print img_picto('', 'contact', 'class="paddingrightonly"'); + print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid'); print ''; } @@ -1161,7 +1158,7 @@ if ($action == 'create') print ''.$langs->trans("Project").''; print img_picto('', 'project', 'class="paddingrightonly"'); - $numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); + $numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500 widthcentpercentminusxx'); print ' '; $urloption = '?action=create&donotclearsession=1'; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index a48dc03aea2..7a52183b195 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -360,7 +360,9 @@ if (empty($action) || $action == 'show_month') $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y"); $nav .= " \n"; $nav .= "   \n"; - $nav .= "   ".$langs->trans("Today")." "; + if (empty($conf->dol_optimize_smallscreen)) { + $nav .= "   ".$langs->trans("Today")." "; + } $picto = 'calendar'; } if ($action == 'show_week') @@ -369,7 +371,9 @@ if ($action == 'show_week') $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; $nav .= " \n"; $nav .= "   trans("Next"))."\">\n"; - $nav .= "   ".$langs->trans("Today")." "; + if (empty($conf->dol_optimize_smallscreen)) { + $nav .= "   ".$langs->trans("Today")." "; + } $picto = 'calendarweek'; } if ($action == 'show_day') @@ -378,7 +382,9 @@ if ($action == 'show_day') $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort"); $nav .= " \n"; $nav .= "   \n"; - $nav .= "   ".$langs->trans("Today")." "; + if (empty($conf->dol_optimize_smallscreen)) { + $nav .= "   ".$langs->trans("Today")." "; + } $picto = 'calendarday'; } diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 72b25c9d731..f0c1a0d1951 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -274,34 +274,17 @@ $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); $tmpday = $first_day; -$picto = 'calendartype'; +$picto = 'calendarweek'; $nav = "".img_previous($langs->trans("Previous"))."\n"; $nav .= " ".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y")." \n"; $nav .= "".img_next($langs->trans("Next"))."\n"; -$nav .= "   (".$langs->trans("Today").")"; -$picto = 'calendarweek'; +if (empty($conf->dol_optimize_smallscreen)) { + $nav .= "   (".$langs->trans("Today").")"; +} -/*$nav .= '  
'; -$nav .= ''; -$nav .= ''; -$nav .= ''; -$nav .= ''; -$nav .= ''; -$nav .= ''; -$nav .= ''; -$nav .= ''; -$nav .= ''; -$nav .= ''; -$nav .= ''; -$nav .= ''; -$nav .= ''; -$nav .= ''; -*/ $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -//$nav .= ' '; $nav .= ' '; -//$nav .= '
'; // Must be after the nav definition $param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($day) : ''); diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index f99cc3cbd16..899925b16f6 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -285,28 +285,11 @@ $nav = "".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week; $nav .= " \n"; $nav .= "   trans("Next"))."\">\n"; -$nav .= "   ".$langs->trans("Today")." "; - -/*$nav.='  
'; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -$nav.=''; -*/ +if (empty($conf->dol_optimize_smallscreen)) { + $nav .= "   ".$langs->trans("Today")." "; +} $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); -//$nav .= ' '; $nav .= ' '; -//$nav.='
'; // Must be after the nav definition $param .= '&year='.urlencode($year).'&month='.urlencode($month).($day ? '&day='.urlencode($day) : ''); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 7e34ac6fc3c..525a267dacc 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3153,7 +3153,7 @@ class Propal extends CommonObject $sql .= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; $sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_cloture"; $sql .= " FROM ".MAIN_DB_PREFIX."propal as c"; - $sql .= " WHERE c.rowid = ".$id; + $sql .= " WHERE c.rowid = ".((int) $id); $result = $this->db->query($sql); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 00815c90f7d..cc882b5f1ee 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -98,7 +98,7 @@ class RemiseCheque extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON bc.fk_bank_account = ba.rowid"; $sql .= " WHERE bc.entity = ".$conf->entity; - if ($id) $sql .= " AND bc.rowid = ".$id; + if ($id) $sql .= " AND bc.rowid = ".((int) $id); if ($ref) $sql .= " AND bc.ref = '".$this->db->escape($ref)."'"; dol_syslog("RemiseCheque::fetch", LOG_DEBUG); diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 1ee79aeafd9..5e71ff5c50c 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -99,6 +99,7 @@ $sql .= $db->plimit($max); $resql = $db->query($sql); if ($resql) { + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; print ''; @@ -126,9 +127,9 @@ if ($resql) print ''."\n"; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -136,6 +137,7 @@ if ($resql) print ''; } print "
'.$langs->trans("LastCheckReceiptShort", $max).'
'.$checkdepositstatic->getNomUrl(1).''.$checkdepositstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->db), 'day').''.$accountstatic->getNomUrl(1).''.$accountstatic->getNomUrl(1).''.$objp->nbcheque.''.price($objp->amount).''.$checkdepositstatic->LibStatut($objp->statut, 3).'
"; + print '
'; $db->free($resql); } else { diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index bd7f6147f2d..c4910e431e5 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -4,7 +4,8 @@ * 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 @@ -20,12 +21,18 @@ */ /** - * \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'; @@ -35,36 +42,32 @@ if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/clas // Load translation files required by the page $langs->loadLangs(array('compta', 'banks', 'bills')); -$action = GETPOST('action', 'aZ09'); -$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'; +$action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); +$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_ref = GETPOST('search_ref', 'int'); +$search_label = GETPOST('search_label', 'alpha'); +$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_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'); +$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'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$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 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; + if (!$sortfield) $sortfield = "cs.date_ech"; if (!$sortorder) $sortorder = "DESC"; @@ -84,23 +87,50 @@ if (!GETPOSTISSET('search_typeid')) $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 -{ - $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(); -} +$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(); + } +} /* * View @@ -114,8 +144,8 @@ if (!empty($conf->projet->enabled)) $projectstatic = new Project($db); llxHeader('', $langs->trans("SocialContributions")); -$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,"; +$sql = "SELECT cs.rowid, cs.fk_type as type, "; +$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,"; $sql .= " c.libelle as type_label,"; $sql .= " SUM(pc.amount) as alreadypayed"; @@ -135,19 +165,19 @@ $sql .= dolSqlDateFilter("cs.periode", $search_day_lim, $search_month_lim, $sear //$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') = '".$db->escape($year)."') "; + $sql .= "OR (cs.periode IS NULL AND date_format(cs.date_ech, '%Y') = '".$db->escape($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"; @@ -157,193 +187,275 @@ $totalnboflines = 0; $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', 1); - 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); + 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(); $db->close(); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 8ea6ebea0d4..91a32f39f26 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -879,7 +879,7 @@ class Contact extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcommcontact as st ON c.fk_stcommcontact = st.id'; - if ($id) $sql .= " WHERE c.rowid = ".$id; + if ($id) $sql .= " WHERE c.rowid = ".((int) $id); else { $sql .= " WHERE c.entity IN (".getEntity($this->element).")"; if ($ref_ext) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e179bd50797..0b62146b080 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2028,7 +2028,7 @@ class Contrat extends CommonObject $sql .= " c.tms as date_modification,"; $sql .= " fk_user_author"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c"; - $sql .= " WHERE c.rowid = ".$id; + $sql .= " WHERE c.rowid = ".((int) $id); $result = $this->db->query($sql); if ($result) diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index a083576aacb..39ae2eb63ef 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -186,7 +186,7 @@ class Comment extends CommonObject $sql .= " c.entity,"; $sql .= " c.import_key"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c"; - $sql .= " WHERE c.rowid = ".$id; + $sql .= " WHERE c.rowid = ".((int) $id); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index feddd6e4f24..452454ced5b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1848,7 +1848,7 @@ class Form if ($ownerid == $value['id'] && is_array($listofuserid) && count($listofuserid) && in_array($ownerid, array_keys($listofuserid))) { $out .= '
'; - $out .= ' - '.$langs->trans("Availability").': '.$langs->trans("Busy"); + $out .= ' - '.$langs->trans("Availability").': '; $out .= '
'; } } @@ -5578,7 +5578,6 @@ class Form } // Show date with combo selects else { - //$retstring.='
'; // Day $retstring .= ''; @@ -5622,11 +5621,13 @@ class Form } $retstring .= "\n"; } - //$retstring.='
'; } } - if ($d && $h) $retstring .= ($h == 2 ? '
' : ' '); + if ($d && $h) { + $retstring .= ($h == 2 ? '
' : ' '); + $retstring.=''; + } if ($h) { @@ -5644,10 +5645,13 @@ class Form for ($hour = $hourstart; $hour < $hourend; $hour++) { if (strlen($hour) < 2) $hour = "0".$hour; - $retstring .= ''; + $retstring .= ''; } $retstring .= ''; - if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":"; + //if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":"; + if ($m) $retstring .= ":"; } if ($m) @@ -5665,6 +5669,10 @@ class Form $retstring .= ''; } + if ($d && $h) { + $retstring .= ''; + } + // Add a "Now" link if ($conf->use_javascript_ajax && $addnowlink) { @@ -7257,7 +7265,7 @@ class Form } if ($morehtml) { - $ret .= '
  • '.$morehtml.'
  • '; + $ret .= '
  • '.$morehtml.'
  • '; } if ($shownav && ($previous_ref || $next_ref)) { diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 9586adeaed4..eac04cfefc1 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -353,7 +353,7 @@ class FormProjets include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); $out .= $comboenhancement; - $morecss = 'minwidth200imp maxwidth500'; + $morecss = 'minwidth200 maxwidth500'; } if (empty($option_only)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 47a5d3d9330..7b705b4bd87 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1522,8 +1522,9 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]); $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5); if ($conf->browser->layout == 'phone') $maxvisiblephotos = 1; - if ($showimage) $morehtmlleft .= '
    '.$object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0).'
    '; - else { + if ($showimage) { + $morehtmlleft .= '
    '.$object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0).'
    '; + } else { if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) { $nophoto = ''; $morehtmlleft .= '
    '; @@ -1610,9 +1611,9 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi // If the preview file is found if (file_exists($fileimage)) { - $phototoshow = '
    '; + $phototoshow = '
    '; $phototoshow .= ''; - $phototoshow .= '
    '; + $phototoshow .= '
    '; } } } elseif (!$phototoshow) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index db79efefc45..bf957dc40a6 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2017,7 +2017,25 @@ function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0) if ($object->lines[$i]->special_code == 3) { $result .= $outputlangs->transnoentities("Option"); - } elseif (empty($hidedetails) || $hidedetails > 1) $result .= price($sign * ($object->lines[$i]->total_ht) + ($object->lines[$i]->total_ht) * ($object->lines[$i]->tva_tx) / 100, 0, $outputlangs); + } + if (empty($hidedetails) || $hidedetails > 1) + { + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->lines[$i]->multicurrency_total_ttc : $object->lines[$i]->total_ttc); + if ($object->lines[$i]->situation_percent > 0) + { + // TODO Remove this. The total should be saved correctly in database instead of being modified here. + $prev_progress = 0; + $progress = 1; + if (method_exists($object->lines[$i], 'get_prev_progress')) + { + $prev_progress = $object->lines[$i]->get_prev_progress($object->id); + $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100; + } + $result .= price($sign * ($total_ttc / ($object->lines[$i]->situation_percent / 100)) * $progress, 0, $outputlangs); + } else { + $result .= price($sign * $total_ttc, 0, $outputlangs); + } + } } return $result; } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 603fd4efa22..324f7c83fd0 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -224,9 +224,16 @@ class pdf_einstein extends ModelePDFCommandes // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + global $outputlangsbis; + $outputlangsbis = new Translate('', $conf); + $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); + $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); + } + $nblines = count($object->lines); - if ($conf->commande->dir_output) + if ($conf->commande->multidir_output[$conf->entity]) { $object->fetch_thirdparty(); @@ -325,7 +332,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->AddPage(); if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); @@ -335,6 +342,7 @@ class pdf_einstein extends ModelePDFCommandes $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); // Incoterm + $height_incoterms = 0; if ($conf->incoterm->enabled) { $desc_incoterms = $object->getIncotermsForPDF(); @@ -585,15 +593,17 @@ class pdf_einstein extends ModelePDFCommandes } // Show square - if ($pagenb == 1) + if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); - else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + } else { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + } $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - // Affiche zone infos + // Display infos area $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); - // Affiche zone totaux + // Display total zone $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements @@ -664,7 +674,7 @@ class pdf_einstein extends ModelePDFCommandes * @param Object $object Object to show * @param int $posy Y * @param Translate $outputlangs Langs object - * @return void + * @return int */ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs) { @@ -783,20 +793,22 @@ class pdf_einstein extends ModelePDFCommandes // Si mode reglement non force ou si force a CHQ if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { - if ($conf->global->FACTURE_CHQ_NUMBER > 0) + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + + if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); $account->fetch($conf->global->FACTURE_CHQ_NUMBER); $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('', 'B', $default_font_size - 3); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('', '', $default_font_size - 3); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); $posy = $pdf->GetY() + 2; } @@ -804,14 +816,14 @@ class pdf_einstein extends ModelePDFCommandes if ($conf->global->FACTURE_CHQ_NUMBER == -1) { $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('', 'B', $default_font_size - 3); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('', '', $default_font_size - 3); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); $posy = $pdf->GetY() + 2; } @@ -822,10 +834,10 @@ class pdf_einstein extends ModelePDFCommandes // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { - if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) + if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) { - $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); - if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank + $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); + if ($object->fk_bank > 0) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank $account = new Account($this->db); $account->fetch($bankid); @@ -856,15 +868,23 @@ class pdf_einstein extends ModelePDFCommandes protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf, $mysoc; + global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); + $outputlangsbis = null; + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + $outputlangsbis = new Translate('', $conf); + $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); + $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); + $default_font_size--; + } + $tab2_top = $posy; $tab2_hl = 4; $pdf->SetFont('', '', $default_font_size - 1); - // Tableau total + // Total table $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { @@ -878,7 +898,7 @@ class pdf_einstein extends ModelePDFCommandes // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1); $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); @@ -918,7 +938,8 @@ class pdf_einstein extends ModelePDFCommandes $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); + $totalvat .= ' '; $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); @@ -949,7 +970,8 @@ class pdf_einstein extends ModelePDFCommandes $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); + $totalvat .= ' '; $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); @@ -975,7 +997,8 @@ class pdf_einstein extends ModelePDFCommandes $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' '; + $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : ''); + $totalvat .= ' '; $totalvat .= vatrate($tvakey, 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); @@ -1006,8 +1029,9 @@ class pdf_einstein extends ModelePDFCommandes $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' '; - + $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : ''); + $totalvat .= ' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); @@ -1025,6 +1049,7 @@ class pdf_einstein extends ModelePDFCommandes foreach ($localtax_rate as $tvakey => $tvaval) { + // retrieve global local tax if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; @@ -1038,8 +1063,9 @@ class pdf_einstein extends ModelePDFCommandes $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' '; - + $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : ''); + $totalvat .= ' '; + $totalvat .= vatrate(abs($tvakey), 1).$tvacompl; $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); @@ -1055,7 +1081,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalTTC", $mysoc->country_code) : ''), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); @@ -1078,7 +1104,7 @@ class pdf_einstein extends ModelePDFCommandes $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0); @@ -1086,7 +1112,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 60); $pdf->SetFillColor(224, 224, 224); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1); @@ -1111,9 +1137,10 @@ class pdf_einstein extends ModelePDFCommandes * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title * @param int $hidebottom Hide bottom bar of array * @param string $currency Currency code + * @param Translate $outputlangsbis Langs object bis * @return void */ - protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null) { global $conf; @@ -1131,6 +1158,10 @@ class pdf_einstein extends ModelePDFCommandes if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency)); + } + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); @@ -1214,10 +1245,11 @@ class pdf_einstein extends ModelePDFCommandes * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output + * @param Translate $outputlangsbis Object lang for output bis * @param string $titlekey Translation key to show as title of document * @return int Return topshift value */ - protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle") + protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle") { // phpcs:enable global $conf, $langs, $hookmanager; @@ -1238,8 +1270,10 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); + $w = 100; + $posy = $this->marge_haute; - $posx = $this->page_largeur - $this->marge_droite - 100; + $posx = $this->page_largeur - $this->marge_droite - $w; $pdf->SetXY($this->marge_gauche, $posy); @@ -1263,12 +1297,12 @@ class pdf_einstein extends ModelePDFCommandes } else { $pdf->SetTextColor(200, 0, 0); $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); } } else { $text = $this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); + $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } @@ -1276,7 +1310,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities($titlekey); - $pdf->MultiCell(100, 3, $title, '', 'R'); + $pdf->MultiCell($w, 3, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); @@ -1293,7 +1327,7 @@ class pdf_einstein extends ModelePDFCommandes $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) @@ -1323,14 +1357,14 @@ class pdf_einstein extends ModelePDFCommandes $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) { $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } // Get contact @@ -1344,7 +1378,7 @@ class pdf_einstein extends ModelePDFCommandes $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); + $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } @@ -1353,7 +1387,7 @@ class pdf_einstein extends ModelePDFCommandes $top_shift = 0; // Show list of linked objects $current_y = $pdf->getY(); - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); if ($current_y < $pdf->getY()) { $top_shift = $pdf->getY() - $current_y; @@ -1402,8 +1436,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); - - // If CUSTOMER contact defined on order, we use it + // If CUSTOMER contact defined, we use it $usecontact = false; $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) @@ -1425,9 +1458,10 @@ class pdf_einstein extends ModelePDFCommandes $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox = 100; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format - $posy = 42 + $top_shift; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy += $top_shift; $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; @@ -1441,7 +1475,7 @@ class pdf_einstein extends ModelePDFCommandes // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); + $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); $posy = $pdf->getY(); diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index e6e54e521d8..bfbc798d4bb 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -120,7 +120,12 @@ class pdf_eratosthene extends ModelePDFCommandes */ public $emetteur; - + /** + * @var array of document table collumns + */ + public $cols; + + /** * Constructor * @@ -165,11 +170,13 @@ class pdf_eratosthene extends ModelePDFCommandes if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxdesc = $this->marge_gauche + 1; + $this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff $this->tabTitleHeight = 5; // default height + // Use new system for position of columns, view $this->defineColumnField() + $this->tva = array(); $this->localtax1 = array(); $this->localtax2 = array(); @@ -242,7 +249,11 @@ class pdf_eratosthene extends ModelePDFCommandes { if (!$arephoto) { - $dir = $conf->product->dir_output.'/'.$midir; + if ($conf->product->entity != $objphoto->entity) { + $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities + } else { + $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product + } foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { @@ -271,7 +282,7 @@ class pdf_eratosthene extends ModelePDFCommandes - if ($conf->commande->dir_output) + if ($conf->commande->multidir_output[$conf->entity]) { $object->fetch_thirdparty(); @@ -345,20 +356,21 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right - /// Does we have at least one line with discount $this->atleastonediscount - foreach ($object->lines as $line) { - if ($line->remise_percent) { - $this->atleastonediscount = true; - break; - } + // Set $this->atleastonediscount if you have at least one discount + for ($i = 0; $i < $nblines; $i++) + { + if ($object->lines[$i]->remise_percent) + { + $this->atleastonediscount++; + } } - + // New page $pdf->AddPage(); if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); @@ -368,6 +380,7 @@ class pdf_eratosthene extends ModelePDFCommandes $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); // Incoterm + $height_incoterms = 0; if ($conf->incoterm->enabled) { $desc_incoterms = $object->getIncotermsForPDF(); @@ -404,15 +417,16 @@ class pdf_eratosthene extends ModelePDFCommandes // Extrafields in note $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); - if (!empty($extranote)) - { + if (!empty($extranote)) { $notetoshow = dol_concatdesc($notetoshow, $extranote); } $pagenb = $pdf->getPage(); if ($notetoshow) { - $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; + $tab_top -= 2; + + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; $pageposbeforenote = $pagenb; $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object); @@ -420,8 +434,6 @@ class pdf_eratosthene extends ModelePDFCommandes $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); - $tab_top -= 2; - $pdf->startTransaction(); $pdf->SetFont('', '', $default_font_size - 1); @@ -582,6 +594,7 @@ class pdf_eratosthene extends ModelePDFCommandes } } + // Description of product line if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); @@ -632,7 +645,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - // We suppose that a too long description is moved completely on next page + // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } @@ -681,7 +694,7 @@ class pdf_eratosthene extends ModelePDFCommandes $nexY = max($pdf->GetY(), $nexY); } - // Total HT line + // Total excl tax line (HT) if ($this->getColumnStatus('totalexcltax')) { $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); @@ -689,7 +702,15 @@ class pdf_eratosthene extends ModelePDFCommandes $nexY = max($pdf->GetY(), $nexY); } - // Extrafields + // Total with tax line (TTC) + if ($this->getColumnStatus('totalincltax')) + { + $total_incl_tax = pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails); + $this->printStdColumnContent($pdf, $curY, 'totalincltax', $total_incl_tax); + $nexY = max($pdf->GetY(), $nexY); + } + + // Extrafields if (!empty($object->lines[$i]->array_options)) { foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) { if ($this->getColumnStatus($extrafieldColKey)) @@ -795,14 +816,17 @@ class pdf_eratosthene extends ModelePDFCommandes // Show square if ($pagenb == $pageposbeforeprintlines) + { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); - else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + } else { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + } $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - // Affiche zone infos + // Display infos area $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs); - // Affiche zone totaux + // Display total zone $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements @@ -986,20 +1010,22 @@ class pdf_eratosthene extends ModelePDFCommandes // Si mode reglement non force ou si force a CHQ if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { - if ($conf->global->FACTURE_CHQ_NUMBER > 0) + $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE); + + if ($conf->global->FACTURE_CHQ_NUMBER > 0) { $account = new Account($this->db); $account->fetch($conf->global->FACTURE_CHQ_NUMBER); $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('', 'B', $default_font_size - 3); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('', '', $default_font_size - 3); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); $posy = $pdf->GetY() + 2; } @@ -1007,14 +1033,14 @@ class pdf_eratosthene extends ModelePDFCommandes if ($conf->global->FACTURE_CHQ_NUMBER == -1) { $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('', 'B', $default_font_size - 3); + $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); $posy = $pdf->GetY() + 1; if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) { $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('', '', $default_font_size - 3); + $pdf->SetFont('', '', $default_font_size - $diffsizetitle); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); $posy = $pdf->GetY() + 2; } @@ -1025,10 +1051,10 @@ class pdf_eratosthene extends ModelePDFCommandes // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { - if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) + if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) { - $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); - if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank + $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); + if ($object->fk_bank > 0) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank $account = new Account($this->db); $account->fetch($bankid); @@ -1057,30 +1083,32 @@ class pdf_eratosthene extends ModelePDFCommandes */ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs) { - global $conf, $mysoc; + global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); - $tab2_top = $posy; - $tab2_hl = 4; - $pdf->SetFont('', '', $default_font_size - 1); - - // Tableau total - $col1x = 120; $col2x = 170; - if ($this->page_largeur < 210) // To work with US executive format - { - $col2x -= 20; - } - $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); - $useborder = 0; - $index = 0; - $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); + $default_font_size--; } + + $tab2_top = $posy; + $tab2_hl = 4; + $pdf->SetFont('', '', $default_font_size - 1); + + // Total table + $col1x = 120; $col2x = 170; + if ($this->page_largeur < 210) // To work with US executive format + { + $col2x -= 20; + } + $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); + + $useborder = 0; + $index = 0; // Total HT $pdf->SetFillColor(255, 255, 255); @@ -1234,6 +1262,7 @@ class pdf_eratosthene extends ModelePDFCommandes foreach ($localtax_rate as $tvakey => $tvaval) { + // retrieve global local tax if ($tvakey != 0) // On affiche pas taux 0 { //$this->atleastoneratenotnull++; @@ -1321,9 +1350,10 @@ class pdf_eratosthene extends ModelePDFCommandes * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title * @param int $hidebottom Hide bottom bar of array * @param string $currency Currency code + * @param Translate $outputlangsbis Langs object bis * @return void */ - protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null) { global $conf; @@ -1341,6 +1371,10 @@ class pdf_eratosthene extends ModelePDFCommandes if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency)); + } + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); @@ -1373,10 +1407,11 @@ class pdf_eratosthene extends ModelePDFCommandes * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output + * @param Translate $outputlangsbis Object lang for output bis * @param string $titlekey Translation key to show as title of document * @return int Return topshift value */ - protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle") + protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey = "PdfOrderTitle") { // phpcs:enable global $conf, $langs, $hookmanager; @@ -1397,8 +1432,10 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); + $w = 100; + $posy = $this->marge_haute; - $posx = $this->page_largeur - $this->marge_droite - 100; + $posx = $this->page_largeur - $this->marge_droite - $w; $pdf->SetXY($this->marge_gauche, $posy); @@ -1422,12 +1459,12 @@ class pdf_eratosthene extends ModelePDFCommandes } else { $pdf->SetTextColor(200, 0, 0); $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); } } else { $text = $this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); + $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } @@ -1435,7 +1472,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities($titlekey); - $pdf->MultiCell(100, 3, $title, '', 'R'); + $pdf->MultiCell($w, 4, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); @@ -1449,10 +1486,10 @@ class pdf_eratosthene extends ModelePDFCommandes if ($object->ref_client) { - $posy += 5; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) @@ -1483,14 +1520,14 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) { $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } // Get contact @@ -1504,7 +1541,7 @@ class pdf_eratosthene extends ModelePDFCommandes $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); + $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } @@ -1513,7 +1550,7 @@ class pdf_eratosthene extends ModelePDFCommandes $top_shift = 0; // Show list of linked objects $current_y = $pdf->getY(); - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); if ($current_y < $pdf->getY()) { $top_shift = $pdf->getY() - $current_y; @@ -1562,8 +1599,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); - - // If CUSTOMER contact defined on order, we use it + // If CUSTOMER contact defined, we use it $usecontact = false; $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) @@ -1585,9 +1621,10 @@ class pdf_eratosthene extends ModelePDFCommandes $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox = 100; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format - $posy = 42 + $top_shift; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy += $top_shift; $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; @@ -1601,7 +1638,7 @@ class pdf_eratosthene extends ModelePDFCommandes // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); + $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); $posy = $pdf->getY(); @@ -1690,7 +1727,7 @@ class pdf_eratosthene extends ModelePDFCommandes 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', @@ -1698,6 +1735,7 @@ class pdf_eratosthene extends ModelePDFCommandes ), ); + // Image of product $rank = $rank + 10; $this->cols['photo'] = array( 'rank' => $rank, @@ -1789,14 +1827,25 @@ class pdf_eratosthene extends ModelePDFCommandes $this->cols['totalexcltax'] = array( 'rank' => $rank, 'width' => 26, // in mm - 'status' => true, + 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false, 'title' => array( 'textkey' => 'TotalHT' ), 'border-left' => true, // add left line separator ); - // Add extrafields cols + $rank = $rank + 1010; // add a big offset to be sure is the last col because default extrafield rank is 100 + $this->cols['totalincltax'] = array( + 'rank' => $rank, + 'width' => 26, // in mm + 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ? false : true, + 'title' => array( + 'textkey' => 'TotalTTC' + ), + 'border-left' => true, // add left line separator + ); + + // Add extrafields cols if (!empty($object->lines)) { $line = reset($object->lines); $this->defineColumnExtrafield($line, $outputlangs, $hidedetails); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index bab3bbd9e71..bd7b055c28e 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -289,7 +289,7 @@ class pdf_sponge extends ModelePDFFactures //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva; - if ($conf->facture->dir_output) + if ($conf->facture->multidir_output[$conf->entity]) { $object->fetch_thirdparty(); @@ -300,11 +300,11 @@ class pdf_sponge extends ModelePDFFactures // Definition of $dir and $file if ($object->specimen) { - $dir = $conf->facture->dir_output; + $dir = $conf->facture->multidir_output[$conf->entity]; $file = $dir."/SPECIMEN.pdf"; } else { $objectref = dol_sanitizeFileName($object->ref); - $dir = $conf->facture->dir_output."/".$objectref; + $dir = $conf->facture->multidir_output[$conf->entity]."/".$objectref; $file = $dir."/".$objectref.".pdf"; } if (!file_exists($dir)) @@ -386,14 +386,15 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right - // Does we have at least one line with discount $this->atleastonediscount - foreach ($object->lines as $line) { - if ($line->remise_percent) { - $this->atleastonediscount = true; - break; + // Set $this->atleastonediscount if you have at least one discount + for ($i = 0; $i < $nblines; $i++) + { + if ($object->lines[$i]->remise_percent) + { + $this->atleastonediscount++; } } - + // Situation invoice handling if ($object->situation_cycle_ref) @@ -458,8 +459,7 @@ class pdf_sponge extends ModelePDFFactures // Extrafields in note $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); - if (!empty($extranote)) - { + if (!empty($extranote)) { $notetoshow = dol_concatdesc($notetoshow, $extranote); } @@ -735,7 +735,7 @@ class pdf_sponge extends ModelePDFFactures $nexY = max($pdf->GetY(), $nexY); } - // Total HT line + // Total excl tax line (HT) if ($this->getColumnStatus('totalexcltax')) { $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); @@ -743,6 +743,14 @@ class pdf_sponge extends ModelePDFFactures $nexY = max($pdf->GetY(), $nexY); } + // Total with tax line (TTC) + if ($this->getColumnStatus('totalincltax')) + { + $total_incl_tax = pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails); + $this->printStdColumnContent($pdf, $curY, 'totalincltax', $total_incl_tax); + $nexY = max($pdf->GetY(), $nexY); + } + // Extrafields if (!empty($object->lines[$i]->array_options)) { foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) { @@ -2216,7 +2224,7 @@ class pdf_sponge extends ModelePDFFactures ), ); - // PHOTO + // Image of product $rank = $rank + 10; $this->cols['photo'] = array( 'rank' => $rank, @@ -2324,13 +2332,24 @@ class pdf_sponge extends ModelePDFFactures $this->cols['totalexcltax'] = array( 'rank' => $rank, 'width' => 26, // in mm - 'status' => true, + 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false, 'title' => array( 'textkey' => 'TotalHT' ), 'border-left' => true, // add left line separator ); + $rank = $rank + 1010; // add a big offset to be sure is the last col because default extrafield rank is 100 + $this->cols['totalincltax'] = array( + 'rank' => $rank, + 'width' => 26, // in mm + 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ? false : true, + 'title' => array( + 'textkey' => 'TotalTTC' + ), + 'border-left' => true, // add left line separator + ); + // Add extrafields cols if (!empty($object->lines)) { $line = reset($object->lines); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index c67789b1814..a74286e4cdc 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -173,8 +173,8 @@ class pdf_azur extends ModelePDFPropales $this->posxqty = 135; $this->posxunit = 151; } else { - $this->posxtva = 110; - $this->posxup = 126; + $this->posxtva = 106; + $this->posxup = 122; $this->posxqty = 145; $this->posxunit = 162; } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 8563c845d2b..6696364b9dd 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -57,7 +57,7 @@ class pdf_cyan extends ModelePDFPropales public $description; /** - * @var string Save the name of generated file as the main doc when generating a doc with this template + * @var int Save the name of generated file as the main doc when generating a doc with this template */ public $update_main_doc_field; @@ -119,7 +119,12 @@ class pdf_cyan extends ModelePDFPropales */ public $emetteur; - + /** + * @var array of document table collumns + */ + public $cols; + + /** * Constructor * @@ -164,11 +169,13 @@ class pdf_cyan extends ModelePDFPropales if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined // Define position of columns - $this->posxdesc = $this->marge_gauche + 1; - + $this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff + $this->tabTitleHeight = 5; // default height + // Use new system for position of columns, view $this->defineColumnField() + $this->tva = array(); $this->localtax1 = array(); $this->localtax2 = array(); @@ -197,7 +204,7 @@ class pdf_cyan extends ModelePDFPropales // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; - // Load traductions files required by page + // Load translation files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { @@ -344,15 +351,15 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right - // Does we have at least one line with discount $this->atleastonediscount - foreach ($object->lines as $line) { - if ($line->remise_percent) { - $this->atleastonediscount = true; - break; + // Set $this->atleastonediscount if you have at least one discount + for ($i = 0; $i < $nblines; $i++) + { + if ($object->lines[$i]->remise_percent) + { + $this->atleastonediscount++; } } - - + // New page $pdf->AddPage(); @@ -365,7 +372,7 @@ class pdf_cyan extends ModelePDFPropales $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); @@ -397,7 +404,7 @@ class pdf_cyan extends ModelePDFPropales } } - // Affiche notes + // Displays notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { @@ -454,7 +461,7 @@ class pdf_cyan extends ModelePDFPropales { $pdf->rollbackTransaction(true); - // prepar pages to receive notes + // prepare pages to receive notes while ($pagenb < $pageposafternote) { $pdf->AddPage(); $pagenb++; @@ -488,7 +495,7 @@ class pdf_cyan extends ModelePDFPropales } - // apply note frame to previus pages + // apply note frame to previous pages $i = $pageposbeforenote; while ($i < $pageposafternote) { $pdf->setPage($i); @@ -544,10 +551,10 @@ class pdf_cyan extends ModelePDFPropales $height_note = 0; } - // Use new auto collum system + // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); - // Simulation de tableau pour connaitre la hauteur de la ligne de titre + // tab simulation to know line height $pdf->startTransaction(); $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); $pdf->rollbackTransaction(true); @@ -582,7 +589,6 @@ class pdf_cyan extends ModelePDFPropales { $pdf->AddPage('', '', true); if (!empty($tplidx)) $pdf->useTemplate($tplidx); - //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; @@ -656,7 +662,7 @@ class pdf_cyan extends ModelePDFPropales $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // VAT Rate if ($this->getColumnStatus('vat')) @@ -700,7 +706,7 @@ class pdf_cyan extends ModelePDFPropales $nexY = max($pdf->GetY(), $nexY); } - // Total HT line + // Total excl tax line (HT) if ($this->getColumnStatus('totalexcltax')) { $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); @@ -708,6 +714,14 @@ class pdf_cyan extends ModelePDFPropales $nexY = max($pdf->GetY(), $nexY); } + // Total with tax line (TTC) + if ($this->getColumnStatus('totalincltax')) + { + $total_incl_tax = pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails); + $this->printStdColumnContent($pdf, $curY, 'totalincltax', $total_incl_tax); + $nexY = max($pdf->GetY(), $nexY); + } + // Extrafields if (!empty($object->lines[$i]->array_options)) { foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) { @@ -732,8 +746,7 @@ class pdf_cyan extends ModelePDFPropales $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook - - // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + // Collection of totals by value of vat in $this->tva["rate"] = total_tva if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; else $tvaligne = $object->lines[$i]->total_tva; @@ -826,13 +839,13 @@ class pdf_cyan extends ModelePDFPropales $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1; } - // Affiche zone infos + // Display infos area $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs); - // Affiche zone totaux + // Display total zone $posy = $this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs); - // Affiche zone versements + // Display payment area /* if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { @@ -1121,10 +1134,10 @@ class pdf_cyan extends ModelePDFPropales // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { - if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) + if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) { - $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); - if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank + $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account); + if ($object->fk_bank > 0) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank $account = new Account($this->db); $account->fetch($bankid); @@ -1154,15 +1167,23 @@ class pdf_cyan extends ModelePDFPropales */ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs) { - global $conf, $mysoc; + global $conf, $mysoc, $hookmanager; $default_font_size = pdf_getPDFFontSize($outputlangs); + $outputlangsbis = null; + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + $outputlangsbis = new Translate('', $conf); + $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); + $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); + $default_font_size--; + } + $tab2_top = $posy; $tab2_hl = 4; $pdf->SetFont('', '', $default_font_size - 1); - // Tableau total + // Total table $col1x = 120; $col2x = 170; if ($this->page_largeur < 210) // To work with US executive format { @@ -1173,13 +1194,6 @@ class pdf_cyan extends ModelePDFPropales $useborder = 0; $index = 0; - $outputlangsbis = null; - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { - $outputlangsbis = new Translate('', $conf); - $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); - $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); - } - // Total HT $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + 0); @@ -1387,6 +1401,7 @@ class pdf_cyan extends ModelePDFPropales if ($deja_regle > 0) { + // Already paid + Deposits $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); @@ -1440,9 +1455,10 @@ class pdf_cyan extends ModelePDFPropales * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title * @param int $hidebottom Hide bottom bar of array * @param string $currency Currency code + * @param Translate $outputlangsbis Langs object bis * @return void */ - protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null) { global $conf; @@ -1460,6 +1476,10 @@ class pdf_cyan extends ModelePDFPropales if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency)); + } + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); @@ -1490,9 +1510,10 @@ class pdf_cyan extends ModelePDFPropales * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output + * @param Translate $outputlangsbis Object lang for output bis * @return void */ - protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null) { global $conf, $langs; @@ -1512,8 +1533,10 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); + $w = 100; + $posy = $this->marge_haute; - $posx = $this->page_largeur - $this->marge_droite - 100; + $posx = $this->page_largeur - $this->marge_droite - $w; $pdf->SetXY($this->marge_gauche, $posy); @@ -1537,12 +1560,12 @@ class pdf_cyan extends ModelePDFPropales } else { $pdf->SetTextColor(200, 0, 0); $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); } } else { $text = $this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); + $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } } @@ -1550,7 +1573,7 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities("PdfCommercialProposalTitle"); - $pdf->MultiCell(100, 4, $title, '', 'R'); + $pdf->MultiCell($w, 4, $title, '', 'R'); $pdf->SetFont('', 'B', $default_font_size); @@ -1567,7 +1590,7 @@ class pdf_cyan extends ModelePDFPropales $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) @@ -1597,7 +1620,7 @@ class pdf_cyan extends ModelePDFPropales $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R'); $posy += 4; $pdf->SetXY($posx, $posy); @@ -1609,7 +1632,7 @@ class pdf_cyan extends ModelePDFPropales $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } // Get contact @@ -1623,7 +1646,7 @@ class pdf_cyan extends ModelePDFPropales $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); + $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } @@ -1632,7 +1655,7 @@ class pdf_cyan extends ModelePDFPropales $top_shift = 0; // Show list of linked objects $current_y = $pdf->getY(); - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); if ($current_y < $pdf->getY()) { $top_shift = $pdf->getY() - $current_y; @@ -1703,9 +1726,10 @@ class pdf_cyan extends ModelePDFPropales $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox = 100; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format - $posy = 42 + $top_shift; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy += $top_shift; $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; @@ -1719,7 +1743,7 @@ class pdf_cyan extends ModelePDFPropales // Show recipient name $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); + $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); $posy = $pdf->getY(); @@ -1840,7 +1864,7 @@ class pdf_cyan extends ModelePDFPropales 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', @@ -1848,6 +1872,7 @@ class pdf_cyan extends ModelePDFPropales ), ); + // Image of product $rank = $rank + 10; $this->cols['photo'] = array( 'rank' => $rank, @@ -1939,13 +1964,24 @@ class pdf_cyan extends ModelePDFPropales $this->cols['totalexcltax'] = array( 'rank' => $rank, 'width' => 26, // in mm - 'status' => true, + 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ? true : false, 'title' => array( 'textkey' => 'TotalHT' ), 'border-left' => true, // add left line separator ); + $rank = $rank + 1010; // add a big offset to be sure is the last col because default extrafield rank is 100 + $this->cols['totalincltax'] = array( + 'rank' => $rank, + 'width' => 26, // in mm + 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ? false : true, + 'title' => array( + 'textkey' => 'TotalTTC' + ), + 'border-left' => true, // add left line separator + ); + // Add extrafields cols if (!empty($object->lines)) { $line = reset($object->lines); diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 10a2659f6a5..c5acbcf16bd 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1285,9 +1285,9 @@ class Cronjob extends CommonObject elseif ($lastresult) $moretext .= ' ('.$langs->trans("Error").')'; $this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Disabled').$moretext; - $this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled').$moretext; + $this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Scheduled').$moretext; $this->labelStatusShort[self::STATUS_DISABLED] = $langs->trans('Disabled'); - $this->labelStatusShort[self::STATUS_ENABLED] = $langs->trans('Enabled'); + $this->labelStatusShort[self::STATUS_ENABLED] = $langs->trans('Scheduled'); } $statusType = 'status4'; diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 927c1d1014f..cea8ce39016 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -372,7 +372,7 @@ print ' '; print ' '; print ' '; print ''; -print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Enabled")), $search_status, 1); +print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Scheduled")), $search_status, 1); print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c42bf1c3991..2de5e76f369 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2665,10 +2665,10 @@ if ($action == 'create') print ''; 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 { - $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 ''; diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 80e86ae747a..43868da4a1b 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -139,7 +139,7 @@ CREATE TABLE llx_intracommreport content_xml text, type_export varchar(10), datec datetime, - tms timestamp + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, )ENGINE=innodb; ALTER TABLE llx_c_incoterms ADD COLUMN label varchar(100) NULL; diff --git a/htdocs/install/mysql/tables/llx_ecm_files.sql b/htdocs/install/mysql/tables/llx_ecm_files.sql index 52521e2af3e..030081b66b7 100644 --- a/htdocs/install/mysql/tables/llx_ecm_files.sql +++ b/htdocs/install/mysql/tables/llx_ecm_files.sql @@ -35,7 +35,7 @@ CREATE TABLE llx_ecm_files gen_or_uploaded varchar(12), -- 'generated' or 'uploaded' extraparams varchar(255), -- for stocking other parameters with json format date_c datetime, - date_m timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, fk_user_c integer, fk_user_m integer, acl text -- for future permission 'per file' diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index bb61ed13bbe..9921f21851d 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -47,6 +47,7 @@ CronNbRun=Number of launches CronMaxRun=Maximum number of launches CronEach=Every JobFinished=Job launched and finished +Scheduled=Scheduled #Page card CronAdd= Add jobs CronEvery=Execute job each @@ -57,7 +58,7 @@ CronNote=Comment CronFieldMandatory=Fields %s is mandatory CronErrEndDateStartDt=End date cannot be before start date StatusAtInstall=Status at module installation -CronStatusActiveBtn=Enable +CronStatusActiveBtn=Schedule CronStatusInactiveBtn=Disable CronTaskInactive=This job is disabled CronId=Id diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index f6bb28edd56..966ad4cae92 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -590,21 +590,19 @@ $showdatefilter = 0; if (!$showdatefilter) { print '
    '; - print '
    '; + print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - print '
    '.$langs->trans("From").' '; - print $form->selectDate($dates, 'dates', 0, 0, 1, '', 1, 0); - print ''.$langs->trans("to").' '; - print $form->selectDate($datee, 'datee', 0, 0, 1, '', 1, 0); - print ''; + print '
    '; + print $form->selectDate($dates, 'dates', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); + print '
    '; + print '
    '; + print $form->selectDate($datee, 'datee', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); + print '
    '; + print '
    '; print ''; - print '
    '; + print '
    '; print ''; print ''; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 1336c870cbe..b0c97907f7d 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -539,7 +539,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print ''; print ''.$langs->trans("Label").''; - print ''; + print ''; print ''; // List of projects @@ -704,16 +704,16 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third if (!empty($arrayfields['t.dateo']['checked'])) { print ''; - print ''; - print ''; + print ''; + print ''; $formother->select_year($search_dtstartyear ? $search_dtstartyear : -1, 'search_dtstartyear', 1, 20, 5); print ''; } if (!empty($arrayfields['t.datee']['checked'])) { print ''; - print ''; - print ''; + print ''; + print ''; $formother->select_year($search_dtendyear ? $search_dtendyear : -1, 'search_dtendyear', 1, 20, 5); print ''; } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 92759515ba4..8a198720e56 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2103,7 +2103,7 @@ class SupplierProposal extends CommonObject $sql .= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; $sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_cloture"; $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal as c"; - $sql .= " WHERE c.rowid = ".$id; + $sql .= " WHERE c.rowid = ".((int) $id); $result = $this->db->query($sql); diff --git a/htdocs/takepos/admin/orderprinters.php b/htdocs/takepos/admin/orderprinters.php index b396655dea4..c7ebbebffb7 100644 --- a/htdocs/takepos/admin/orderprinters.php +++ b/htdocs/takepos/admin/orderprinters.php @@ -42,6 +42,7 @@ $catname = GETPOST('catname', 'alpha'); $action = GETPOST('action', 'aZ09'); $printer1 = GETPOST('printer1', 'alpha'); $printer2 = GETPOST('printer2', 'alpha'); +$printer3 = GETPOST('printer3', 'alpha'); 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); } +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 @@ -206,6 +215,33 @@ if ($nbofentries > 0) print ''; print ''; } + +//Printer3 +print ''; +print ''; +$nbofentries = (count($data) - 1); +print ''; +if ($nbofentries > 0) +{ + print ''; +} else { + print ''; + print ''; + print ''; +} + print "
    '.$langs->trans("Printer").' 3'; +print '
    '; + print ''; + 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 ''.$row["label"].'
    '; + } + print '
    '; + print ''; + print ''; + print '
    '.img_picto_common('', 'treemenu/branchbottom.gif').''; + print $langs->trans("NoCategoryYet"); + print ' 
    "; print ''; diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 384be4f8f13..108fdea0b64 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -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_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_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_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 ''; 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 ''; + print ''.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 3'; + print ''; + 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 ''; } $printer->listPrintersTemplates(); $templates = array(); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index eee4faf9d43..fc0fd749242 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -532,8 +532,10 @@ if ($action == "order" and $placeid != 0) $footerorder = ''.dol_print_date(dol_now(), 'dayhour').'
    '; $order_receipt_printer1 = ""; $order_receipt_printer2 = ""; + $order_receipt_printer3 = ""; $catsprinter1 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_1); $catsprinter2 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_2); + $catsprinter3 = explode(';', $conf->global->TAKEPOS_PRINTED_CATEGORIES_3); foreach ($invoice->lines as $line) { 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 $db->query($sql); $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 .= ''.$line->product_label.''.$line->qty; + if (!empty($line->array_options['options_order_notes'])) $order_receipt_printer3 .= "
    (".$line->array_options['options_order_notes'].")"; + $order_receipt_printer3 .= ''; + } + } + 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 = ''; @@ -863,7 +893,7 @@ if (!empty($conf->use_javascript_ajax)) print ''."\n"; print '
    '; print ''; -if ($mobilepage == "invoice" || $mobilepage == "") { +if ($sectionwithinvoicelink && ($mobilepage == "invoice" || $mobilepage == "")) { print ''; } print ''; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d6c5434ce94..5c493cd505e 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1275,6 +1275,10 @@ table[summary="list_of_modules"] .fa-cog { width: calc(100% - 50px) !important; display: inline-block; } +.widthcentpercentminusxx { + width: calc(100% - 70px) !important; + display: inline-block; +} /* Force values for small screen 767 */ @media only screen and (max-width: 767px) @@ -1287,6 +1291,10 @@ table[summary="list_of_modules"] .fa-cog { padding-right: 5px; } + div.divphotoref { + padding-right: 10px !important; + } + .hideonsmartphone { display: none; } .hideonsmartphoneimp { display: none !important; } @@ -1298,15 +1306,10 @@ table[summary="list_of_modules"] .fa-cog { margin-bottom: 15px !important; } - select.minwidth100imp, select.minwidth100, select.minwidth200, select.minwidth300 { - width: calc(100% - 50px) !important; + select.minwidth100imp, select.minwidth100, select.minwidth200, select.minwidth200imp, select.minwidth300 { + width: calc(100% - 40px) !important; display: inline-block; } - - .clearbothonsmartphone { clear: both; display: block; } - /*img.photoref, div.photoref { - box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2); - }*/ } /* Force values for small screen 570 */ @@ -3757,6 +3760,15 @@ ul.noborder li:nth-child(even):not(.liste_titre) { @media only screen and (max-width: 767px) { + .tabBar .arearef .pagination.paginationref { + max-width: calc(50%); + } + + .clearbothonsmartphone { + clear: both; + display: block !important; + } + div.tabs { padding-left: 0 !important; padding-right: 0!important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 65afa0e017f..0be0b85bbbc 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1269,6 +1269,15 @@ table[summary="list_of_modules"] .fa-cog { .minwidth500imp { min-width: 250px !important; } } +.widthcentpercentminusx { + width: calc(100% - 50px) !important; + display: inline-block; +} +.widthcentpercentminusxx { + width: calc(100% - 70px) !important; + display: inline-block; +} + /* Force values for small screen 767 */ @media only screen and (max-width: 767px) { @@ -1279,7 +1288,9 @@ table[summary="list_of_modules"] .fa-cog { font-size: !important; } - .clearbothonsmartphone { clear: both; display: block; } + div.divphotoref { + padding-right: 10px !important; + } } /* Force values for small screen 570 */ @@ -3690,6 +3701,15 @@ ul.noborder li:nth-child(even):not(.liste_titre) { } @media only screen and (max-width: 767px) { + .tabBar .arearef .pagination.paginationref { + max-width: calc(50%); + } + + .clearbothonsmartphone { + clear: both; + display: block !important; + } + div.tabs { padding-left: 0 !important; margin-left: 0 !important;
    '.$sectionwithinvoicelink.'