diff --git a/.github/workflows/phpcsfixer.yml.disabled b/.github/workflows/phpcsfixer.yml.disabled index 89de2dc4539..959ba5ad801 100644 --- a/.github/workflows/phpcsfixer.yml.disabled +++ b/.github/workflows/phpcsfixer.yml.disabled @@ -60,3 +60,4 @@ jobs: #committer_email: eldy@destailleur.fr message: 'PHP CS fixer github action' add: '*.php' + diff --git a/.travis.yml b/.travis.yml index 54feb351933..0450f41de81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -325,22 +325,24 @@ script: echo - | - echo "Checking coding style (only for Pull Requests builds and 1 version to not overload travis and avoid duplicate tests)" + echo "Checking coding style (only for 1 version to not overload travis and avoid duplicate tests)" # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then + #if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then + if [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi set +e echo - | - echo "Checking missing debug" + echo "Checking missing debug (only for 1 version to not overload travis and avoid duplicate tests)" # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file - if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then + #if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then + if [ "$TRAVIS_PHP_VERSION" = "8.1" ]; then var-dump-check --extensions php --tracy --exclude htdocs/includes --exclude test/ --exclude htdocs/public/test/ --exclude htdocs/core/lib/functions.lib.php . fi set +e diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index fb306b9b257..7dac8f9d440 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -54,6 +54,38 @@ $rowid = GETPOST('rowid', 'alpha'); $entity = GETPOST('entity', 'int'); $code = GETPOST('code', 'alpha'); +$acts = array(); $actl = array(); +$acts[0] = "activate"; +$acts[1] = "disable"; +$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"'); +$actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"'); + +// Load variable for pagination +$listoffset = GETPOST('listoffset'); +$listlimit = GETPOST('listlimit') > 0 ?GETPOST('listlimit') : 1000; // To avoid too long dictionaries +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters + $page = 0; +} +$offset = $listlimit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +$search_country_id = GETPOST('search_country_id', 'int'); +$search_code = GETPOST('search_code', 'alpha'); +$search_active = GETPOST('search_active', 'alpha'); + +// Special case to set a default value for country according to dictionary +if (!GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) { // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only. + $search_country_id = $mysoc->country_id; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('admin', 'dictionaryadmin')); + $allowed = $user->admin; if ($id == 7 && $user->hasRight('accounting', 'chartofaccount')) { $allowed = 1; // Tax page allowed to manager of chart account @@ -68,34 +100,8 @@ if (!$allowed) { accessforbidden(); } -$acts = array(); $actl = array(); -$acts[0] = "activate"; -$acts[1] = "disable"; -$actl[0] = img_picto($langs->trans("Disabled"), 'switch_off', 'class="size15x"'); -$actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"'); +$permissiontoadd = $allowed; -$listoffset = GETPOST('listoffset'); -$listlimit = GETPOST('listlimit') > 0 ?GETPOST('listlimit') : 1000; // To avoid too long dictionaries -$active = 1; - -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$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 = $listlimit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - -$search_country_id = GETPOST('search_country_id', 'int'); -if (!GETPOSTISSET('search_country_id') && $search_country_id == '' && ($id == 2 || $id == 3 || $id == 10)) { // Not a so good idea to force on current country for all dictionaries. Some tables have entries that are for all countries, we must be able to see them, so this is done for dedicated dictionaries only. - $search_country_id = $mysoc->country_id; -} -$search_code = GETPOST('search_code', 'alpha'); - -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('admin', 'dictionaryadmin')); // This page is a generic page to edit dictionaries // Put here declaration of dictionaries properties @@ -201,7 +207,7 @@ $tablib[44] = "DictionaryAssetDisposalType"; $tabsql = array(); $tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, c.code as country_code, c.label as country, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c WHERE f.fk_pays=c.rowid"; $tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, c.code as country_code, c.label as country, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and r.active=1 and c.active=1"; -$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as state_code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1"; +$tabsql[3] = "SELECT r.rowid as rowid, r.code_region as code, r.nom as libelle, r.fk_pays as country_id, c.code as country_code, c.label as country, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_country as c WHERE r.fk_pays=c.rowid and c.active=1"; $tabsql[4] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.favorite, c.eec FROM ".MAIN_DB_PREFIX."c_country AS c"; $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c"; $tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a"; @@ -670,6 +676,7 @@ $localtax_typeList = array( ); + /* * Actions */ @@ -702,6 +709,7 @@ if ($reshook < 0) { if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) { $search_country_id = ''; $search_code = ''; + $search_active = ''; } if (empty($reshook)) { @@ -746,9 +754,9 @@ if (empty($reshook)) { && ($id != 10 || ($value != 'code' && $value != 'note')) // Field code and note is not mandatory for dictionary table 10 ) ) { - $ok = 0; - $fieldnamekey = $value; - // We take translate key of field + $ok = 0; + $fieldnamekey = $value; + // We take translate key of field if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) { $fieldnamekey = 'Label'; } @@ -823,7 +831,7 @@ if (empty($reshook)) { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors'); } } - if (($id == 3 || $id == 42) && !is_numeric(GETPOST("code"))) { + if (($id == 3 || $id == 42) && !is_numeric(GETPOST("code")) && GETPOST('actionadd')) { $ok = 0; setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric", $langs->transnoentities("Code")), null, 'errors'); } @@ -998,6 +1006,13 @@ if (empty($reshook)) { setEventMessages($db->error(), null, 'errors'); } } + + if (!$ok && GETPOST('actionadd')) { + $action = 'create'; + } + if (!$ok && GETPOST('actionmodify')) { + $action = 'edit'; + } } if ($action == 'confirm_delete' && $confirm == 'yes') { // delete @@ -1168,7 +1183,6 @@ if (empty($reshook)) { */ $form = new Form($db); -$formadmin = new FormAdmin($db); $title = $langs->trans("DictionarySetup"); @@ -1189,22 +1203,16 @@ if ($id == 7 && GETPOST('from') == 'accountancy') { $titlepicto = 'accountancy'; } -print load_fiche_titre($title, $linkback, $titlepicto); - -if (empty($id)) { - print ''.$langs->trans("DictionaryDesc"); - print " ".$langs->trans("OnlyActiveElementsAreShown")."
\n"; - print '

'; -} - - $param = '&id='.urlencode($id); -if ($search_country_id > 0) { - $param .= '&search_country_id='.urlencode($search_country_id); +if ($search_country_id || GETPOSTISSET('page') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) { + $param .= '&search_country_id='.urlencode($search_country_id ? $search_country_id : -1); } if ($search_code != '') { $param .= '&search_code='.urlencode($search_code); } +if ($search_active != '') { + $param .= '&search_active='.urlencode($search_active); +} if ($entity != '') { $param .= '&entity='.(int) $entity; } @@ -1225,37 +1233,55 @@ if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'rowid='.urlencode($rowid).'&code='.urlencode($code).$paramwithsearch, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1); } -/* - * Show a dictionary - */ +// Show a dictionary if ($id > 0) { // Complete search values request with sort criteria - $sql = $tabsql[$id]; + $sqlfields = $tabsql[$id]; + $tablecode = ''; + $tableprefix = ''; + $tableprefixarray = array(9 => 'code_iso', 28 => 'h.code', 7 => 'a.code', 32 => 'a.code', 3 => 'r.code_region', 8 => 't.code', 10 => 't.code', 1 => 'f.code', 2 => 'd.code_departement', 14 => 'e.code'); + if (!empty($tableprefixarray[$id])) { + $tablecode = $tableprefixarray[$id]; + $tableprefix = preg_replace('/\..*$/', '.', $tablecode); + } + + $sql = $sqlfields; if (!preg_match('/ WHERE /', $sql)) { $sql .= " WHERE 1 = 1"; } if ($search_country_id > 0) { $sql .= " AND c.rowid = ".((int) $search_country_id); } - if ($search_code != '' && $id == 9) { - $sql .= natural_search("code_iso", $search_code); - } elseif ($search_code != '' && $id == 28) { - $sql .= natural_search("h.code", $search_code); - } elseif ($search_code != '' && ($id == 7 || $id == 32)) { - $sql .= natural_search("a.code", $search_code); - } elseif ($search_code != '' && $id == 3) { - $sql .= natural_search("r.code_region", $search_code); - } elseif ($search_code != '' && ($id == 8 || $id == 10)) { - $sql .= natural_search("t.code", $search_code); - } elseif ($search_code != '' && $id == 1) { - $sql .= natural_search("f.code", $search_code); - } elseif ($search_code != '' && $id == 2) { - $sql .= natural_search("d.code_departement", $search_code); - } elseif ($search_code != '' && $id == 14) { - $sql .= natural_search("e.code", $search_code); - } elseif ($search_code != '' && $id != 9) { - $sql .= natural_search("code", $search_code); + if ($search_code != '') { + $sql .= natural_search($tablecode, $search_code); + } + if ($search_active == 'yes') { + $sql .= " AND ".$tableprefix."active = 1"; + } elseif ($search_active == 'no') { + $sql .= " AND ".$tableprefix."active = 0"; + } + //print $sql; + + // Count total nb of records + $nbtotalofrecords = ''; + if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^.*\sFROM\s/', 'SELECT COUNT(*) as nbtotalofrecords FROM ', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 + $page = 0; + $offset = 0; + } + $db->free($resql); } if ($sortfield) { @@ -1272,7 +1298,16 @@ if ($id > 0) { $sql .= " ORDER BY "; } $sql .= $tabsqlsort[$id]; + $sql .= $db->plimit($listlimit + 1, $offset); + + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + exit; + } + $num = $db->num_rows($resql); + //print $sql; if (empty($tabfield[$id])) { @@ -1285,327 +1320,12 @@ if ($id > 0) { print ''; print ''; + // Special warning for VAT dictionary if ($id == 10 && empty($conf->global->FACTURE_TVAOPTION)) { print info_admin($langs->trans("VATIsUsedIsOff", $langs->transnoentities("Setup"), $langs->transnoentities("CompanyFoundation"))); print "
\n"; } - // Form to add a new line - if ($tabname[$id]) { - $withentity = null; - - $fieldlist = explode(',', $tabfield[$id]); - - print '
'; - print ''; - - // Line for title - print ''; - $tdsoffields = ''; - foreach ($fieldlist as $field => $value) { - if ($value == 'entity') { - $withentity = getEntity($tabname[$id]); - continue; - } - - // Define field friendly name from its technical name - $valuetoshow = ucfirst($value); // Par defaut - $valuetoshow = $langs->trans($valuetoshow); // try to translate - $class = ''; - - if ($value == 'pos') { - $valuetoshow = $langs->trans("Position"); $class = 'right'; - } - if ($value == 'source') { - $valuetoshow = $langs->trans("Contact"); - } - if ($value == 'price') { - $valuetoshow = $langs->trans("PriceUHT"); - } - if ($value == 'taux') { - if ($tabname[$id] != "c_revenuestamp") { - $valuetoshow = $langs->trans("Rate"); - } else { - $valuetoshow = $langs->trans("Amount"); - } - $class = 'center'; - } - if ($value == 'localtax1_type') { - $valuetoshow = $langs->trans("UseLocalTax")." 2"; $class = "center"; $sortable = 0; - } - if ($value == 'localtax1') { - $valuetoshow = $langs->trans("RateOfTaxN", '2'); $class = "center"; - } - if ($value == 'localtax2_type') { - $valuetoshow = $langs->trans("UseLocalTax")." 3"; $class = "center"; $sortable = 0; - } - if ($value == 'localtax2') { - $valuetoshow = $langs->trans("RateOfTaxN", '3'); $class = "center"; - } - if ($value == 'organization') { - $valuetoshow = $langs->trans("Organization"); - } - if ($value == 'lang') { - $valuetoshow = $langs->trans("Language"); - } - if ($value == 'type') { - if ($tabname[$id] == "c_paiement") { - $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); - } else { - $valuetoshow = $langs->trans("Type"); - } - } - if ($value == 'code') { - $valuetoshow = $langs->trans("Code"); $class = 'maxwidth100'; - } - if ($value == 'libelle' || $value == 'label') { - $valuetoshow = $form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); - } - if ($value == 'libelle_facture') { - $valuetoshow = $form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); - } - if ($value == 'deposit_percent') { - $valuetoshow = $langs->trans('DepositPercent'); - $class = 'right'; - } - if ($value == 'country') { - if (in_array('region_id', $fieldlist)) { - print ''; continue; - } // For region page, we do not show the country input - $valuetoshow = $langs->trans("Country"); - } - if ($value == 'recuperableonly') { - $valuetoshow = $langs->trans("NPR"); $class = "center"; - } - if ($value == 'nbjour') { - $valuetoshow = $langs->trans("NbOfDays"); - $class = 'right'; - } - if ($value == 'type_cdr') { - $valuetoshow = $langs->trans("AtEndOfMonth"); $class = "center"; - } - if ($value == 'decalage') { - $valuetoshow = $langs->trans("Offset"); - $class = 'right'; - } - if ($value == 'width' || $value == 'nx') { - $valuetoshow = $langs->trans("Width"); - } - if ($value == 'height' || $value == 'ny') { - $valuetoshow = $langs->trans("Height"); - } - if ($value == 'unit' || $value == 'metric') { - $valuetoshow = $langs->trans("MeasuringUnit"); - } - if ($value == 'region_id' || $value == 'country_id') { - $valuetoshow = ''; - } - if ($value == 'accountancy_code') { - $valuetoshow = $langs->trans("AccountancyCode"); - } - if ($value == 'accountancy_code_sell') { - $valuetoshow = $langs->trans("AccountancyCodeSell"); - } - if ($value == 'accountancy_code_buy') { - $valuetoshow = $langs->trans("AccountancyCodeBuy"); - } - if ($value == 'pcg_version' || $value == 'fk_pcg_version') { - $valuetoshow = $langs->trans("Pcg_version"); - } - if ($value == 'account_parent') { - $valuetoshow = $langs->trans("Accountparent"); - } - if ($value == 'pcg_type') { - $valuetoshow = $langs->trans("Pcg_type"); - } - if ($value == 'pcg_subtype') { - $valuetoshow = $langs->trans("Pcg_subtype"); - } - if ($value == 'sortorder') { - $valuetoshow = $langs->trans("SortOrder"); - $class = 'center'; - } - if ($value == 'short_label') { - $valuetoshow = $langs->trans("ShortLabel"); - } - if ($value == 'fk_parent') { - $valuetoshow = $langs->trans("ParentID"); $class = 'center'; - } - if ($value == 'range_account') { - $valuetoshow = $langs->trans("Range"); - } - if ($value == 'sens') { - $valuetoshow = $langs->trans("Sens"); - } - if ($value == 'category_type') { - $valuetoshow = $langs->trans("Calculated"); - } - if ($value == 'formula') { - $valuetoshow = $langs->trans("Formula"); - } - if ($value == 'paper_size') { - $valuetoshow = $langs->trans("PaperSize"); - } - if ($value == 'orientation') { - $valuetoshow = $langs->trans("Orientation"); - } - if ($value == 'leftmargin') { - $valuetoshow = $langs->trans("LeftMargin"); - } - if ($value == 'topmargin') { - $valuetoshow = $langs->trans("TopMargin"); - } - if ($value == 'spacex') { - $valuetoshow = $langs->trans("SpaceX"); - } - if ($value == 'spacey') { - $valuetoshow = $langs->trans("SpaceY"); - } - if ($value == 'font_size') { - $valuetoshow = $langs->trans("FontSize"); - } - if ($value == 'custom_x') { - $valuetoshow = $langs->trans("CustomX"); - } - if ($value == 'custom_y') { - $valuetoshow = $langs->trans("CustomY"); - } - if ($value == 'percent') { - $valuetoshow = $langs->trans("Percentage"); - } - if ($value == 'affect') { - $valuetoshow = $langs->trans("WithCounter"); - } - if ($value == 'delay') { - $valuetoshow = $langs->trans("NoticePeriod"); - } - if ($value == 'newbymonth') { - $valuetoshow = $langs->trans("NewByMonth"); - } - if ($value == 'fk_tva') { - $valuetoshow = $langs->trans("VAT"); - } - if ($value == 'range_ik') { - $valuetoshow = $langs->trans("RangeIk"); - } - if ($value == 'fk_c_exp_tax_cat') { - $valuetoshow = $langs->trans("CarCategory"); - } - if ($value == 'revenuestamp_type') { - $valuetoshow = $langs->trans('TypeOfRevenueStamp'); - } - if ($value == 'use_default') { - $valuetoshow = $langs->trans('Default'); $class = 'center'; - } - if ($value == 'unit_type') { - $valuetoshow = $langs->trans('TypeOfUnit'); - } - if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') { - $valuetoshow = $langs->trans('TicketGroupIsPublic'); $class = 'center'; - } - if ($value == 'block_if_negative') { - $valuetoshow = $langs->trans('BlockHolidayIfNegative'); - } - if ($value == 'type_duration') { - $valuetoshow = $langs->trans('Unit'); - } - - if ($id == 2) { // Special case for state page - if ($value == 'region_id') { - $valuetoshow = ' '; $showfield = 1; - } - if ($value == 'region') { - $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region"); $showfield = 1; - } - } - - if ($valuetoshow != '') { - $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : ''); - - $tdsoffields .= ''; - if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) { - $tdsoffields .= ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - } elseif ($tooltiphelp) { - $tdsoffields .= $form->textwithpicto($valuetoshow, $tooltiphelp); - } else { - $tdsoffields .= $valuetoshow; - } - $tdsoffields .= ''; - } - } - - if ($id == 4) { - $tdsoffields .= ''; - $tdsoffields .= ''; - } - $tdsoffields .= ''; - $tdsoffields .= ''; - $tdsoffields .= ''; - $tdsoffields .= ''; - - print $tdsoffields; - - - // Line to enter new values - print ''; - print ''; - - $obj = new stdClass(); - // If data was already input, we define them in obj to populate input fields. - if (GETPOST('actionadd')) { - foreach ($fieldlist as $key => $val) { - if (GETPOST($val) != '') { - $obj->$val = GETPOST($val); - } - } - } - - $tmpaction = 'create'; - $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); - $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks - $error = $hookmanager->error; $errors = $hookmanager->errors; - - if ($id == 3) { - unset($fieldlist[2]); // Remove field ??? if dictionary Regions - } - - if (empty($reshook)) { - fieldList($fieldlist, $obj, $tabname[$id], 'add'); - } - - if ($id == 4) { - print ''; - print ''; - } - print ''; - - print ""; - - print '
 '; - $tdsoffields .= ''; - if (!is_null($withentity)) { - $tdsoffields .= ''; - } - $tdsoffields .= '
'; - if ($action != 'edit') { - print ''; - } else { - print ''; - } - print '
'; - print '
'; - } - - print ''; - - - print '
'; - - - print '
'; - print ''; - print ''; - // List of available record in database dol_syslog("htdocs/admin/dict", LOG_DEBUG); @@ -1614,12 +1334,336 @@ if ($id > 0) { $num = $db->num_rows($resql); $i = 0; - // There is several pages - if (($num > $listlimit) || $page) { - print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), ''); - print '
'; + $massactionbutton = $linkback; + + $newcardbutton = ''; + /*$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitleSeparator(); + */ + $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/admin/dict.php?action=create'.$param.'&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'tools', 0, $newcardbutton, '', $listlimit, 1, 0, 1); + + + if ($action == 'create') { + // Form to add a new line + if ($tabname[$id]) { + $withentity = null; + + $fieldlist = explode(',', $tabfield[$id]); + + print '
'; + print ''; + + // Line for title + print ''; + $tdsoffields = ''; + foreach ($fieldlist as $field => $value) { + if ($value == 'entity') { + $withentity = getEntity($tabname[$id]); + continue; + } + + // Define field friendly name from its technical name + $valuetoshow = ucfirst($value); // Par defaut + $valuetoshow = $langs->trans($valuetoshow); // try to translate + $class = ''; + + if ($value == 'pos') { + $valuetoshow = $langs->trans("Position"); $class = 'right'; + } + if ($value == 'source') { + $valuetoshow = $langs->trans("Contact"); + } + if ($value == 'price') { + $valuetoshow = $langs->trans("PriceUHT"); + } + if ($value == 'taux') { + if ($tabname[$id] != "c_revenuestamp") { + $valuetoshow = $langs->trans("Rate"); + } else { + $valuetoshow = $langs->trans("Amount"); + } + $class = 'center'; + } + if ($value == 'localtax1_type') { + $valuetoshow = $langs->trans("UseLocalTax")." 2"; $class = "center"; $sortable = 0; + } + if ($value == 'localtax1') { + $valuetoshow = $langs->trans("RateOfTaxN", '2'); $class = "center"; + } + if ($value == 'localtax2_type') { + $valuetoshow = $langs->trans("UseLocalTax")." 3"; $class = "center"; $sortable = 0; + } + if ($value == 'localtax2') { + $valuetoshow = $langs->trans("RateOfTaxN", '3'); $class = "center"; + } + if ($value == 'organization') { + $valuetoshow = $langs->trans("Organization"); + } + if ($value == 'lang') { + $valuetoshow = $langs->trans("Language"); + } + if ($value == 'type') { + if ($tabname[$id] == "c_paiement") { + $valuetoshow = $form->textwithtooltip($langs->trans("Type"), $langs->trans("TypePaymentDesc"), 2, 1, img_help(1, '')); + } else { + $valuetoshow = $langs->trans("Type"); + } + } + if ($value == 'code') { + $valuetoshow = $langs->trans("Code"); $class = 'maxwidth100'; + } + if ($value == 'libelle' || $value == 'label') { + $valuetoshow = $form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); + } + if ($value == 'libelle_facture') { + $valuetoshow = $form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"), 2, 1, img_help(1, '')); + } + if ($value == 'deposit_percent') { + $valuetoshow = $langs->trans('DepositPercent'); + $class = 'right'; + } + if ($value == 'country') { + if (in_array('region_id', $fieldlist)) { + //print ''; + continue; + } // For region page, we do not show the country input + $valuetoshow = $langs->trans("Country"); + } + if ($value == 'recuperableonly') { + $valuetoshow = $langs->trans("NPR"); $class = "center"; + } + if ($value == 'nbjour') { + $valuetoshow = $langs->trans("NbOfDays"); + $class = 'right'; + } + if ($value == 'type_cdr') { + $valuetoshow = $langs->trans("AtEndOfMonth"); $class = "center"; + } + if ($value == 'decalage') { + $valuetoshow = $langs->trans("Offset"); + $class = 'right'; + } + if ($value == 'width' || $value == 'nx') { + $valuetoshow = $langs->trans("Width"); + } + if ($value == 'height' || $value == 'ny') { + $valuetoshow = $langs->trans("Height"); + } + if ($value == 'unit' || $value == 'metric') { + $valuetoshow = $langs->trans("MeasuringUnit"); + } + if ($value == 'region_id' || $value == 'country_id') { + $valuetoshow = ''; + } + if ($value == 'accountancy_code') { + $valuetoshow = $langs->trans("AccountancyCode"); + } + if ($value == 'accountancy_code_sell') { + $valuetoshow = $langs->trans("AccountancyCodeSell"); + } + if ($value == 'accountancy_code_buy') { + $valuetoshow = $langs->trans("AccountancyCodeBuy"); + } + if ($value == 'pcg_version' || $value == 'fk_pcg_version') { + $valuetoshow = $langs->trans("Pcg_version"); + } + if ($value == 'account_parent') { + $valuetoshow = $langs->trans("Accountparent"); + } + if ($value == 'pcg_type') { + $valuetoshow = $langs->trans("Pcg_type"); + } + if ($value == 'pcg_subtype') { + $valuetoshow = $langs->trans("Pcg_subtype"); + } + if ($value == 'sortorder') { + $valuetoshow = $langs->trans("SortOrder"); + $class = 'center'; + } + if ($value == 'short_label') { + $valuetoshow = $langs->trans("ShortLabel"); + } + if ($value == 'fk_parent') { + $valuetoshow = $langs->trans("ParentID"); $class = 'center'; + } + if ($value == 'range_account') { + $valuetoshow = $langs->trans("Range"); + } + if ($value == 'sens') { + $valuetoshow = $langs->trans("Sens"); + } + if ($value == 'category_type') { + $valuetoshow = $langs->trans("Calculated"); + } + if ($value == 'formula') { + $valuetoshow = $langs->trans("Formula"); + } + if ($value == 'paper_size') { + $valuetoshow = $langs->trans("PaperSize"); + } + if ($value == 'orientation') { + $valuetoshow = $langs->trans("Orientation"); + } + if ($value == 'leftmargin') { + $valuetoshow = $langs->trans("LeftMargin"); + } + if ($value == 'topmargin') { + $valuetoshow = $langs->trans("TopMargin"); + } + if ($value == 'spacex') { + $valuetoshow = $langs->trans("SpaceX"); + } + if ($value == 'spacey') { + $valuetoshow = $langs->trans("SpaceY"); + } + if ($value == 'font_size') { + $valuetoshow = $langs->trans("FontSize"); + } + if ($value == 'custom_x') { + $valuetoshow = $langs->trans("CustomX"); + } + if ($value == 'custom_y') { + $valuetoshow = $langs->trans("CustomY"); + } + if ($value == 'percent') { + $valuetoshow = $langs->trans("Percentage"); + } + if ($value == 'affect') { + $valuetoshow = $langs->trans("WithCounter"); + } + if ($value == 'delay') { + $valuetoshow = $langs->trans("NoticePeriod"); + } + if ($value == 'newbymonth') { + $valuetoshow = $langs->trans("NewByMonth"); + } + if ($value == 'fk_tva') { + $valuetoshow = $langs->trans("VAT"); + } + if ($value == 'range_ik') { + $valuetoshow = $langs->trans("RangeIk"); + } + if ($value == 'fk_c_exp_tax_cat') { + $valuetoshow = $langs->trans("CarCategory"); + } + if ($value == 'revenuestamp_type') { + $valuetoshow = $langs->trans('TypeOfRevenueStamp'); + } + if ($value == 'use_default') { + $valuetoshow = $langs->trans('Default'); $class = 'center'; + } + if ($value == 'unit_type') { + $valuetoshow = $langs->trans('TypeOfUnit'); + } + if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') { + $valuetoshow = $langs->trans('TicketGroupIsPublic'); $class = 'center'; + } + if ($value == 'block_if_negative') { + $valuetoshow = $langs->trans('BlockHolidayIfNegative'); + } + if ($value == 'type_duration') { + $valuetoshow = $langs->trans('Unit'); + } + + if ($id == 2) { // Special case for state page + if ($value == 'region_id') { + $valuetoshow = ' '; + $showfield = 1; + } + if ($value == 'region') { + $valuetoshow = $langs->trans("Country").'/'.$langs->trans("Region"); + $showfield = 1; + } + } + + if ($valuetoshow != '') { + $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : ''); + + $tdsoffields .= ''; + if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) { + $tdsoffields .= ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + } elseif ($tooltiphelp) { + $tdsoffields .= $form->textwithpicto($valuetoshow, $tooltiphelp); + } else { + $tdsoffields .= $valuetoshow; + } + $tdsoffields .= ''; + } + } + + if ($id == 4) { + $tdsoffields .= ''; + $tdsoffields .= ''; + } + $tdsoffields .= ''; + $tdsoffields .= ''; + $tdsoffields .= ''; + $tdsoffields .= ''; + + print $tdsoffields; + + + // Line to enter new values + print ''; + print ''; + + $obj = new stdClass(); + // If data was already input, we define them in obj to populate input fields. + if (GETPOST('actionadd')) { + foreach ($fieldlist as $key => $val) { + if (GETPOST($val) != '') { + $obj->$val = GETPOST($val); + } + } + } + + $tmpaction = 'create'; + $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); + $reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks + $error = $hookmanager->error; $errors = $hookmanager->errors; + + if ($id == 3) { + unset($fieldlist[2]); // Remove field ??? if dictionary Regions + } + + if (empty($reshook)) { + fieldList($fieldlist, $obj, $tabname[$id], 'add'); + } + + if ($id == 4) { + print ''; + print ''; + } + print ''; + + print ""; + + print '
 '; + $tdsoffields .= ''; + if (!is_null($withentity)) { + $tdsoffields .= ''; + } + $tdsoffields .= '
'; + if ($action != 'edit') { + print ''; + } else { + print ''; + } + print '
'; + print '
'; + } + + print '
'; + + print '
'; + print ''; + print ''; } + $filterfound = 0; foreach ($fieldlist as $field => $value) { if ($value == 'entity') { @@ -1673,7 +1717,7 @@ if ($id > 0) { if ($showfield) { if ($value == 'country') { print ''; - print $form->select_country($search_country_id, 'search_country_id', '', 28, 'minwidth100 maxwidth150 maxwidthonsmartphone'); + print $form->select_country($search_country_id, 'search_country_id', '', 28, 'minwidth100 maxwidth150 maxwidthonsmartphone', '', ' '); print ''; $colspan++; } elseif ($value == 'code') { @@ -1695,7 +1739,10 @@ if ($id > 0) { $colspan++; } - print ''; + // Active + print ''; + print $form->selectyesno('search_active', $search_active, 0, false, 1); + print ''; $colspan++; // Action button @@ -2009,7 +2056,9 @@ if ($id > 0) { if (empty($rowidcol) || in_array($id, array(6, 7, 8, 13, 17, 19, 27, 32))) { $rowidcol = 'rowid'; } - $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(isset($obj->{$rowidcol}) ? $obj->{$rowidcol} : (!empty($obj->code) ? urlencode($obj->code) : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); + $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder; + $url .= '&rowid='.(isset($obj->$rowidcol) ? $obj->$rowidcol : (!empty($obj->code) ? urlencode($obj->code) : '')); + $url .= '&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); if (!empty($param)) { $url .= '&'.$param; } @@ -2230,8 +2279,6 @@ if ($id > 0) { $langs->load('other'); $key = $langs->trans($obj->label); $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$value}); - } elseif ($value == 'code' && $id == 3) { - $valuetoshow = $obj->state_code; } elseif ($value == 'label' && $tabname[$id] == 'c_product_nature') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$value}); @@ -2347,6 +2394,11 @@ if ($id > 0) { /* * Show list of dictionary to show */ + print load_fiche_titre($title, $linkback, $titlepicto); + + print ''.$langs->trans("DictionaryDesc"); + print " ".$langs->trans("OnlyActiveElementsAreShown")."
\n"; + print '

'; $lastlineisempty = false; diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index 40e07b821c5..6da76ad4a80 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -102,7 +102,7 @@ class Availabilities extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1',), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',), diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 2de8736b39f..836562067f8 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -300,6 +300,11 @@ class ActionComm extends CommonObject */ public $elementtype; + /** + * @var int id of availability + */ + public $fk_bookcal_availability; + /** * @var string Ical name */ @@ -539,6 +544,7 @@ class ActionComm extends CommonObject $sql .= "transparency,"; $sql .= "fk_element,"; $sql .= "elementtype,"; + $sql .= "fk_bookcal_availability,"; $sql .= "entity,"; $sql .= "extraparams,"; // Fields emails @@ -581,6 +587,7 @@ class ActionComm extends CommonObject $sql .= "'".$this->db->escape($this->transparency)."', "; $sql .= (!empty($this->fk_element) ? ((int) $this->fk_element) : "null").", "; $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; + $sql .= (!empty($this->fk_bookcal_availability) ? "'".$this->db->escape($this->fk_bookcal_availability)."'" : "null").", "; $sql .= ((int) $conf->entity).","; $sql .= (!empty($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").", "; // Fields emails diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 7316ee3daaf..e03b4bd1473 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -557,6 +557,34 @@ if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allac $s = ''; $link = ''; $showextcals = $listofextcals; +$bookcalcalendars = array(); + +// Load Bookcal Calendars +if (isModEnabled("bookcal")) { + $sql = "SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal"; + $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_availabilities as ba"; + $sql .= " JOIN ".MAIN_DB_PREFIX."bookcal_calendar as bc"; + $sql .= " ON bc.rowid = ba.fk_bookcal_calendar"; + $sql .= " WHERE bc.status = 1"; + $sql .= " AND ba.status = 1"; + if (!empty($filtert) && $filtert != -1) { + $sql .= " AND bc.visibility = ".(int) $filtert ; + } + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($resql); + $label = !empty($objp->label) ? $objp->label : $objp->ref; + $bookcalcalendars["calendars"][] = array("id" => $objp->id_cal, "label" => $label); + $bookcalcalendars["availabilitieslink"][$objp->rowid] = $objp->id_cal; + $i++; + } + } else { + dol_print_error($db); + } +} if (!empty($conf->use_javascript_ajax)) { // If javascript on $s .= "\n".''."\n"; @@ -564,6 +592,11 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on $s .= 'jQuery(document).ready(function () {'."\n"; $s .= 'jQuery(".check_birthday").click(function() { console.log("Toggle birthdays"); jQuery(".family_birthday").toggle(); });'."\n"; $s .= 'jQuery(".check_holiday").click(function() { console.log("Toggle holidays"); jQuery(".family_holiday").toggle(); });'."\n"; + if (isModEnabled("bookcal")) { + foreach ($bookcalcalendars["calendars"] as $key => $value) { + $s .= 'jQuery(".check_bookcal_calendar_'.$value['id'].'").click(function() { console.log("Toggle Bookcal Calendar '.$value['id'].'"); jQuery(".family_bookcal_calendar_'.$value['id'].'").toggle(); });'."\n"; + } + } if ($mode == "show_week" || $mode == "show_month" || empty($mode)) { // Code to enable drag and drop $s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n"; @@ -631,6 +664,14 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on // Birthdays $s .= '
 
'; + // Bookcal Calendar + if (isModEnabled("bookcal")) { + foreach ($bookcalcalendars["calendars"] as $key => $value) { + $label = $value['label']; + $s .= '
 
'; + } + } + // Calendars from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); @@ -673,7 +714,7 @@ $sql .= ' a.datep2,'; $sql .= ' a.percent,'; $sql .= ' a.fk_user_author,a.fk_user_action,'; $sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,'; -$sql .= ' a.fk_soc, a.fk_contact, a.fk_project,'; +$sql .= ' a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_availability,'; $sql .= ' a.fk_element, a.elementtype,'; $sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto'; $sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; @@ -862,6 +903,10 @@ if ($resql) { $event->socid = $obj->fk_soc; $event->contact_id = $obj->fk_contact; + $event->fk_bookcal_availability = $obj->fk_bookcal_availability; + if (!empty($event->fk_bookcal_availability)) { + $event->type = "bookcal_calendar"; + } // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. @@ -1505,7 +1550,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month } //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style); echo ' '; - show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); + show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam, 0, 60, 0, $bookcalcalendars); echo "\n"; } else { /* Show days after the current month (next month) */ @@ -1578,7 +1623,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month } echo ' '; - show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); + show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars); echo " \n"; } echo " \n"; @@ -1668,13 +1713,13 @@ if (empty($mode) || $mode == 'show_month') { // View by month echo ''; - show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1); + show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars); print ''; } else { print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); + show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars); print '
'; } @@ -1703,9 +1748,10 @@ $db->close(); * @param int $showinfo Add extended information (used by day and week view) * @param int $minheight Minimum height for each event. 60px by default. * @param string $nonew 0=Add "new entry button", 1=No "new entry button", -1=Only "new entry button" + * @param string $bookcalcalendarsarray Used for Bookcal module array of calendar of bookcal * @return void */ -function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0) +function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0, $bookcalcalendarsarray = array()) { global $user, $conf, $langs; global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form @@ -1817,6 +1863,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $colorindex = 2; $cssclass = 'family_birthday '; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + } elseif ($event->type == 'bookcal_calendar') { + $numbirthday++; + $colorindex = 3; + $cssclass = 'family_bookcal_calendar_'.(!empty($bookcalcalendarsarray[$fk_bookcal_availability]) ? $bookcalcalendarsarray[$fk_bookcal_availability][$event->fk_bookcal_availability] : ""); + $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } else { $numother++; $color = ($event->icalcolor ? $event->icalcolor : -1); @@ -1904,6 +1955,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($event->type == 'holiday' && !GETPOST('check_holiday')) { $morecss = 'hidden'; } + if ($event->type == 'bookcal_calendar' && !GETPOST('check_bookcal_calendar_'.$bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_availability])) { + $morecss = 'hidden'; + } if ($morecss != 'hidden') { $itoshow++; } @@ -1911,8 +1965,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $ireallyshown++; } //var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow); - - print '
type == 'bookcal_calendar') { + print '
fk_bookcal_availability].' '.$cssclass.($morecss ? ' '.$morecss : '').'"'; + } else { + print '
total_tva)) { $datas['amountvat'] = '
'.$langs->trans('AmountVAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); } - if (!empty($this->revenuestamp)) { + if (!empty($this->revenuestamp) && $this->revenuestamp != 0) { $datas['amountrevenustamp'] = '
'.$langs->trans('RevenueStamp').': '.price($this->revenuestamp, 0, $langs, 0, -1, -1, $conf->currency); } if (!empty($this->total_localtax1) && $this->total_localtax1 != 0) { diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 44cd2437195..455e1c7972c 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -87,6 +87,10 @@ class BonPrelevement extends CommonObject */ public $file; + /* + * @var string filename + */ + public $filename; const STATUS_DRAFT = 0; const STATUS_TRANSFERED = 1; diff --git a/htdocs/core/ajax/bookcalAjax.php b/htdocs/core/ajax/bookcalAjax.php index 80323b0fee9..4859d5b5941 100644 --- a/htdocs/core/ajax/bookcalAjax.php +++ b/htdocs/core/ajax/bookcalAjax.php @@ -80,11 +80,11 @@ if ($action == 'verifyavailability') { } if (!$error) { $datetocheckbooking_end = dol_time_plus_duree($datetocheckbooking, 1, 'd'); - $sql = "SELECT b.start, b.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_booking as b"; + $sql = "SELECT b.datep, b.id"; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as b"; $sql .= " WHERE fk_bookcal_availability = ".((int) $idavailability); - $sql .= " AND b.start >= '".$db->idate($datetocheckbooking)."'"; - $sql .= " AND b.start < '".$db->idate($datetocheckbooking_end)."'"; + $sql .= " AND b.datep >= '".$db->idate($datetocheckbooking)."'"; + $sql .= " AND b.datep < '".$db->idate($datetocheckbooking_end)."'"; $resql = $db->query($sql); if ($resql) { @@ -94,7 +94,7 @@ if ($action == 'verifyavailability') { $response["content"] = array(); while ($i < $num) { $obj = $db->fetch_object($resql); - $dateobject = $obj->start; + $dateobject = $obj->datep; $dateobject = explode(" ", $dateobject)[1]; $dateobject = explode(":", $dateobject); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index bfec5a6c199..ccb379ea531 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -150,6 +150,8 @@ abstract class CommonDocGenerator */ public $result; + public $posxlabel; + public $posxup; public $posxref; public $posxpicture; // For picture public $posxdesc; // For description diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index faa8251ad0a..33694e798e6 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -188,15 +188,13 @@ class FormContract * @param int $showempty Show empty line * @param int $showRef Show customer and supplier reference on each contract (when found) * @param int $noouput 1=Return the output instead of display - * @return int Nbr of project if OK, <0 if KO + * @return string|void html string */ public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0, $noouput = 0) { global $langs; - $ret = ''; - - $ret .= ''; + $ret = ''; $ret .= ''; $ret .= ''; $ret .= $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef, 1); @@ -208,7 +206,5 @@ class FormContract } print $ret; - - return $result; } } diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 5ce093f7868..74287b1bd0b 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -145,13 +145,13 @@ class Notify $nb = count($listofnotiftodo); } if ($nb < 0) { - $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); + $texte = img_object($langs->trans("Notifications"), 'email', 'class="pictofixedwidth"').$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); } elseif ($nb == 0) { - $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent"); + $texte = img_object($langs->trans("Notifications"), 'email', 'class="pictofixedwidth"').$langs->trans("NoNotificationsWillBeSent"); } elseif ($nb == 1) { - $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent"); + $texte = img_object($langs->trans("Notifications"), 'email', 'class="pictofixedwidth"').$langs->trans("ANotificationsWillBeSent"); } elseif ($nb >= 2) { - $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb); + $texte = img_object($langs->trans("Notifications"), 'email', 'class="pictofixedwidth"').$langs->trans("SomeNotificationsWillBeSent", $nb); } if (is_array($listofnotiftodo)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 710ad9f3dce..a984ef485c7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5532,7 +5532,7 @@ function load_fiche_titre($titre, $morehtmlright = '', $picto = 'generic', $pict */ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', $sortorder = '', $morehtmlcenter = '', $num = -1, $totalnboflines = '', $picto = 'generic', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limit = -1, $hideselectlimit = 0, $hidenavigation = 0, $pagenavastextinput = 0, $morehtmlrightbeforearrow = '') { - global $conf, $langs; + global $conf; $savlimit = $limit; $savtotalnboflines = $totalnboflines; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d6bc0027da4..9d38e7fdb3d 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -371,7 +371,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); /*print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; print ", dbtablename=".$tableandshare.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; - print ", perm: user->right->".$features.($feature2 ? "->".$feature2 : "")."=".($user->hasRight($features, $feature2, 'lire'))."
"; + print ", perm: user->hasRight(".$features.($feature2 ? ",".$feature2 : "").", lire) = ".($feature2 ? $user->hasRight($features, $feature2, 'lire') : $user->hasRight($features, 'lire'))."
"; */ $parentfortableentity = ''; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index d27c4dac376..0fd313e4cd1 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -163,12 +163,13 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c if (preg_last_error() == PREG_JIT_STACKLIMIT_ERROR) $content = 'preg_replace error (when removing php tags) PREG_JIT_STACKLIMIT_ERROR'; }*/ $content = dolStripPhpCode($content, $replacewith); - //var_dump($content); // Protect the link styles.css.php to any replacement that we make after. $content = str_replace('href="styles.css.php', 'href="!~!~!~styles.css.php', $content); + $content = str_replace('src="javascript.js.php', 'src="!~!~!~javascript.js.php', $content); $content = str_replace('href="http', 'href="!~!~!~http', $content); $content = str_replace('href="//', 'href="!~!~!~//', $content); + $content = str_replace('src="//', 'src="!~!~!~//', $content); $content = str_replace('src="viewimage.php', 'src="!~!~!~/viewimage.php', $content); $content = str_replace('src="/viewimage.php', 'src="!~!~!~/viewimage.php', $content); $content = str_replace('src="'.DOL_URL_ROOT.'/viewimage.php', 'src="!~!~!~'.DOL_URL_ROOT.'/viewimage.php', $content); @@ -301,11 +302,14 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '') } } elseif (defined('USEDOLIBARRSERVER')) { // REPLACEMENT OF LINKS When page called from Dolibarr server $content = str_replace('virtualhost) { $content = preg_replace('/^(]*rel="canonical" href=")\//m', '\1'.$website->virtualhost.'/', $content, -1, $nbrep); diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 87a964c9419..1668d640f02 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -248,7 +248,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, // Add js $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; - $tplcontent .= ''."\n"; + $tplcontent .= ''."\n"; // Add headers $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; diff --git a/htdocs/core/modules/modBookCal.class.php b/htdocs/core/modules/modBookCal.class.php index fbbc4180423..07237b63d45 100644 --- a/htdocs/core/modules/modBookCal.class.php +++ b/htdocs/core/modules/modBookCal.class.php @@ -297,7 +297,7 @@ class modBookCal extends DolibarrModules $r = 0; // Add here entries to declare new menus /* BEGIN MODULEBUILDER TOPMENU */ - $this->menu[$r++] = array( + /*$this->menu[$r++] = array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'top', // This is a Top menu entry 'titre'=>'ModuleBookCalName', @@ -311,18 +311,33 @@ class modBookCal extends DolibarrModules 'perms'=>'$user->rights->bookcal->availabilities->read', // Use 'perms'=>'$user->rights->bookcal->availabilities->read' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - ); + );*/ /* END MODULEBUILDER TOPMENU */ /* BEGIN MODULEBUILDER LEFTMENU CALENDAR */ + $this->menu[$r++] = array( + 'fk_menu'=>'fk_mainmenu=agenda', + 'type'=>'left', + 'titre'=> 'MenuBookcalIndex', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em92"'), + 'mainmenu'=>'agenda', + 'leftmenu'=> 'bookcal', + 'url'=> '/bookcal/bookcalindex.php', + 'langs'=> 'bookcal', + 'position'=> 1100+$r, + 'enabled'=> '1', + 'perms'=> '$user->rights->bookcal->calendar->read', + 'user'=> 0 + ); + $this->menu[$r++]=array( // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=bookcal', + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal', // This is a Left menu entry 'type'=>'left', - 'titre'=>'List Calendar', - 'mainmenu'=>'bookcal', - 'leftmenu'=>'bookcal_calendar', + 'titre'=>'Calendar', + 'mainmenu'=>'agenda', + 'leftmenu'=>'bookcal_calendar_list', 'url'=>'/bookcal/calendar_list.php', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'bookcal', @@ -337,12 +352,12 @@ class modBookCal extends DolibarrModules ); $this->menu[$r++]=array( // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=bookcal,fk_leftmenu=bookcal_calendar', + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal_calendar_list', // This is a Left menu entry 'type'=>'left', - 'titre'=>'New Calendar', - 'mainmenu'=>'bookcal', - 'leftmenu'=>'bookcal_calendar', + 'titre'=>'NewCalendar', + 'mainmenu'=>'agenda', + 'leftmenu'=>'bookcal_new', 'url'=>'/bookcal/calendar_card.php?action=create', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'bookcal', @@ -405,11 +420,11 @@ class modBookCal extends DolibarrModules $this->menu[$r++]=array( // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=bookcal', + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal', // This is a Left menu entry 'type'=>'left', - 'titre'=>'List Availabilities', - 'mainmenu'=>'bookcal', + 'titre'=>'Availabilities', + 'mainmenu'=>'agenda', 'leftmenu'=>'bookcal_availabilities', 'url'=>'/bookcal/availabilities_list.php', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. @@ -425,11 +440,11 @@ class modBookCal extends DolibarrModules ); $this->menu[$r++]=array( // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=bookcal,fk_leftmenu=bookcal_availabilities', + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal_availabilities', // This is a Left menu entry 'type'=>'left', - 'titre'=>'New Availabilities', - 'mainmenu'=>'bookcal', + 'titre'=>'NewAvailabilities', + 'mainmenu'=>'agenda', 'leftmenu'=>'bookcal_availabilities', 'url'=>'/bookcal/availabilities_card.php?action=create', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index a13dec33985..5baf6099e33 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -871,7 +871,7 @@ if (empty($reshook)) { * View */ -$title = $langs->trans("Shipment"); +$title = $object->ref.' - '.$langs->trans("Shipment"); if ($action == 'create2') { $title = $langs->trans("CreateShipment"); } @@ -1379,7 +1379,7 @@ if ($action == 'create') { //var_dump($dbatch); $batchStock = + $dbatch->qty; // To get a numeric $deliverableQty = min($quantityToBeDelivered, $batchStock); - print ''; + print ''; print ''; print ''; print ''; @@ -1451,7 +1451,7 @@ if ($action == 'create') { $deliverableQty = min($quantityToBeDelivered, $stock); $deliverableQty = max(0, $deliverableQty); // Quantity to send - print ''; + print ''; print ''; if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) { @@ -1591,7 +1591,7 @@ if ($action == 'create') { } $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]; - print ''; + print ''; print ''; print ''; @@ -1764,9 +1764,9 @@ if ($action == 'create') { $text = $langs->trans("ConfirmValidateSending", $numref); if (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT')) { - $text .= '
'.$langs->trans("StockMovementWillBeRecorded").'.'; + $text .= '
'.img_picto('', 'movement', 'class="pictofixedwidth"').$langs->trans("StockMovementWillBeRecorded").'.'; } elseif (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE')) { - $text .= '
'.$langs->trans("StockMovementNotYetRecorded").'.'; + $text .= '
'.img_picto('', 'movement', 'class="pictofixedwidth"').$langs->trans("StockMovementNotYetRecorded").'.'; } if (isModEnabled('notification')) { diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index e538f36bf18..28edd145cc0 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -679,7 +679,7 @@ class Expedition extends CommonObject return 1; } else { dol_syslog(get_class($this).'::Fetch no expedition found', LOG_ERR); - $this->error = 'Delivery with id '.$id.' not found'; + $this->error = 'Shipment with id '.$id.' not found'; return 0; } } else { diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 5707b3474ef..8417699cb19 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -40,15 +40,12 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php'; - - - if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; } // Load translation files required by the page -$langs->loadLangs(array("sendings", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal')); +$langs->loadLangs(array("sendings", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal', 'receptions')); if (isModEnabled('productbatch')) { $langs->load('productbatch'); @@ -80,7 +77,7 @@ $objectorder = new Commande($db); if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); - if ($result < 0) { + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } $result = $object->fetch_thirdparty(); @@ -105,6 +102,7 @@ if (!isModEnabled('stock')) { $usercancreate = $user->hasRight('expedition', 'creer'); $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php + /* * Actions */ @@ -319,7 +317,7 @@ $morejs = array('/expedition/js/lib_dispatch.js.php'); llxHeader('', $title, $help_url, '', 0, 0, $morejs); -if ($id > 0 || !empty($ref)) { +if ($object->id > 0 || !empty($object->ref)) { $lines = $object->lines; $num_prod = count($lines); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index dfe1c7d9bc6..12f8d2e21f5 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4107,8 +4107,6 @@ function migrate_delete_old_files($db, $langs, $conf) '/core/modules/modCommercial.class.php', '/core/modules/modProduit.class.php', '/core/modules/modSkype.class.php', - '/phenix/inc/triggers/interface_modPhenix_Phenixsynchro.class.php', - '/webcalendar/inc/triggers/interface_modWebcalendar_webcalsynchro.class.php', '/core/triggers/interface_modWebcalendar_Webcalsynchro.class.php', '/core/triggers/interface_modCommande_Ecotax.class.php', '/core/triggers/interface_modCommande_fraisport.class.php', @@ -4139,6 +4137,10 @@ function migrate_delete_old_files($db, $langs, $conf) '/core/boxes/box_members.php', '/includes/restler/framework/Luracast/Restler/Data/Object.php', + '/includes/restler/framework/Luracast/Restler/Data/Object.php', + '/phenix/inc/triggers/interface_modPhenix_Phenixsynchro.class.php', + '/webcalendar/inc/triggers/interface_modWebcalendar_webcalsynchro.class.php', + '/api/class/api_generic.class.php', '/asterisk/cidlookup.php', '/categories/class/api_category.class.php', diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index abdbdbed6a1..07d97bb967f 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -180,4 +180,5 @@ BrowserPush=Browser Popup Notification Reminders=Reminders ActiveByDefault=Enabled by default Until=until -DataFromWasMerged=Data from %s was merged \ No newline at end of file +DataFromWasMerged=Data from %s was merged +AgendaShowBookcalCalendar=Booking calendar: %s \ No newline at end of file diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 19b17a73dff..871d9a72809 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -1,5 +1,5 @@ # Dolibarr language file - Source file is en_US - companies -newSocieteAdded=Your contact has been recorded. We will go back to you soon... +newSocieteAdded=Your contact details have been recorded. We will get back to you soon... ContactUsDesc=This form allows you to send us a message for a first contact. ErrorCompanyNameAlreadyExists=Company name %s already exists. Choose another one. ErrorSetACountryFirst=Set the country first diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 4028726096a..9c9f3e5f274 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -413,7 +413,9 @@ if (empty($reshook)) { */ $product_static = new Product($db); -$static_ws = new Workstation($db); +if (isModEnabled('workstation')) { + $workstation_static = new Workstation($db); +} $product_fourn = new ProductFournisseur($db); $title = $langs->trans("ProductsAndServices"); @@ -1844,12 +1846,12 @@ while ($i < $imaxinloop) { // Default Workstation if (!empty($arrayfields['p.fk_default_workstation']['checked'])) { print ''; - if (!empty($obj->fk_default_workstation)) { - $static_ws->id = $obj->fk_default_workstation; - $static_ws->ref = $obj->ref_workstation; - $static_ws->status = $obj->status_workstation; + if (isModEnabled('workstation') && !empty($obj->fk_default_workstation)) { + $workstation_static->id = $obj->fk_default_workstation; + $workstation_static->ref = $obj->ref_workstation; + $workstation_static->status = $obj->status_workstation; - print $static_ws->getNomUrl(1); + print $workstation_static->getNomUrl(1); } print ''; if (!$i) { diff --git a/htdocs/public/bookcal/booking.php b/htdocs/public/bookcal/booking.php index 74972cfc8f0..0ddc53ebd6f 100644 --- a/htdocs/public/bookcal/booking.php +++ b/htdocs/public/bookcal/booking.php @@ -44,6 +44,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $langs->loadLangs(array("main", "other", "dict", "agenda", "errors", "companies")); @@ -169,13 +171,21 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ if ($action == 'add') { $error = 0; - $urlback = ''; + $idcontact = 0; + $calendar = new Calendar($db); + $contact = new Contact($db); + $actioncomm = new ActionComm($db); + + $res = $calendar->fetch($fk_calendar); + if ($res < 0) { + $error++; + $errmsg .= $calendar->error." ".join(',', $calendar->errors); + } + if (!is_object($user)) { $user = new User($db); } - $booking = new ActionComm($db); - $db->begin(); if (!GETPOST("lastname")) { $error++; @@ -191,21 +201,71 @@ if ($action == 'add') { } if (!$error) { - $booking->ref = $booking->getNextNumRef(); - $booking->lastname = GETPOST("lastname"); - $booking->firstname = GETPOST("firstname"); - $booking->email = GETPOST("email"); - $booking->description = GETPOST("description"); - $booking->duration = GETPOST("duration"); - $booking->start = GETPOST("datetimebooking", 'int'); - $booking->fk_bookcal_availability = GETPOST("id", 'int'); + $sql = "SELECT s.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as s"; + $sql .= " WHERE s.lastname = '".GETPOST("lastname")."'"; + $sql .= " AND s.firstname = '".GETPOST("firstname")."'"; + $sql .= " AND s.email = '".GETPOST("email")."'"; + $resql = $db->query($sql); - $result = $booking->create($user); - if ($result <= 0) { + if ($resql) { + $num = $db->num_rows($resql); + if ($num > 0) { + $obj = $db->fetch_object($resql); + $idcontact = $obj->rowid; + $contact->fetch($idcontact); + } else { + $contact->lastname = GETPOST("lastname"); + $contact->firstname = GETPOST("firstname"); + $contact->email = GETPOST("email"); + $result = $contact->create($user); + if ($result < 0) { + $error++; + $errmsg .= $contact->error." ".join(',', $contact->errors); + } + } + } else { $error++; - $errmsg = ($booking->error ? $booking->error.'
' : '').join('
', $booking->errors); + $errmsg .= $db->lasterror(); } } + + if (!$error) { + $dateend = dol_time_plus_duree(GETPOST("datetimebooking", 'int'), GETPOST("duration"), 'i'); + + $actioncomm->label = "test"; + $actioncomm->type = 'AC_RDV'; + $actioncomm->type_id = 5; + $actioncomm->datep = GETPOST("datetimebooking", 'int'); + $actioncomm->datef = $dateend; + $actioncomm->note_private = GETPOST("description"); + $actioncomm->percentage = -1; + $actioncomm->fk_bookcal_availability = GETPOST("id", 'int'); + $actioncomm->userownerid = $calendar->visibility; + $actioncomm->contact_id = $contact->id; + $actioncomm->socpeopleassigned = $contact->id; + $result = $actioncomm->create($user); + if ($result < 0) { + $error++; + $errmsg .= $actioncomm->error." ".join(',', $actioncomm->errors); + } + + if (!$error) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources"; + $sql .= "(fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency"; + $sql .= ") VALUES ("; + $sql .= (int) $actioncomm->id; + $sql .= ", 'socpeople'"; + $sql .= ", ". (int) $contact->id; + $sql .= ", 0, 0, 0)"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $errmsg .= $db->lasterror(); + } + } + } + if (!$error) { $db->commit(); $action = 'afteradd'; diff --git a/htdocs/public/bookcal/index.php b/htdocs/public/bookcal/index.php index cd4db57da4d..39d6b1f84da 100644 --- a/htdocs/public/bookcal/index.php +++ b/htdocs/public/bookcal/index.php @@ -180,7 +180,7 @@ print '
'; print '

'.(!empty($object->label) ? $object->label : $object->ref).'

'; -$sql = "SELECT b.rowid, b.ref, b.label, b.start, b.end, b.duration, b.startHour, b.endHour"; +$sql = "SELECT b.rowid, b.label, b.start, b.end, b.duration, b.startHour, b.endHour"; $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_availabilities as b"; $sql .= " WHERE b.status = ".(int) $availabilities::STATUS_VALIDATED; $sql .= " AND b.fk_bookcal_calendar = ".(int) $id; @@ -193,7 +193,7 @@ if ($resql) { while ($i < $num) { $i++; $obj = $db->fetch_object($resql); - print ''; + print ''; } } print '
'; diff --git a/htdocs/public/website/javascript.js.php b/htdocs/public/website/javascript.js.php new file mode 100644 index 00000000000..51cecf8c699 --- /dev/null +++ b/htdocs/public/website/javascript.js.php @@ -0,0 +1,171 @@ + + * + * 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/public/website/javascript.js.php + * \ingroup website + * \brief Page to output style page. Called with + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); // Disables token renewal +} +if (!defined('NOLOGIN')) { + define("NOLOGIN", 1); +} +if (!defined('NOCSRFCHECK')) { + define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOIPCHECK')) { + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} + +/** + * Header empty + * + * @return void + */ +function llxHeader() +{ +} +/** + * Footer empty + * + * @return void + */ +function llxFooter() +{ +} + +require '../../master.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + +$error = 0; +$website = GETPOST('website', 'alpha'); +$websiteid = GETPOST('websiteid', 'int'); +$pageid = GETPOST('page', 'alpha') ?GETPOST('page', 'alpha') : GETPOST('pageid', 'alpha'); + +$accessallowed = 1; +$type = ''; + + +/* + * View + */ + +$appli = constant('DOL_APPLICATION_TITLE'); +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $appli = $conf->global->MAIN_APPLICATION_TITLE; +} + +//print 'Directory with '.$appli.' websites.
'; + +if (empty($pageid)) { + require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; + require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; + + $object = new Website($db); + if ($websiteid) { + $object->fetch($websiteid); + $website = $object->ref; + } else { + $object->fetch(0, $website); + } + + $objectpage = new WebsitePage($db); + /* Not required for CSS file + $array=$objectpage->fetchAll($object->id); + + if (is_array($array) && count($array) > 0) + { + $firstrep=reset($array); + $pageid=$firstrep->id; + } + */ +} +/* Not required for CSS file +if (empty($pageid)) +{ + $langs->load("website"); + print $langs->trans("PreviewOfSiteNotYetAvailable"); + exit; +} +*/ + +// Security: Delete string ../ into $original_file +global $dolibarr_main_data_root; + +$original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website.'/javascript.js.php'; + +// Find the subdirectory name as the reference +$refname = basename(dirname($original_file)."/"); + +// Security: +// Limite acces si droits non corrects +if (!$accessallowed) { + accessforbidden(); +} + +// Security: +// On interdit les remontees de repertoire ainsi que les pipe dans +// les noms de fichiers. +if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { + dol_syslog("Refused to deliver file ".$original_file); + $file = basename($original_file); // Do no show plain path of original_file in shown error message + dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $file)); + exit; +} + +clearstatcache(); + +$filename = basename($original_file); + +// Output file on browser +dol_syslog("javascript.js.css.php include $original_file $filename content-type=$type"); +$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset + +// This test if file exists should be useless. We keep it to find bug more easily +if (!file_exists($original_file_osencoded)) { + $langs->load("website"); + print $langs->trans("RequestedPageHasNoContentYet", $pageid); + //dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); + exit; +} + + +// Output page content +define('USEDOLIBARRSERVER', 1); +print '/* Page content '.$original_file.' : JS content that was saved into tpl dir */'."\n"; +require_once $original_file_osencoded; + + +if (is_object($db)) { + $db->close(); +} diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 29ea1434b2e..9cee2a4fc29 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1037,14 +1037,16 @@ if ($action == 'create') { print '