mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-31 06:04:54 +01:00
Merge branch 'develop' into develop_project
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2019 Eric Seigne <eric.seigne@cap-rel.fr>
|
||||
*
|
||||
* 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
|
||||
@@ -14,15 +15,33 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/lib/accounting.lib.php
|
||||
* \ingroup Advanced accountancy
|
||||
* \ingroup Accountancy (Double entries)
|
||||
* \brief Library of accountancy functions
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Check if a value is empty with some options
|
||||
*
|
||||
* @author Michael - https://www.php.net/manual/fr/function.empty.php#90767
|
||||
* @param mixed $var Value to test
|
||||
* @param int|null $allow_false Setting this to true will make the function consider a boolean value of false as NOT empty. This parameter is false by default.
|
||||
* @param int|null $allow_ws Setting this to true will make the function consider a string with nothing but white space as NOT empty. This parameter is false by default.
|
||||
* @return boolean True of False
|
||||
*/
|
||||
function is_empty($var, $allow_false = false, $allow_ws = false)
|
||||
{
|
||||
if (!isset($var) || is_null($var) || ($allow_ws == false && trim($var) == "" && !is_bool($var)) || ($allow_false === false && is_bool($var) && $var === false) || (is_array($var) && empty($var))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare array with list of tabs
|
||||
*
|
||||
@@ -60,7 +79,7 @@ function accounting_prepare_head(AccountingAccount $object)
|
||||
*/
|
||||
function clean_account($account)
|
||||
{
|
||||
$account = rtrim($account,"0");
|
||||
$account = rtrim($account, "0");
|
||||
|
||||
return $account;
|
||||
}
|
||||
@@ -75,12 +94,12 @@ function length_accountg($account)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if ($account < 0 || empty($account)) return '';
|
||||
if ($account < 0 || is_empty($account)) return '';
|
||||
|
||||
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
|
||||
if (! is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account;
|
||||
|
||||
$g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
|
||||
if (! empty($g)) {
|
||||
if (! is_empty($g)) {
|
||||
// Clean parameters
|
||||
$i = strlen($account);
|
||||
|
||||
@@ -108,14 +127,14 @@ function length_accountg($account)
|
||||
*/
|
||||
function length_accounta($accounta)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $conf;
|
||||
|
||||
if ($accounta < 0 || empty($accounta)) return '';
|
||||
if ($accounta < 0 || is_empty($accounta)) return '';
|
||||
|
||||
if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
|
||||
if (! is_empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta;
|
||||
|
||||
$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
|
||||
if (! empty($a)) {
|
||||
if (! is_empty($a)) {
|
||||
// Clean parameters
|
||||
$i = strlen($accounta);
|
||||
|
||||
@@ -138,36 +157,36 @@ function length_accounta($accounta)
|
||||
|
||||
|
||||
/**
|
||||
* Show header of a VAT report
|
||||
* Show header of a page used to transfer/dispatch data in accounting
|
||||
*
|
||||
* @param string $nom Name of report
|
||||
* @param string $variante Link for alternate report
|
||||
* @param string $period Period of report
|
||||
* @param string $periodlink Link to switch period
|
||||
* @param string $description Description
|
||||
* @param timestamp|integer $builddate Date generation
|
||||
* @param integer $builddate Date of generation
|
||||
* @param string $exportlink Link for export or ''
|
||||
* @param array $moreparam Array with list of params to add into form
|
||||
* @param string $calcmode Calculation mode
|
||||
* @param string $varlink Add a variable into the address of the page
|
||||
* @return void
|
||||
*/
|
||||
function journalHead($nom,$variante,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='')
|
||||
function journalHead($nom, $variante, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if (empty($hselected)) $hselected='report';
|
||||
print "\n\n<!-- start banner journal -->\n";
|
||||
|
||||
print "\n\n<!-- debut cartouche journal -->\n";
|
||||
|
||||
if(! empty($varlink)) $varlink = '?'.$varlink;
|
||||
if(! is_empty($varlink)) $varlink = '?'.$varlink;
|
||||
|
||||
$head=array();
|
||||
$h=0;
|
||||
$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
|
||||
$head[$h][1] = $langs->trans("Journalization");
|
||||
$head[$h][2] = 'journal';
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
|
||||
dol_fiche_head($head, 'journal');
|
||||
|
||||
@@ -180,10 +199,8 @@ function journalHead($nom,$variante,$period,$periodlink,$description,$builddate,
|
||||
// Ligne de titre
|
||||
print '<tr>';
|
||||
print '<td width="110">'.$langs->trans("Name").'</td>';
|
||||
if (! $variantexxx) print '<td colspan="3">';
|
||||
else print '<td>';
|
||||
print '<td colspan="3">';
|
||||
print $nom;
|
||||
if ($variantexxx) print '</td><td colspan="2">'.$variantexxx;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@@ -224,6 +241,5 @@ function journalHead($nom,$variante,$period,$periodlink,$description,$builddate,
|
||||
|
||||
print '</form>';
|
||||
|
||||
print "\n<!-- fin cartouche journal -->\n\n";
|
||||
print "\n<!-- end banner journal -->\n\n";
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,8 +14,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@
|
||||
* @param int $resourceid Preselected value of resource for filter on resource
|
||||
* @return void
|
||||
*/
|
||||
function print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals=array(), $actioncode='', $usergroupid='', $excludetype='', $resourceid=0)
|
||||
function print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, $filtera, $filtert, $filterd, $pid, $socid, $action, $showextcals = array(), $actioncode = '', $usergroupid = '', $excludetype = '', $resourceid = 0)
|
||||
{
|
||||
global $conf, $user, $langs, $db, $hookmanager;
|
||||
global $begin_h, $end_h, $begin_d, $end_d;
|
||||
@@ -64,7 +64,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
print '<input type="hidden" name="month" value="' . $month . '">';
|
||||
print '<input type="hidden" name="day" value="' . $day . '">';
|
||||
print '<input type="hidden" name="action" value="' . $action . '">';
|
||||
print '<input type="hidden" name="showbirthday" value="' . $showbirthday . '">';
|
||||
print '<input type="hidden" name="search_showbirthday" value="' . $showbirthday . '">';
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
@@ -79,7 +79,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">';
|
||||
print $langs->trans("ActionsToDoBy").' ';
|
||||
print '</td><td style="padding-bottom: 2px; padding-right: 4px;">';
|
||||
print $form->select_dolusers($filtert, 'filtert', 1, '', ! $canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
|
||||
print $form->select_dolusers($filtert, 'search_filtert', 1, '', ! $canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
|
||||
if (empty($conf->dol_optimize_smallscreen)) print ' '.$langs->trans("or") . ' '.$langs->trans("ToUserOfGroup").' ';
|
||||
print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit);
|
||||
print '</td></tr>';
|
||||
@@ -94,7 +94,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">';
|
||||
print $langs->trans("Resource");
|
||||
print ' </td><td class="nowrap maxwidthonsmartphone" style="padding-bottom: 2px; padding-right: 4px;">';
|
||||
print $formresource->select_resource_list($resourceid, "resourceid", '', 1, 0, 0, null, '', 2);
|
||||
print $formresource->select_resource_list($resourceid, "search_resourceid", '', 1, 0, 0, null, '', 2);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
{
|
||||
$multiselect=(!empty($conf->global->AGENDA_USE_EVENT_TYPE));
|
||||
}
|
||||
print $formactions->select_type_actions($actioncode, "actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1), 0, $multiselect);
|
||||
print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1), 0, $multiselect);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">';
|
||||
print $langs->trans("ThirdParty").' ';
|
||||
print '</td><td class="nowrap" style="padding-bottom: 2px;">';
|
||||
print $form->select_company($socid, 'socid', '', 'SelectThirdParty', 0, 0, null, 0);
|
||||
print $form->select_company($socid, 'search_socid', '', 'SelectThirdParty', 0, 0, null, 0);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
print '<td class="nowrap" style="padding-bottom: 2px;">';
|
||||
print $langs->trans("Project").' ';
|
||||
print '</td><td class="nowrap" style="padding-bottom: 2px;">';
|
||||
print $formproject->select_projects($socid?$socid:-1, $pid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500');
|
||||
print $formproject->select_projects($socid?$socid:-1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
print '<td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">';
|
||||
print $langs->trans("Status");
|
||||
print ' </td><td class="nowrap" style="padding-bottom: 2px; padding-right: 4px;">';
|
||||
$formactions->form_select_status_action('formaction', $status, 1, 'status', 1, 2, 'minwidth100');
|
||||
$formactions->form_select_status_action('formaction', $status, 1, 'search_status', 1, 2, 'minwidth100');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
else print '</td>';
|
||||
|
||||
if ($conf->browser->layout == 'phone') print '<div class="fichehalfright">';
|
||||
else print '<td align="center" valign="middle" class="nowrap">';
|
||||
else print '<td class="center nowrap" valign="middle">';
|
||||
|
||||
print '<table class="centpercent"><tr><td align="center">';
|
||||
print '<div class="formleftzone">';
|
||||
@@ -209,7 +209,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
|
||||
* @param int $max Max nb of records
|
||||
* @return void
|
||||
*/
|
||||
function show_array_actions_to_do($max=5)
|
||||
function show_array_actions_to_do($max = 5)
|
||||
{
|
||||
global $langs, $conf, $user, $db, $bc, $socid;
|
||||
|
||||
@@ -237,9 +237,10 @@ function show_array_actions_to_do($max=5)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("LastActionsToDo",$max).'</th>';
|
||||
print '<th colspan="2" align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/comm/action/list.php?status=todo">'.$langs->trans("FullList").'</a></th>';
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("LastActionsToDo", $max).'</th>';
|
||||
print '<th colspan="2" class="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/comm/action/list.php?status=todo">'.$langs->trans("FullList").'</a></th>';
|
||||
print '</tr>';
|
||||
|
||||
$var = true;
|
||||
@@ -258,9 +259,9 @@ function show_array_actions_to_do($max=5)
|
||||
$staticaction->type_code=$obj->code;
|
||||
$staticaction->label=($obj->label?$obj->label:$obj->type_label);
|
||||
$staticaction->id=$obj->id;
|
||||
print '<td>'.$staticaction->getNomUrl(1,34).'</td>';
|
||||
print '<td>'.$staticaction->getNomUrl(1, 34).'</td>';
|
||||
|
||||
// print '<td>'.dol_trunc($obj->label,22).'</td>';
|
||||
// print '<td>'.dol_trunc($obj->label,22).'</td>';
|
||||
|
||||
print '<td>';
|
||||
if ($obj->rowid > 0)
|
||||
@@ -268,7 +269,7 @@ function show_array_actions_to_do($max=5)
|
||||
$customerstatic->id=$obj->rowid;
|
||||
$customerstatic->name=$obj->sname;
|
||||
$customerstatic->client=$obj->client;
|
||||
print $customerstatic->getNomUrl(1,'',16);
|
||||
print $customerstatic->getNomUrl(1, '', 16);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
@@ -276,7 +277,7 @@ function show_array_actions_to_do($max=5)
|
||||
$datep2=$db->jdate($obj->dp2);
|
||||
|
||||
// Date
|
||||
print '<td width="100" align="right">'.dol_print_date($datep,'day').' ';
|
||||
print '<td width="100" class="right">'.dol_print_date($datep, 'day').' ';
|
||||
$late=0;
|
||||
if ($obj->percent == 0 && $datep && $datep < time()) $late=1;
|
||||
if ($obj->percent == 0 && ! $datep && $datep2 && $datep2 < time()) $late=1;
|
||||
@@ -286,13 +287,13 @@ function show_array_actions_to_do($max=5)
|
||||
print "</td>";
|
||||
|
||||
// Statut
|
||||
print "<td align=\"right\" width=\"14\">".$staticaction->LibStatut($obj->percent,3)."</td>\n";
|
||||
print '<td class="right" width="14">'.$staticaction->LibStatut($obj->percent, 3)."</td>\n";
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
print "</table><br>";
|
||||
print "</table></div><br>";
|
||||
|
||||
$db->free($resql);
|
||||
}
|
||||
@@ -309,7 +310,7 @@ function show_array_actions_to_do($max=5)
|
||||
* @param int $max Max nb of records
|
||||
* @return void
|
||||
*/
|
||||
function show_array_last_actions_done($max=5)
|
||||
function show_array_last_actions_done($max = 5)
|
||||
{
|
||||
global $langs, $conf, $user, $db, $bc, $socid;
|
||||
|
||||
@@ -334,9 +335,10 @@ function show_array_last_actions_done($max=5)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("LastDoneTasks",$max).'</th>';
|
||||
print '<th colspan="2" align="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/comm/action/list.php?status=done">'.$langs->trans("FullList").'</a></th>';
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("LastDoneTasks", $max).'</th>';
|
||||
print '<th colspan="2" class="right"><a class="commonlink" href="'.DOL_URL_ROOT.'/comm/action/list.php?status=done">'.$langs->trans("FullList").'</a></th>';
|
||||
print '</tr>';
|
||||
$var = true;
|
||||
$i = 0;
|
||||
@@ -354,7 +356,7 @@ function show_array_last_actions_done($max=5)
|
||||
$staticaction->type_code=$obj->code;
|
||||
$staticaction->libelle=$obj->label;
|
||||
$staticaction->id=$obj->id;
|
||||
print '<td>'.$staticaction->getNomUrl(1,34).'</td>';
|
||||
print '<td>'.$staticaction->getNomUrl(1, 34).'</td>';
|
||||
|
||||
//print '<td>'.dol_trunc($obj->label,24).'</td>';
|
||||
|
||||
@@ -364,23 +366,23 @@ function show_array_last_actions_done($max=5)
|
||||
$customerstatic->id=$obj->rowid;
|
||||
$customerstatic->name=$obj->sname;
|
||||
$customerstatic->client=$obj->client;
|
||||
print $customerstatic->getNomUrl(1,'',24);
|
||||
print $customerstatic->getNomUrl(1, '', 24);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Date
|
||||
print '<td width="100" align="right">'.dol_print_date($db->jdate($obj->da2),'day');
|
||||
print '<td width="100" class="right">'.dol_print_date($db->jdate($obj->da2), 'day');
|
||||
print "</td>";
|
||||
|
||||
// Statut
|
||||
print "<td align=\"right\" width=\"14\">".$staticaction->LibStatut($obj->percent,3)."</td>\n";
|
||||
print "<td class=\"right\" width=\"14\">".$staticaction->LibStatut($obj->percent, 3)."</td>\n";
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
// TODO Ajouter rappel pour "il y a des contrats a mettre en service"
|
||||
// TODO Ajouter rappel pour "il y a des contrats qui arrivent a expiration"
|
||||
print "</table><br>";
|
||||
print "</table></div><br>";
|
||||
|
||||
$db->free($resql);
|
||||
}
|
||||
@@ -414,10 +416,10 @@ function agenda_prepare_head()
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL > 0)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/agenda_reminder.php";
|
||||
$head[$h][1] = $langs->trans("Reminders");
|
||||
$head[$h][2] = 'reminders';
|
||||
$h++;
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/agenda_reminder.php";
|
||||
$head[$h][1] = $langs->trans("Reminders");
|
||||
$head[$h][2] = 'reminders';
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/agenda_xcal.php";
|
||||
@@ -430,14 +432,14 @@ function agenda_prepare_head()
|
||||
$head[$h][2] = 'extsites';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'agenda_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/agenda_extrafields.php";
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'agenda_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda_admin', 'remove');
|
||||
|
||||
|
||||
return $head;
|
||||
@@ -469,9 +471,9 @@ function actions_prepare_head($object)
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=action&element_id='.$object->id;
|
||||
$listofresourcelinked = $resource->getElementResources($object->element, $object->id);
|
||||
$nbResources=count($listofresourcelinked);
|
||||
$nbResources=(is_array($listofresourcelinked)?count($listofresourcelinked):0);
|
||||
$head[$h][1] = $langs->trans("Resources");
|
||||
if ($nbResources > 0) $head[$h][1].= ' <span class="badge">'.($nbResources).'</span>';
|
||||
if ($nbResources > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbResources).'</span>';
|
||||
$head[$h][2] = 'resources';
|
||||
$h++;
|
||||
}
|
||||
@@ -480,11 +482,11 @@ function actions_prepare_head($object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->agenda->dir_output . "/" . $object->id;
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -493,9 +495,9 @@ function actions_prepare_head($object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'action');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'action');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'action','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'action', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -549,16 +551,13 @@ function calendars_prepare_head($param)
|
||||
$h++;
|
||||
|
||||
|
||||
$object=new stdClass();
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'agenda');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'agenda','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'agenda', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@
|
||||
*
|
||||
* @param string $selected Preselected value
|
||||
* @param string $htmlname HTML name of input field
|
||||
* @param string $url Url for request: /path/page.php. Must return a json array ('key'=>id, 'value'=>String shown into input field once selected, 'label'=>String shown into combo list)
|
||||
* @param string $url Ajax Url to call for request: /path/page.php. Must return a json array ('key'=>id, 'value'=>String shown into input field once selected, 'label'=>String shown into combo list)
|
||||
* @param string $urloption More parameters on URL request
|
||||
* @param int $minLength Minimum number of chars to trigger that Ajax search
|
||||
* @param int $autoselect Automatic selection if just one value
|
||||
@@ -43,7 +43,7 @@
|
||||
* - Ex: array('option_disabled'=> id to disable and warning to show if we select a disabled value (this is possible when using autocomplete ajax)
|
||||
* @return string Script
|
||||
*/
|
||||
function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array())
|
||||
function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLength = 2, $autoselect = 0, $ajaxoptions = array())
|
||||
{
|
||||
if (empty($minLength)) $minLength=1;
|
||||
|
||||
@@ -58,7 +58,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
||||
$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />';
|
||||
|
||||
$script.= '<!-- Javascript code for autocomplete of field '.$htmlname.' -->'."\n";
|
||||
$script.= '<script type="text/javascript">'."\n";
|
||||
$script.= '<script>'."\n";
|
||||
$script.= '$(document).ready(function() {
|
||||
var autoselect = '.$autoselect.';
|
||||
var options = '.json_encode($ajaxoptions).';
|
||||
@@ -221,10 +221,10 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
||||
* @param int $autoselect Automatic selection if just one value
|
||||
* @return string Script
|
||||
*/
|
||||
function ajax_multiautocompleter($htmlname, $fields, $url, $option='', $minLength=2, $autoselect=0)
|
||||
function ajax_multiautocompleter($htmlname, $fields, $url, $option = '', $minLength = 2, $autoselect = 0)
|
||||
{
|
||||
$script = '<!-- Autocomplete -->'."\n";
|
||||
$script.= '<script type="text/javascript">';
|
||||
$script.= '<script>';
|
||||
$script.= 'jQuery(document).ready(function() {
|
||||
var fields = '.json_encode($fields).';
|
||||
var nboffields = fields.length;
|
||||
@@ -326,17 +326,17 @@ function ajax_multiautocompleter($htmlname, $fields, $url, $option='', $minLengt
|
||||
* @param string $message Message of dialog box
|
||||
* @param int $w Width of dialog box
|
||||
* @param int $h height of dialog box
|
||||
* @return void
|
||||
* @return string
|
||||
*/
|
||||
function ajax_dialog($title,$message,$w=350,$h=150)
|
||||
function ajax_dialog($title, $message, $w = 350, $h = 150)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$newtitle=dol_textishtml($title)?dol_string_nohtmltag($title,1):$title;
|
||||
$newtitle=dol_textishtml($title)?dol_string_nohtmltag($title, 1):$title;
|
||||
$msg= '<div id="dialog-info" title="'.dol_escape_htmltag($newtitle).'">';
|
||||
$msg.= $message;
|
||||
$msg.= '</div>'."\n";
|
||||
$msg.= '<script type="text/javascript">
|
||||
$msg.= '<script>
|
||||
jQuery(function() {
|
||||
jQuery("#dialog-info").dialog({
|
||||
resizable: false,
|
||||
@@ -369,27 +369,27 @@ function ajax_dialog($title,$message,$w=350,$h=150)
|
||||
* @param int $forcefocus Force focus on field
|
||||
* @param string $widthTypeOfAutocomplete 'resolve' or 'off'
|
||||
* @return string Return html string to convert a select field into a combo, or '' if feature has been disabled for some reason.
|
||||
* @see selectArrayAjax of html.form.class
|
||||
* @see selectArrayAjax() of html.form.class
|
||||
*/
|
||||
function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve')
|
||||
function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = 0, $forcefocus = 0, $widthTypeOfAutocomplete = 'resolve')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// select2 disabled for smartphones with standard browser.
|
||||
// TODO With select2 v4, it seems ok, except that responsive style on table become crazy when scrolling at end of array)
|
||||
if ($conf->browser->layout == 'phone') return '';
|
||||
// select2 can be disabled for smartphones
|
||||
if (! empty($conf->browser->layout) && $conf->browser->layout == 'phone' && ! empty($conf->global->MAIN_DISALLOW_SELECT2_WITH_SMARTPHONE)) return '';
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
|
||||
if (empty($conf->use_javascript_ajax)) return '';
|
||||
if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return '';
|
||||
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return '';
|
||||
|
||||
if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
|
||||
|
||||
$tmpplugin='select2';
|
||||
$msg="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$(\''.(preg_match('/^\./',$htmlname)?$htmlname:'#'.$htmlname).'\').'.$tmpplugin.'({
|
||||
$(\''.(preg_match('/^\./', $htmlname)?$htmlname:'#'.$htmlname).'\').'.$tmpplugin.'({
|
||||
dir: \'ltr\',
|
||||
width: \''.$widthTypeOfAutocomplete.'\', /* off or resolve */
|
||||
minimumInputLength: '.$minLengthToAutocomplete.',
|
||||
@@ -480,7 +480,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $
|
||||
* @param bool $strict Use only "disabled" with delConstant and "enabled" with setConstant
|
||||
* @return string
|
||||
*/
|
||||
function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0)
|
||||
function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
@@ -488,13 +488,13 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0,
|
||||
|
||||
if (empty($conf->use_javascript_ajax))
|
||||
{
|
||||
if (empty($conf->global->$code)) print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||
else print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"),'on').'</a>';
|
||||
if (empty($conf->global->$code)) print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||
else print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out= "\n<!-- Ajax code to switch constant ".$code." -->".'
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var input = '.json_encode($input).';
|
||||
var url = \''.DOL_URL_ROOT.'/core/ajax/constantonoff.php\';
|
||||
@@ -529,8 +529,8 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0,
|
||||
</script>'."\n";
|
||||
|
||||
$out.= '<div id="confirm_'.$code.'" title="" style="display: none;"></div>';
|
||||
$out.= '<span id="set_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'hideobject':'').'">'.($revertonoff?img_picto($langs->trans("Enabled"),'switch_on'):img_picto($langs->trans("Disabled"),'switch_off')).'</span>';
|
||||
$out.= '<span id="del_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'':'hideobject').'">'.($revertonoff?img_picto($langs->trans("Disabled"),'switch_off'):img_picto($langs->trans("Enabled"),'switch_on')).'</span>';
|
||||
$out.= '<span id="set_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'hideobject':'').'">'.($revertonoff?img_picto($langs->trans("Enabled"), 'switch_on'):img_picto($langs->trans("Disabled"), 'switch_off')).'</span>';
|
||||
$out.= '<span id="del_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'':'hideobject').'">'.($revertonoff?img_picto($langs->trans("Disabled"), 'switch_off'):img_picto($langs->trans("Enabled"), 'switch_on')).'</span>';
|
||||
$out.="\n";
|
||||
}
|
||||
|
||||
@@ -538,21 +538,22 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0,
|
||||
}
|
||||
|
||||
/**
|
||||
* On/off button for object
|
||||
* On/off button to change status of an object
|
||||
* This is called when MAIN_DIRECT_STATUS_UPDATE is set and it use tha ajax service objectonoff.php
|
||||
*
|
||||
* @param int $object Id product to set
|
||||
* @param Object $object Object to set
|
||||
* @param string $code Name of constant : status or status_buy for product by example
|
||||
* @param string $field Name of database field : tosell or tobuy for product by example
|
||||
* @param string $field Name of database field : 'tosell' or 'tobuy' for product by example
|
||||
* @param string $text_on Text if on
|
||||
* @param string $text_off Text if off
|
||||
* @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
|
||||
* @return string html for button on/off
|
||||
*/
|
||||
function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array())
|
||||
function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array())
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$out= '<script type="text/javascript">
|
||||
$out= '<script>
|
||||
$(function() {
|
||||
var input = '.json_encode($input).';
|
||||
|
||||
@@ -617,8 +618,8 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=a
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
$out.= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans($text_off),'switch_off').'</span>';
|
||||
$out.= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans($text_on),'switch_on').'</span>';
|
||||
$out.= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'hideobject':'').'">'.img_picto($langs->trans($text_off), 'switch_off').'</span>';
|
||||
$out.= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code==1?'':'hideobject').'">'.img_picto($langs->trans($text_on), 'switch_on').'</span>';
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
/* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* 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
|
||||
@@ -12,7 +12,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ function asset_admin_prepare_head()
|
||||
//$this->tabs = array(
|
||||
// 'entity:-tabname:Title:@assets:/asset/mypage.php?id=__ID__'
|
||||
//); // to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'assets_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
@@ -60,7 +60,7 @@ function asset_admin_prepare_head()
|
||||
$head[$h][2] = 'attributes_type';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin', 'remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'assets_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -68,11 +68,12 @@ function asset_admin_prepare_head()
|
||||
/**
|
||||
* Prepare admin pages header
|
||||
*
|
||||
* @param Contrat $object Object related to tabs
|
||||
* @return array head array with tabs
|
||||
*/
|
||||
function asset_prepare_head()
|
||||
function asset_prepare_head(Asset $object)
|
||||
{
|
||||
global $langs, $conf;
|
||||
global $db, $langs, $conf;
|
||||
|
||||
$langs->load("assets");
|
||||
|
||||
@@ -96,12 +97,12 @@ function asset_prepare_head()
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->assets->dir_output . '/' . get_exdir($filename,2,0,1,$object,'assets'). '/'. dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$upload_dir = $conf->assets->dir_output . '/' . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -110,7 +111,7 @@ function asset_prepare_head()
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/asset/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Notes");
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
|
||||
@@ -146,9 +147,9 @@ function asset_type_prepare_head(AssetType $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'assettype');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'assettype','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'assettype', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
*
|
||||
* 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
|
||||
@@ -15,8 +16,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -37,42 +38,42 @@ function bank_prepare_head(Account $object)
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/compta/bank/card.php?id=' . $object->id;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/bank/card.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'bankname';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . "/compta/bank/bankentries_list.php?id=" . $object->id;
|
||||
$head[$h][0] = DOL_URL_ROOT."/compta/bank/bankentries_list.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans("BankTransactions");
|
||||
$head[$h][2] = 'journal';
|
||||
$h++;
|
||||
|
||||
// if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
|
||||
// {
|
||||
$head[$h][0] = DOL_URL_ROOT . "/compta/bank/treso.php?account=" . $object->id;
|
||||
// if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
|
||||
// {
|
||||
$head[$h][0] = DOL_URL_ROOT."/compta/bank/treso.php?account=".$object->id;
|
||||
$head[$h][1] = $langs->trans("PlannedTransactions");
|
||||
$head[$h][2] = 'cash';
|
||||
$h++;
|
||||
// }
|
||||
// }
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . "/compta/bank/annuel.php?account=" . $object->id;
|
||||
$head[$h][0] = DOL_URL_ROOT."/compta/bank/annuel.php?account=".$object->id;
|
||||
$head[$h][1] = $langs->trans("IOMonthlyReporting");
|
||||
$head[$h][2] = 'annual';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . "/compta/bank/graph.php?account=" . $object->id;
|
||||
$head[$h][0] = DOL_URL_ROOT."/compta/bank/graph.php?account=".$object->id;
|
||||
$head[$h][1] = $langs->trans("Graph");
|
||||
$head[$h][2] = 'graph';
|
||||
$h++;
|
||||
|
||||
if ($object->courant != Account::TYPE_CASH)
|
||||
{
|
||||
$nbReceipts=0;
|
||||
$nbReceipts = 0;
|
||||
|
||||
// List of all standing receipts
|
||||
$sql = "SELECT COUNT(DISTINCT(b.num_releve)) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||
$sql.= " WHERE b.fk_account = ".$object->id;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||
$sql .= " WHERE b.fk_account = ".$object->id;
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@@ -84,7 +85,7 @@ function bank_prepare_head(Account $object)
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$object->id;
|
||||
$head[$h][1] = $langs->trans("AccountStatements");
|
||||
if (($nbReceipts) > 0) $head[$h][1].= ' <span class="badge">'.($nbReceipts).'</span>';
|
||||
if (($nbReceipts) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbReceipts).'</span>';
|
||||
$head[$h][2] = 'statement';
|
||||
$h++;
|
||||
}
|
||||
@@ -92,12 +93,12 @@ function bank_prepare_head(Account $object)
|
||||
// Attached files
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT . "/compta/bank/document.php?account=" . $object->id;
|
||||
$upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks = Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT."/compta/bank/document.php?account=".$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
|
||||
$head[$h][2] = 'document';
|
||||
$h++;
|
||||
|
||||
@@ -128,12 +129,12 @@ function bank_admin_prepare_head($object)
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/admin/bank.php';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/bank.php';
|
||||
$head[$h][1] = $langs->trans("Miscellaneous");
|
||||
$head[$h][2] = 'general';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/admin/chequereceipts.php';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/chequereceipts.php';
|
||||
$head[$h][1] = $langs->trans("CheckReceiptShort");
|
||||
$head[$h][2] = 'checkreceipts';
|
||||
$h++;
|
||||
@@ -152,9 +153,50 @@ function bank_admin_prepare_head($object)
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank_admin', 'remove');
|
||||
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare array with list of tabs
|
||||
*
|
||||
* @param Object $object Object related to tabs
|
||||
* @param Object $num val to account statement
|
||||
* @return array Array of tabs to shoc
|
||||
*/
|
||||
function account_statement_prepare_head($object, $num)
|
||||
{
|
||||
global $langs, $conf, $user, $db;
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/bank/releve.php?account='.$object->id.'&num='.$num;
|
||||
$head[$h][1] = $langs->trans("AccountStatements");
|
||||
$head[$h][2] = 'statement';
|
||||
$h++;
|
||||
|
||||
// Attached files
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->bank->dir_output."/".$object->id.'/'.dol_sanitizeFileName($num);
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks = Link::count($db, $object->element, $object->id);
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/compta/bank/account_statement_document.php?account=".$object->id."&num=".$num;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
|
||||
$head[$h][2] = 'document';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'account_statement');
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'account_statement', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare array with list of tabs
|
||||
*
|
||||
@@ -163,7 +205,6 @@ function bank_admin_prepare_head($object)
|
||||
*/
|
||||
function various_payment_prepare_head($object)
|
||||
{
|
||||
|
||||
global $db, $langs, $conf;
|
||||
|
||||
$h = 0;
|
||||
@@ -178,16 +219,16 @@ function various_payment_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'various_payment');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'various_payment');
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->banque->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$upload_dir = $conf->bank->dir_output."/".dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks = Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/bank/various_payment/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -196,7 +237,7 @@ function various_payment_prepare_head($object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'various_payment', 'remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'various_payment', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -252,12 +293,12 @@ function checkBanForAccount($account)
|
||||
if (empty($account->cle))
|
||||
$account->cle = $account->cle_rib;
|
||||
|
||||
dol_syslog("bank.lib::checkBanForAccount account->code_banque=" . $account->code_banque . " account->code_guichet=" . $account->code_guichet . " account->number=" . $account->number . " account->cle=" . $account->cle . " account->iban=" . $account->iban . " country_code=" . $country_code, LOG_DEBUG);
|
||||
dol_syslog("bank.lib::checkBanForAccount account->code_banque=".$account->code_banque." account->code_guichet=".$account->code_guichet." account->number=".$account->number." account->cle=".$account->cle." account->iban=".$account->iban." country_code=".$country_code, LOG_DEBUG);
|
||||
|
||||
if ($country_code == 'FR') { // France rules
|
||||
$coef = array(62, 34, 3);
|
||||
// Concatenation des differents codes.
|
||||
$rib = strtolower(trim($account->code_banque) . trim($account->code_guichet) . trim($account->number) . trim($account->cle));
|
||||
$rib = strtolower(trim($account->code_banque).trim($account->code_guichet).trim($account->number).trim($account->cle));
|
||||
// On remplace les eventuelles lettres par des chiffres.
|
||||
//$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678912345678"); //Ne marche pas
|
||||
$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz", "12345678912345678923456789");
|
||||
@@ -277,12 +318,11 @@ function checkBanForAccount($account)
|
||||
}
|
||||
|
||||
if ($country_code == 'BE') { // Belgium rules
|
||||
|
||||
}
|
||||
|
||||
if ($country_code == 'ES') { // Spanish rules
|
||||
$CCC = strtolower(trim($account->number));
|
||||
$rib = strtolower(trim($account->code_banque) . trim($account->code_guichet));
|
||||
$rib = strtolower(trim($account->code_banque).trim($account->code_guichet));
|
||||
$cle_rib = strtolower(checkES($rib, $CCC));
|
||||
if ($cle_rib == strtolower($account->cle)) {
|
||||
return true;
|
||||
@@ -292,7 +332,7 @@ function checkBanForAccount($account)
|
||||
if ($country_code == 'AU') { // Australian
|
||||
if (strlen($account->code_banque) > 7)
|
||||
return false; // Sould be 6 but can be 123-456
|
||||
else if (strlen($account->code_banque) < 6)
|
||||
elseif (strlen($account->code_banque) < 6)
|
||||
return false; // Sould be 6
|
||||
else
|
||||
return true;
|
||||
@@ -324,7 +364,7 @@ function checkES($IentOfi, $InumCta)
|
||||
return $keycontrol;
|
||||
}
|
||||
|
||||
$ccc = $IentOfi . $InumCta;
|
||||
$ccc = $IentOfi.$InumCta;
|
||||
$numbers = "1234567890";
|
||||
|
||||
$i = 0;
|
||||
@@ -356,7 +396,7 @@ function checkES($IentOfi, $InumCta)
|
||||
$sum = 0;
|
||||
|
||||
for ($i = 0; $i < 11; $i++) {
|
||||
$sum += $values[$i] * (int) substr($InumCta, $i, 1);//int to cast result of substr to a number
|
||||
$sum += $values[$i] * (int) substr($InumCta, $i, 1); //int to cast result of substr to a number
|
||||
}
|
||||
|
||||
$key = 11 - $sum % 11;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -65,11 +65,11 @@ else $genbarcode_loc = $conf->global->GENBARCODE_LOCATION;
|
||||
* @param string $mode 'png' or 'jpg' ...
|
||||
* @return array|string $bars array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info) or string with error message
|
||||
*/
|
||||
function barcode_print($code, $encoding="ANY", $scale = 2 ,$mode = "png")
|
||||
function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png")
|
||||
{
|
||||
dol_syslog("barcode.lib.php::barcode_print $code $encoding $scale $mode");
|
||||
|
||||
$bars=barcode_encode($code,$encoding);
|
||||
$bars=barcode_encode($code, $encoding);
|
||||
if (! $bars || ! empty($bars['error']))
|
||||
{
|
||||
// Return error message instead of array
|
||||
@@ -106,9 +106,9 @@ function barcode_print($code, $encoding="ANY", $scale = 2 ,$mode = "png")
|
||||
*
|
||||
* @param string $code Code
|
||||
* @param string $encoding Encoding
|
||||
* @return array array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
|
||||
* @return array|false array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
|
||||
*/
|
||||
function barcode_encode($code,$encoding)
|
||||
function barcode_encode($code, $encoding)
|
||||
{
|
||||
global $genbarcode_loc;
|
||||
|
||||
@@ -128,7 +128,7 @@ function barcode_encode($code,$encoding)
|
||||
dol_syslog("barcode.lib.php::barcode_encode Use barcode_encode_ean");
|
||||
$bars=barcode_encode_ean($code, $encoding);
|
||||
}
|
||||
else if (file_exists($genbarcode_loc)) // For example C39
|
||||
elseif (file_exists($genbarcode_loc)) // For example C39
|
||||
{
|
||||
/* use genbarcode */
|
||||
dol_syslog("barcode.lib.php::barcode_encode Use genbarcode ".$genbarcode_loc." code=".$code." encoding=".$encoding);
|
||||
@@ -138,7 +138,7 @@ function barcode_encode($code,$encoding)
|
||||
{
|
||||
print "barcode_encode needs an external programm for encodings other then EAN/ISBN (code=".$code.", encoding=".$encoding.")<BR>\n";
|
||||
print "<UL>\n";
|
||||
print "<LI>download gnu-barcode from <A href=\"http://www.gnu.org/software/barcode/\">www.gnu.org/software/barcode/</A>\n";
|
||||
print "<LI>download gnu-barcode from <A href=\"https://www.gnu.org/software/barcode/\">www.gnu.org/software/barcode/</A>\n";
|
||||
print "<LI>compile and install them\n";
|
||||
print "<LI>download genbarcode from <A href=\"http://www.ashberg.de/bar/\">www.ashberg.de/bar/</A>\n";
|
||||
print "<LI>compile and install them\n";
|
||||
@@ -184,7 +184,7 @@ function barcode_encode_ean($ean, $encoding = "EAN-13")
|
||||
$guards=array("9a1a","1a1a1","a1a");
|
||||
|
||||
$ean=trim($ean);
|
||||
if (preg_match("/[^0-9]/i",$ean))
|
||||
if (preg_match("/[^0-9]/i", $ean))
|
||||
{
|
||||
return array("error"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (not a numeric)", "text"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (not a numeric)");
|
||||
}
|
||||
@@ -199,7 +199,7 @@ function barcode_encode_ean($ean, $encoding = "EAN-13")
|
||||
return array("error"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (must have 12/13 numbers)", "text"=>"Invalid encoding/code. encoding=".$encoding." code=".$ean." (must have 12/13 numbers)");
|
||||
}
|
||||
|
||||
$ean=substr($ean,0,12);
|
||||
$ean=substr($ean, 0, 12);
|
||||
$eansum=barcode_gen_ean_sum($ean);
|
||||
$ean.=$eansum;
|
||||
$line=$guards[0];
|
||||
@@ -219,7 +219,7 @@ function barcode_encode_ean($ean, $encoding = "EAN-13")
|
||||
if ($a>0) $text.=" ";
|
||||
$text.="$pos:12:{$ean[$a]}";
|
||||
if ($a==0) $pos+=12;
|
||||
else if ($a==6) $pos+=12;
|
||||
elseif ($a==6) $pos+=12;
|
||||
else $pos+=7;
|
||||
}
|
||||
|
||||
@@ -236,14 +236,14 @@ function barcode_encode_ean($ean, $encoding = "EAN-13")
|
||||
*
|
||||
* @param string $code Code
|
||||
* @param string $encoding Encoding
|
||||
* @return array array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
|
||||
* @return array|false array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info)
|
||||
*/
|
||||
function barcode_encode_genbarcode($code,$encoding)
|
||||
function barcode_encode_genbarcode($code, $encoding)
|
||||
{
|
||||
global $genbarcode_loc;
|
||||
|
||||
// Clean parameters
|
||||
if (preg_match("/^ean$/i", $encoding) && strlen($code)==13) $code=substr($code,0,12);
|
||||
if (preg_match("/^ean$/i", $encoding) && strlen($code)==13) $code=substr($code, 0, 12);
|
||||
if (!$encoding) $encoding="ANY";
|
||||
$encoding=preg_replace("/[\\\|]/", "_", $encoding);
|
||||
$code=preg_replace("/[\\\|]/", "_", $code);
|
||||
@@ -277,7 +277,7 @@ function barcode_encode_genbarcode($code,$encoding)
|
||||
"error" => ""
|
||||
);
|
||||
//var_dump($ret);
|
||||
if (preg_match('/permission denied/i',$ret['bars']))
|
||||
if (preg_match('/permission denied/i', $ret['bars']))
|
||||
{
|
||||
$ret['error']=$ret['bars']; $ret['bars']='';
|
||||
return $ret;
|
||||
@@ -348,9 +348,9 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0,
|
||||
}
|
||||
$im=imagecreate($total_x, $total_y);
|
||||
/* create two images */
|
||||
$col_bg=ImageColorAllocate($im,$bg_color[0],$bg_color[1],$bg_color[2]);
|
||||
$col_bar=ImageColorAllocate($im,$bar_color[0],$bar_color[1],$bar_color[2]);
|
||||
$col_text=ImageColorAllocate($im,$text_color[0],$text_color[1],$text_color[2]);
|
||||
$col_bg=ImageColorAllocate($im, $bg_color[0], $bg_color[1], $bg_color[2]);
|
||||
$col_bar=ImageColorAllocate($im, $bar_color[0], $bar_color[1], $bar_color[2]);
|
||||
$col_text=ImageColorAllocate($im, $text_color[0], $text_color[1], $text_color[2]);
|
||||
$height=round($total_y-($scale*10));
|
||||
$height2=round($total_y-$space['bottom']);
|
||||
|
||||
@@ -397,14 +397,14 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0,
|
||||
header("Content-Type: image/jpeg; name=\"barcode.jpg\"");
|
||||
imagejpeg($im);
|
||||
}
|
||||
else if ($mode=='gif')
|
||||
elseif ($mode=='gif')
|
||||
{
|
||||
header("Content-Type: image/gif; name=\"barcode.gif\"");
|
||||
imagegif($im);
|
||||
}
|
||||
else if (! empty($filebarcode)) // To wxrite into afile onto disk
|
||||
elseif (! empty($filebarcode)) // To wxrite into afile onto disk
|
||||
{
|
||||
imagepng($im,$filebarcode);
|
||||
imagepng($im, $filebarcode);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -412,4 +412,3 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0,
|
||||
imagepng($im);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@
|
||||
* @param string $type Type of category
|
||||
* @return array Array of tabs to show
|
||||
*/
|
||||
function categories_prepare_head($object,$type)
|
||||
function categories_prepare_head($object, $type)
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
|
||||
@@ -61,9 +61,9 @@ function categories_prepare_head($object,$type)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'categories_'.$type);
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'categories_'.$type);
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'categories_'.$type,'remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'categories_'.$type, 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -97,11 +97,9 @@ function categoriesadmin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'categoriesadmin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'categoriesadmin');
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'categoriesadmin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'categoriesadmin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,8 +15,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -58,18 +58,27 @@ function contact_prepare_head(Contact $object)
|
||||
$head[$tab][2] = 'perso';
|
||||
$tab++;
|
||||
|
||||
// Related items
|
||||
if (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->ficheinter->enabled) || ! empty($conf->fournisseur->enabled))
|
||||
{
|
||||
$head[$tab][0] = DOL_URL_ROOT.'/contact/consumption.php?id='.$object->id;
|
||||
$head[$tab][1] = $langs->trans("Referers");
|
||||
$head[$tab][2] = 'consumption';
|
||||
$tab++;
|
||||
}
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $tab, 'contact');
|
||||
|
||||
// Notes
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
|
||||
$nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1);
|
||||
$head[$tab][0] = DOL_URL_ROOT.'/contact/note.php?id='.$object->id;
|
||||
$head[$tab][1] = $langs->trans("Note");
|
||||
if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if($nbNote > 0) $head[$tab][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$tab][2] = 'note';
|
||||
$tab++;
|
||||
}
|
||||
@@ -77,11 +86,11 @@ function contact_prepare_head(Contact $object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->societe->dir_output . "/contact/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$tab][0] = DOL_URL_ROOT.'/contact/document.php?id='.$object->id;
|
||||
$head[$tab][1] = $langs->trans("Documents");
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$tab][2] = 'documents';
|
||||
$tab++;
|
||||
|
||||
@@ -103,8 +112,7 @@ function contact_prepare_head(Contact $object)
|
||||
$head[$tab][2] = 'info';
|
||||
$tab++;*/
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$tab,'contact','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $tab, 'contact', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -30,8 +30,8 @@
|
||||
*/
|
||||
function contract_prepare_head(Contrat $object)
|
||||
{
|
||||
global $db, $langs, $conf;
|
||||
|
||||
global $db, $langs, $conf, $user;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
@@ -42,10 +42,10 @@ function contract_prepare_head(Contrat $object)
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("ContactsAddresses");
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ function contract_prepare_head(Contrat $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'contract');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'contract');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
@@ -63,7 +63,7 @@ function contract_prepare_head(Contrat $object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Notes");
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
@@ -71,20 +71,25 @@ function contract_prepare_head(Contrat $object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id;
|
||||
$head[$h][1].= $langs->trans("Events");
|
||||
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
|
||||
{
|
||||
$head[$h][1].= '/';
|
||||
$head[$h][1].= $langs->trans("Agenda");
|
||||
}
|
||||
$head[$h][2] = 'agenda';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'contract','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'contract', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -96,7 +101,7 @@ function contract_prepare_head(Contrat $object)
|
||||
*/
|
||||
function contract_admin_prepare_head()
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
global $langs, $conf;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
@@ -110,7 +115,7 @@ function contract_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'contract_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contrat/admin/contract_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
@@ -122,10 +127,7 @@ function contract_admin_prepare_head()
|
||||
$head[$h][2] = 'attributeslines';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'contract_admin', 'remove');
|
||||
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'contract_admin','remove');
|
||||
|
||||
return $head;
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -87,50 +87,48 @@ function dol_print_cron_urls()
|
||||
global $dolibarr_main_url_root;
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
|
||||
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
// Cron launch
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>';
|
||||
$url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
|
||||
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||
print $langs->trans("URLToLaunchCronJobs").':<br>';
|
||||
$url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
|
||||
print img_picto('', 'globe').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||
print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>';
|
||||
$url=$urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
|
||||
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||
$url = $urlwithroot.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
|
||||
print img_picto('', 'globe').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||
print '</div>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
$logintouse = 'firstadmin';
|
||||
if ($user->admin) $logintouse = $user->login;
|
||||
|
||||
|
||||
print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
|
||||
|
||||
$file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]';
|
||||
$file = '/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY) ? 'securitykey' : ''.$conf->global->CRON_KEY.'').' '.$logintouse.' [cronjobid]';
|
||||
print '<textarea class="quatrevingtpercent">..'.$file."</textarea><br>\n";
|
||||
print '<br>';
|
||||
|
||||
// Add note
|
||||
if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON))
|
||||
{
|
||||
$linuxlike=1;
|
||||
if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
|
||||
if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
|
||||
$linuxlike = 1;
|
||||
if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0;
|
||||
if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0;
|
||||
print $langs->trans("Note").': ';
|
||||
if ($linuxlike)
|
||||
{
|
||||
print $langs->trans("CronExplainHowToRunUnix");
|
||||
print '<br>';
|
||||
print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' > '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>';
|
||||
print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY) ? 'securitykey' : ''.$conf->global->CRON_KEY.'').' '.$logintouse.' > '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("CronExplainHowToRunWin");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2011-2015 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
|
||||
*
|
||||
* 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
|
||||
@@ -15,8 +16,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -79,13 +80,12 @@ function getServerTimeZoneString()
|
||||
* @param string $refgmtdate Reference period for timezone (timezone differs on winter and summer. May be 'now', 'winter' or 'summer')
|
||||
* @return int An offset in hour (+1 for Europe/Paris on winter and +2 for Europe/Paris on summer)
|
||||
*/
|
||||
function getServerTimeZoneInt($refgmtdate='now')
|
||||
function getServerTimeZoneInt($refgmtdate = 'now')
|
||||
{
|
||||
global $conf;
|
||||
if (method_exists('DateTimeZone','getOffset'))
|
||||
if (method_exists('DateTimeZone', 'getOffset'))
|
||||
{
|
||||
// Method 1 (include daylight)
|
||||
$gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow,'%Y'); $monthref=dol_print_date($gmtnow,'%m'); $dayref=dol_print_date($gmtnow,'%d');
|
||||
$gmtnow=dol_now('gmt'); $yearref=dol_print_date($gmtnow, '%Y'); $monthref=dol_print_date($gmtnow, '%m'); $dayref=dol_print_date($gmtnow, '%d');
|
||||
if ($refgmtdate == 'now') $newrefgmtdate=$yearref.'-'.$monthref.'-'.$dayref;
|
||||
elseif ($refgmtdate == 'summer') $newrefgmtdate=$yearref.'-08-01';
|
||||
else $newrefgmtdate=$yearref.'-01-01';
|
||||
@@ -98,7 +98,7 @@ function getServerTimeZoneInt($refgmtdate='now')
|
||||
else
|
||||
{
|
||||
$tmp=0;
|
||||
dol_print_error('','PHP version must be 5.3+');
|
||||
dol_print_error('', 'PHP version must be 5.3+');
|
||||
}
|
||||
$tz=round(($tmp<0?1:-1)*abs($tmp/3600));
|
||||
return $tz;
|
||||
@@ -135,7 +135,7 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit)
|
||||
$interval = new DateInterval($deltastring);
|
||||
|
||||
if($sub) $date->sub($interval);
|
||||
else $date->add( $interval );
|
||||
else $date->add($interval);
|
||||
|
||||
return $date->getTimestamp();
|
||||
}
|
||||
@@ -148,9 +148,9 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit)
|
||||
* @param int $iMinutes Minutes
|
||||
* @param int $iSeconds Seconds
|
||||
* @return int Time into seconds
|
||||
* @see convertSecondToTime
|
||||
* @see convertSecondToTime()
|
||||
*/
|
||||
function convertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0)
|
||||
function convertTime2Seconds($iHours = 0, $iMinutes = 0, $iSeconds = 0)
|
||||
{
|
||||
$iResult=($iHours*3600)+($iMinutes*60)+$iSeconds;
|
||||
return $iResult;
|
||||
@@ -164,6 +164,7 @@ function convertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0)
|
||||
* @param string $format Output format ('all': total delay days hour:min like "2 days 12:30",
|
||||
* - 'allwithouthour': total delay days without hour part like "2 days",
|
||||
* - 'allhourmin': total delay with format hours:min like "60:30",
|
||||
* - 'allhourminsec': total delay with format hours:min:sec like "60:30:10",
|
||||
* - 'allhour': total delay hours without min/sec like "60:30",
|
||||
* - 'fullhour': total delay hour decimal like "60.5" for 60:30,
|
||||
* - 'hour': only hours part "12",
|
||||
@@ -175,16 +176,16 @@ function convertTime2Seconds($iHours=0,$iMinutes=0,$iSeconds=0)
|
||||
* @param int $lengthOfWeek Length of week (default 7)
|
||||
* @return string Formated text of duration
|
||||
* Example: 0 return 00:00, 3600 return 1:00, 86400 return 1d, 90000 return 1 Day 01:00
|
||||
* @see convertTime2Seconds
|
||||
* @see convertTime2Seconds()
|
||||
*/
|
||||
function convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
|
||||
function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $lengthOfWeek = 7)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if (empty($lengthOfDay)) $lengthOfDay = 86400; // 1 day = 24 hours
|
||||
if (empty($lengthOfWeek)) $lengthOfWeek = 7; // 1 week = 7 days
|
||||
|
||||
if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin')
|
||||
if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin' || $format == 'allhourminsec')
|
||||
{
|
||||
if ((int) $iSecond === 0) return '0'; // This is to avoid having 0 return a 12:00 AM for en_US
|
||||
|
||||
@@ -228,23 +229,27 @@ function convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengt
|
||||
{
|
||||
if ($iSecond || empty($sDay))
|
||||
{
|
||||
$sTime.= dol_print_date($iSecond,'hourduration',true);
|
||||
$sTime.= dol_print_date($iSecond, 'hourduration', true);
|
||||
}
|
||||
}
|
||||
if ($format == 'allhourmin')
|
||||
elseif ($format == 'allhourminsec')
|
||||
{
|
||||
return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d",((int) floor(($iSecond % 3600)/60)));
|
||||
return sprintf("%02d", ($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600)/60))).':'.sprintf("%02d", ((int) ($iSecond % 60)));
|
||||
}
|
||||
if ($format == 'allhour')
|
||||
elseif ($format == 'allhourmin')
|
||||
{
|
||||
return sprintf("%02d",($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600)));
|
||||
return sprintf("%02d", ($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600)/60)));
|
||||
}
|
||||
elseif ($format == 'allhour')
|
||||
{
|
||||
return sprintf("%02d", ($sWeek*$lengthOfWeek*24 + $sDay*24 + (int) floor($iSecond/3600)));
|
||||
}
|
||||
}
|
||||
else if ($format == 'hour') // only hour part
|
||||
elseif ($format == 'hour') // only hour part
|
||||
{
|
||||
$sTime=dol_print_date($iSecond,'%H',true);
|
||||
$sTime=dol_print_date($iSecond, '%H', true);
|
||||
}
|
||||
else if ($format == 'fullhour')
|
||||
elseif ($format == 'fullhour')
|
||||
{
|
||||
if (!empty($iSecond)) {
|
||||
$iSecond=$iSecond/3600;
|
||||
@@ -254,26 +259,56 @@ function convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengt
|
||||
}
|
||||
$sTime=$iSecond;
|
||||
}
|
||||
else if ($format == 'min') // only min part
|
||||
elseif ($format == 'min') // only min part
|
||||
{
|
||||
$sTime=dol_print_date($iSecond,'%M',true);
|
||||
$sTime=dol_print_date($iSecond, '%M', true);
|
||||
}
|
||||
else if ($format == 'sec') // only sec part
|
||||
elseif ($format == 'sec') // only sec part
|
||||
{
|
||||
$sTime=dol_print_date($iSecond,'%S',true);
|
||||
$sTime=dol_print_date($iSecond, '%S', true);
|
||||
}
|
||||
else if ($format == 'month') // only month part
|
||||
elseif ($format == 'month') // only month part
|
||||
{
|
||||
$sTime=dol_print_date($iSecond,'%m',true);
|
||||
$sTime=dol_print_date($iSecond, '%m', true);
|
||||
}
|
||||
else if ($format == 'year') // only year part
|
||||
elseif ($format == 'year') // only year part
|
||||
{
|
||||
$sTime=dol_print_date($iSecond,'%Y',true);
|
||||
$sTime=dol_print_date($iSecond, '%Y', true);
|
||||
}
|
||||
return trim($sTime);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate a SQL string to make a filter into a range (for second of date until last second of date)
|
||||
*
|
||||
* @param string $datefield Name of SQL field where apply sql date filter
|
||||
* @param int $day_date Day date
|
||||
* @param int $month_date Month date
|
||||
* @param int $year_date Year date
|
||||
* @param int $excludefirstand Exclude first and
|
||||
* @return string $sqldate String with SQL filter
|
||||
*/
|
||||
function dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand = 0)
|
||||
{
|
||||
global $db;
|
||||
$sqldate="";
|
||||
if ($month_date > 0) {
|
||||
if ($year_date > 0 && empty($day_date)) {
|
||||
$sqldate.= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, $month_date, false));
|
||||
$sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, $month_date, false))."'";
|
||||
} elseif ($year_date > 0 && ! empty($day_date)) {
|
||||
$sqldate.= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date));
|
||||
$sqldate.= "' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date))."'";
|
||||
} else
|
||||
$sqldate.= ($excludefirstand ? "" : " AND ")." date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'";
|
||||
} elseif ($year_date > 0){
|
||||
$sqldate.= ($excludefirstand ? "" : " AND ").$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, 1, false));
|
||||
$sqldate.= "' AND '".$db->idate(dol_get_last_day($year_date, 12, false))."'";
|
||||
}
|
||||
return $sqldate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a string date into a GM Timestamps date
|
||||
* Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not supported. If parameter gm is 1, we will use no TZ, if not we will use TZ of server, not the one inside string.
|
||||
@@ -289,13 +324,15 @@ function convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengt
|
||||
* 0 =Input date is local date using PHP server timezone
|
||||
* @return int Date as a timestamp
|
||||
* 19700101020000 -> 7200 with gm=1
|
||||
* 19700101000000 -> 0 with gm=1
|
||||
*
|
||||
* @see dol_print_date, dol_mktime, dol_getdate
|
||||
* @see dol_print_date(), dol_mktime(), dol_getdate()
|
||||
*/
|
||||
function dol_stringtotime($string, $gm=1)
|
||||
function dol_stringtotime($string, $gm = 1)
|
||||
{
|
||||
$reg=array();
|
||||
// Convert date with format DD/MM/YYY HH:MM:SS. This part of code should not be used.
|
||||
if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i',$string,$reg))
|
||||
if (preg_match('/^([0-9]+)\/([0-9]+)\/([0-9]+)\s?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $string, $reg))
|
||||
{
|
||||
dol_syslog("dol_stringtotime call to function with deprecated parameter format", LOG_WARNING);
|
||||
// Date est au format 'DD/MM/YY' ou 'DD/MM/YY HH:MM:SS'
|
||||
@@ -308,12 +345,12 @@ function dol_stringtotime($string, $gm=1)
|
||||
$ssec = $reg[6];
|
||||
if ($syear < 50) $syear+=1900;
|
||||
if ($syear >= 50 && $syear < 100) $syear+=2000;
|
||||
$string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
|
||||
$string=sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec);
|
||||
}
|
||||
else if (
|
||||
preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i',$string,$reg) // Convert date with format YYYY-MM-DDTHH:MM:SSZ (RFC3339)
|
||||
|| preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/i',$string,$reg) // Convert date with format YYYY-MM-DD HH:MM:SS
|
||||
|| preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z$/i',$string,$reg) // Convert date with format YYYYMMDDTHHMMSSZ
|
||||
elseif (
|
||||
preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i', $string, $reg) // Convert date with format YYYY-MM-DDTHH:MM:SSZ (RFC3339)
|
||||
|| preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/i', $string, $reg) // Convert date with format YYYY-MM-DD HH:MM:SS
|
||||
|| preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z$/i', $string, $reg) // Convert date with format YYYYMMDDTHHMMSSZ
|
||||
)
|
||||
{
|
||||
$syear = $reg[1];
|
||||
@@ -322,12 +359,12 @@ function dol_stringtotime($string, $gm=1)
|
||||
$shour = $reg[4];
|
||||
$smin = $reg[5];
|
||||
$ssec = $reg[6];
|
||||
$string=sprintf("%04d%02d%02d%02d%02d%02d",$syear,$smonth,$sday,$shour,$smin,$ssec);
|
||||
$string=sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec);
|
||||
}
|
||||
|
||||
$string=preg_replace('/([^0-9])/i','',$string);
|
||||
$string=preg_replace('/([^0-9])/i', '', $string);
|
||||
$tmp=$string.'000000';
|
||||
$date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),($gm?1:0));
|
||||
$date=dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), ($gm?1:0));
|
||||
return $date;
|
||||
}
|
||||
|
||||
@@ -341,9 +378,9 @@ function dol_stringtotime($string, $gm=1)
|
||||
*/
|
||||
function dol_get_prev_day($day, $month, $year)
|
||||
{
|
||||
$time=dol_mktime(12,0,0,$month,$day,$year,1,0);
|
||||
$time=dol_mktime(12, 0, 0, $month, $day, $year, 1, 0);
|
||||
$time-=24*60*60;
|
||||
$tmparray=dol_getdate($time,true);
|
||||
$tmparray=dol_getdate($time, true);
|
||||
return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
|
||||
}
|
||||
|
||||
@@ -356,9 +393,9 @@ function dol_get_prev_day($day, $month, $year)
|
||||
*/
|
||||
function dol_get_next_day($day, $month, $year)
|
||||
{
|
||||
$time=dol_mktime(12,0,0,$month,$day,$year,1,0);
|
||||
$time=dol_mktime(12, 0, 0, $month, $day, $year, 1, 0);
|
||||
$time+=24*60*60;
|
||||
$tmparray=dol_getdate($time,true);
|
||||
$tmparray=dol_getdate($time, true);
|
||||
return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
|
||||
}
|
||||
|
||||
@@ -416,9 +453,9 @@ function dol_get_prev_week($day, $week, $month, $year)
|
||||
{
|
||||
$tmparray = dol_get_first_day_week($day, $month, $year);
|
||||
|
||||
$time=dol_mktime(12,0,0,$month,$tmparray['first_day'],$year,1,0);
|
||||
$time=dol_mktime(12, 0, 0, $month, $tmparray['first_day'], $year, 1, 0);
|
||||
$time-=24*60*60*7;
|
||||
$tmparray=dol_getdate($time,true);
|
||||
$tmparray=dol_getdate($time, true);
|
||||
return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
|
||||
}
|
||||
|
||||
@@ -434,9 +471,9 @@ function dol_get_next_week($day, $week, $month, $year)
|
||||
{
|
||||
$tmparray = dol_get_first_day_week($day, $month, $year);
|
||||
|
||||
$time=dol_mktime(12,0,0,$tmparray['first_month'],$tmparray['first_day'],$tmparray['first_year'],1,0);
|
||||
$time=dol_mktime(12, 0, 0, $tmparray['first_month'], $tmparray['first_day'], $tmparray['first_year'], 1, 0);
|
||||
$time+=24*60*60*7;
|
||||
$tmparray=dol_getdate($time,true);
|
||||
$tmparray=dol_getdate($time, true);
|
||||
|
||||
return array('year' => $tmparray['year'], 'month' => $tmparray['mon'], 'day' => $tmparray['mday']);
|
||||
}
|
||||
@@ -450,10 +487,10 @@ function dol_get_next_week($day, $week, $month, $year)
|
||||
* Exemple: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, after a dol_print_date will return 1970-01-01 00:00:00
|
||||
* @return int Date for first day, '' if error
|
||||
*/
|
||||
function dol_get_first_day($year,$month=1,$gm=false)
|
||||
function dol_get_first_day($year, $month = 1, $gm = false)
|
||||
{
|
||||
if ($year > 9999) return '';
|
||||
return dol_mktime(0,0,0,$month,1,$year,$gm);
|
||||
return dol_mktime(0, 0, 0, $month, 1, $year, $gm);
|
||||
}
|
||||
|
||||
|
||||
@@ -464,7 +501,7 @@ function dol_get_first_day($year,$month=1,$gm=false)
|
||||
* @param boolean $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
|
||||
* @return int Date for first day, '' if error
|
||||
*/
|
||||
function dol_get_last_day($year,$month=12,$gm=false)
|
||||
function dol_get_last_day($year, $month = 12, $gm = false)
|
||||
{
|
||||
if ($year > 9999) return '';
|
||||
if ($month == 12)
|
||||
@@ -478,7 +515,7 @@ function dol_get_last_day($year,$month=12,$gm=false)
|
||||
}
|
||||
|
||||
// On se deplace au debut du mois suivant, et on retire un jour
|
||||
$datelim=dol_mktime(23,59,59,$month,1,$year,$gm);
|
||||
$datelim=dol_mktime(23, 59, 59, $month, 1, $year, $gm);
|
||||
$datelim -= (3600 * 24);
|
||||
|
||||
return $datelim;
|
||||
@@ -492,17 +529,17 @@ function dol_get_last_day($year,$month=12,$gm=false)
|
||||
* @param int $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
|
||||
* @return array year,month,week,first_day,first_month,first_year,prev_day,prev_month,prev_year
|
||||
*/
|
||||
function dol_get_first_day_week($day,$month,$year,$gm=false)
|
||||
function dol_get_first_day_week($day, $month, $year, $gm = false)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
//$day=2; $month=2; $year=2015;
|
||||
$date = dol_mktime(0,0,0,$month,$day,$year,$gm);
|
||||
$date = dol_mktime(0, 0, 0, $month, $day, $year, $gm);
|
||||
|
||||
//Checking conf of start week
|
||||
$start_week = (isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1);
|
||||
|
||||
$tmparray = dol_getdate($date,true); // detail of current day
|
||||
$tmparray = dol_getdate($date, true); // detail of current day
|
||||
|
||||
//Calculate days = offset from current day
|
||||
$days = $start_week - $tmparray['wday'];
|
||||
@@ -513,7 +550,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
|
||||
|
||||
//Get first day of week
|
||||
$tmpdaytms = date($tmparray[0])-$seconds; // $tmparray[0] is day of parameters
|
||||
$tmpday = date("d",$tmpdaytms);
|
||||
$tmpday = date("d", $tmpdaytms);
|
||||
|
||||
//Check first day of week is in same month than current day or not
|
||||
if ($tmpday>$day)
|
||||
@@ -536,9 +573,9 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
|
||||
$tmpyear = $prev_year;
|
||||
|
||||
//Get first day of next week
|
||||
$tmptime=dol_mktime(12,0,0,$month,$tmpday,$year,1,0);
|
||||
$tmptime=dol_mktime(12, 0, 0, $month, $tmpday, $year, 1, 0);
|
||||
$tmptime-=24*60*60*7;
|
||||
$tmparray=dol_getdate($tmptime,true);
|
||||
$tmparray=dol_getdate($tmptime, true);
|
||||
$prev_day = $tmparray['mday'];
|
||||
|
||||
//Check prev day of week is in same month than first day or not
|
||||
@@ -554,51 +591,59 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
|
||||
}
|
||||
}
|
||||
|
||||
$week = date("W",dol_mktime(0,0,0,$tmpmonth,$tmpday,$tmpyear,$gm));
|
||||
$week = date("W", dol_mktime(0, 0, 0, $tmpmonth, $tmpday, $tmpyear, $gm));
|
||||
|
||||
return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'first_month' => $tmpmonth, 'first_year' => $tmpyear, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction retournant le nombre de jour feries, samedis et dimanches entre 2 dates entrees en timestamp. Dates must be UTC with hour, day, min to 0
|
||||
* Return the number of non working days including saturday and sunday (or not) between 2 dates in timestamp.
|
||||
* Dates must be UTC with hour, day, min to 0.
|
||||
* Called by function num_open_day
|
||||
*
|
||||
* @param int $timestampStart Timestamp de debut
|
||||
* @param int $timestampEnd Timestamp de fin
|
||||
* @param string $countrycode Country code
|
||||
* @param string $country_code Country code
|
||||
* @param int $lastday Last day is included, 0: no, 1:yes
|
||||
* @return int Nombre de jours feries
|
||||
* @see num_between_day, num_open_day
|
||||
* @param int $includesaturday Include saturday as non working day (-1=use setup, 0=no, 1=yes)
|
||||
* @param int $includesunday Include sunday as non working day (-1=use setup, 0=no, 1=yes)
|
||||
* @return int|string Number of non working days or error message string if error
|
||||
* @see num_between_day(), num_open_day()
|
||||
*/
|
||||
function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $lastday=0)
|
||||
function num_public_holiday($timestampStart, $timestampEnd, $country_code = '', $lastday = 0, $includesaturday = -1, $includesunday = -1)
|
||||
{
|
||||
global $conf;
|
||||
global $db, $conf, $mysoc;
|
||||
|
||||
$nbFerie = 0;
|
||||
$specialdayrule = array();
|
||||
|
||||
// Check to ensure we use correct parameters
|
||||
if ((($timestampEnd - $timestampStart) % 86400) != 0) return 'ErrorDates must use same hours and must be GMT dates';
|
||||
|
||||
if (empty($country_code)) $country_code = $mysoc->country_code;
|
||||
|
||||
if ($includesaturday < 0) $includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
|
||||
if ($includesunday < 0) $includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);
|
||||
|
||||
|
||||
$i=0;
|
||||
while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) )
|
||||
&& ($i < 50000)) // Loop end when equals (Test on i is a security loop to avoid infinite loop)
|
||||
{
|
||||
$ferie=false;
|
||||
$countryfound=0;
|
||||
$includesaturdayandsunday=1;
|
||||
|
||||
$jour = date("d", $timestampStart);
|
||||
$mois = date("m", $timestampStart);
|
||||
$annee = date("Y", $timestampStart);
|
||||
|
||||
|
||||
// Check into var $conf->global->HOLIDAY_MORE_DAYS MM-DD,YYYY-MM-DD, ...
|
||||
// Do not use this anymore, use instead the dictionary of public holidays.
|
||||
if (! empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS))
|
||||
{
|
||||
$arrayofdaystring=explode(',',$conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS);
|
||||
$arrayofdaystring=explode(',', $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS);
|
||||
foreach($arrayofdaystring as $daystring)
|
||||
{
|
||||
$tmp=explode('-',$daystring);
|
||||
$tmp=explode('-', $daystring);
|
||||
if ($tmp[2])
|
||||
{
|
||||
if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie=true;
|
||||
@@ -610,29 +655,61 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $
|
||||
}
|
||||
}
|
||||
|
||||
if ($countrycode == 'FR')
|
||||
$country_id = dol_getIdFromCode($db, $country_code, 'c_country', 'code', 'rowid');
|
||||
|
||||
// Loop on public holiday defined into hrm_public_holiday
|
||||
$sql = "SELECT code, entity, fk_country, dayrule, year, month, day, active";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_hrm_public_holiday";
|
||||
$sql.= " WHERE active = 1 and fk_country IN (0".($country_id > 0 ? ", ".$country_id : 0).")";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$countryfound=1;
|
||||
$num_rows = $db->num_rows($resql);
|
||||
$i=0;
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
// Definition of fixed working days
|
||||
if($jour == 1 && $mois == 1) $ferie=true; // 1er january
|
||||
if($jour == 1 && $mois == 5) $ferie=true; // 1er may
|
||||
if($jour == 8 && $mois == 5) $ferie=true; // 5 may
|
||||
if($jour == 14 && $mois == 7) $ferie=true; // 14 july
|
||||
if($jour == 15 && $mois == 8) $ferie=true; // 15 august
|
||||
if($jour == 1 && $mois == 11) $ferie=true; // 1 november
|
||||
if($jour == 11 && $mois == 11) $ferie=true; // 11 november
|
||||
if($jour == 25 && $mois == 12) $ferie=true; // 25 december
|
||||
if (! empty($obj->dayrule) && $obj->dayrule != 'date') // For example 'easter', '...'
|
||||
{
|
||||
$specialdayrule[$obj->dayrule] = $obj->dayrule;
|
||||
}
|
||||
else
|
||||
{
|
||||
$match = 1;
|
||||
if (! empty($obj->year) && $obj->year != $annee) $match = 0;
|
||||
if ($obj->month != $mois) $match = 0;
|
||||
if ($obj->day != $jour) $match = 0;
|
||||
|
||||
if ($match) $ferie = true;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog($db->lasterror(), LOG_ERR);
|
||||
return 'Error sql '.$db->lasterror();
|
||||
}
|
||||
|
||||
// Special dayrules
|
||||
if (in_array('easter', $specialdayrule))
|
||||
{
|
||||
// Calculation for easter date
|
||||
$date_paques = easter_date($annee);
|
||||
$jour_paques = date("d", $date_paques);
|
||||
$mois_paques = date("m", $date_paques);
|
||||
if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
|
||||
// Pâques
|
||||
// Easter (sunday)
|
||||
}
|
||||
|
||||
if (in_array('eastermonday', $specialdayrule))
|
||||
{
|
||||
// Calculation for the monday of easter date
|
||||
$date_lundi_paques = mktime(
|
||||
$date_paques = easter_date($annee);
|
||||
$date_lundi_paques = mktime(
|
||||
date("H", $date_paques),
|
||||
date("i", $date_paques),
|
||||
date("s", $date_paques),
|
||||
@@ -642,11 +719,15 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $
|
||||
);
|
||||
$jour_lundi_ascension = date("d", $date_lundi_paques);
|
||||
$mois_lundi_ascension = date("m", $date_lundi_paques);
|
||||
if($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true;
|
||||
// Lundi de Pâques
|
||||
if ($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true;
|
||||
// Easter (monday)
|
||||
}
|
||||
|
||||
// Calcul du jour de l'ascension (38 days after easter day)
|
||||
$date_ascension = mktime(
|
||||
if (in_array('ascension', $specialdayrule))
|
||||
{
|
||||
// Calcul du jour de l'ascension (39 days after easter day)
|
||||
$date_paques = easter_date($annee);
|
||||
$date_ascension = mktime(
|
||||
date("H", $date_paques),
|
||||
date("i", $date_paques),
|
||||
date("s", $date_paques),
|
||||
@@ -657,10 +738,14 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $
|
||||
$jour_ascension = date("d", $date_ascension);
|
||||
$mois_ascension = date("m", $date_ascension);
|
||||
if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true;
|
||||
// Ascension
|
||||
// Ascension (thursday)
|
||||
}
|
||||
|
||||
// Calculation of "Pentecote" (11 days after easter day)
|
||||
$date_pentecote = mktime(
|
||||
if (in_array('pentecote', $specialdayrule))
|
||||
{
|
||||
// Calculation of "Pentecote" (49 days after easter day)
|
||||
$date_paques = easter_date($annee);
|
||||
$date_pentecote = mktime(
|
||||
date("H", $date_paques),
|
||||
date("i", $date_paques),
|
||||
date("s", $date_paques),
|
||||
@@ -671,71 +756,31 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $
|
||||
$jour_pentecote = date("d", $date_pentecote);
|
||||
$mois_pentecote = date("m", $date_pentecote);
|
||||
if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true;
|
||||
// "Pentecote"
|
||||
// "Pentecote" (sunday)
|
||||
}
|
||||
|
||||
// Pentecoste and Ascensione in Italy go to the sunday after: isn't holiday.
|
||||
// Pentecoste is 50 days after Easter, Ascensione 40
|
||||
if ($countrycode == 'IT')
|
||||
if (in_array('pentecotemonday', $specialdayrule))
|
||||
{
|
||||
$countryfound=1;
|
||||
|
||||
// Definition des dates feriees fixes
|
||||
if($jour == 1 && $mois == 1) $ferie=true; // Capodanno
|
||||
if($jour == 6 && $mois == 1) $ferie=true; // Epifania
|
||||
if($jour == 25 && $mois == 4) $ferie=true; // Anniversario Liberazione
|
||||
if($jour == 1 && $mois == 5) $ferie=true; // Festa del Lavoro
|
||||
if($jour == 2 && $mois == 6) $ferie=true; // Festa della Repubblica
|
||||
if($jour == 15 && $mois == 8) $ferie=true; // Ferragosto
|
||||
if($jour == 1 && $mois == 11) $ferie=true; // Tutti i Santi
|
||||
if($jour == 8 && $mois == 12) $ferie=true; // Immacolata Concezione
|
||||
if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre
|
||||
if($jour == 26 && $mois == 12) $ferie=true; // Santo Stefano
|
||||
|
||||
// Calcul du jour de paques
|
||||
// Calculation of "Pentecote" (49 days after easter day)
|
||||
$date_paques = easter_date($annee);
|
||||
$jour_paques = date("d", $date_paques);
|
||||
$mois_paques = date("m", $date_paques);
|
||||
if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
|
||||
// Paques
|
||||
$date_pentecote = mktime(
|
||||
date("H", $date_paques),
|
||||
date("i", $date_paques),
|
||||
date("s", $date_paques),
|
||||
date("m", $date_paques),
|
||||
date("d", $date_paques) + 50,
|
||||
date("Y", $date_paques)
|
||||
);
|
||||
$jour_pentecote = date("d", $date_pentecote);
|
||||
$mois_pentecote = date("m", $date_pentecote);
|
||||
if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true;
|
||||
// "Pentecote" (monday)
|
||||
}
|
||||
|
||||
if ($countrycode == 'IN')
|
||||
if (in_array('viernessanto', $specialdayrule))
|
||||
{
|
||||
$countryfound=1;
|
||||
|
||||
if($jour == 1 && $mois == 1) $ferie=true; // New Year's Day
|
||||
if($jour == 26 && $mois == 1) $ferie=true; // Republic Day
|
||||
if($jour == 1 && $mois == 5) $ferie=true; // May Day
|
||||
if($jour == 15 && $mois == 8) $ferie=true; // Independence Day
|
||||
if($jour == 2 && $mois == 10) $ferie=true; // Gandhi Jayanti
|
||||
if($jour == 25 && $mois == 12) $ferie=true; // Christmas
|
||||
}
|
||||
|
||||
if ($countrycode == 'ES')
|
||||
{
|
||||
$countryfound=1;
|
||||
|
||||
// Definition des dates feriees fixes
|
||||
if($jour == 1 && $mois == 1) $ferie=true; // Año nuevo
|
||||
if($jour == 6 && $mois == 1) $ferie=true; // Día Reyes
|
||||
if($jour == 1 && $mois == 5) $ferie=true; // 1 Mayo
|
||||
if($jour == 15 && $mois == 8) $ferie=true; // 15 Agosto
|
||||
if($jour == 12 && $mois == 10) $ferie=true; // Día Hispanidad
|
||||
if($jour == 1 && $mois == 11) $ferie=true; // 1 noviembre
|
||||
if($jour == 6 && $mois == 12) $ferie=true; // Constitución
|
||||
if($jour == 8 && $mois == 12) $ferie=true; // Inmaculada
|
||||
if($jour == 25 && $mois == 12) $ferie=true; // 25 diciembre
|
||||
|
||||
// Calcul día de Pascua
|
||||
$date_paques = easter_date($annee);
|
||||
$jour_paques = date("d", $date_paques);
|
||||
$mois_paques = date("m", $date_paques);
|
||||
if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
|
||||
// Paques
|
||||
|
||||
// Viernes Santo
|
||||
$date_viernes = mktime(
|
||||
$date_paques = easter_date($annee);
|
||||
$date_viernes = mktime(
|
||||
date("H", $date_paques),
|
||||
date("i", $date_paques),
|
||||
date("s", $date_paques),
|
||||
@@ -749,74 +794,11 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $
|
||||
//Viernes Santo
|
||||
}
|
||||
|
||||
if ($countrycode == 'AT')
|
||||
if (in_array('fronleichnam', $specialdayrule))
|
||||
{
|
||||
$countryfound=1;
|
||||
|
||||
// Definition des dates feriees fixes
|
||||
if($jour == 1 && $mois == 1) $ferie=true; // Neujahr
|
||||
if($jour == 6 && $mois == 1) $ferie=true; // Hl. 3 Koenige
|
||||
if($jour == 1 && $mois == 5) $ferie=true; // 1. Mai
|
||||
if($jour == 15 && $mois == 8) $ferie=true; // Mariae Himmelfahrt
|
||||
if($jour == 26 && $mois == 10) $ferie=true; // 26. Oktober
|
||||
if($jour == 1 && $mois == 11) $ferie=true; // Allerheiligen
|
||||
if($jour == 8 && $mois == 12) $ferie=true; // Mariae Empfaengnis
|
||||
if($jour == 24 && $mois == 12) $ferie=true; // Heilig abend
|
||||
if($jour == 25 && $mois == 12) $ferie=true; // Christtag
|
||||
if($jour == 26 && $mois == 12) $ferie=true; // Stefanietag
|
||||
if($jour == 31 && $mois == 12) $ferie=true; // Silvester
|
||||
|
||||
// Easter calculation
|
||||
$date_paques = easter_date($annee);
|
||||
$jour_paques = date("d", $date_paques);
|
||||
$mois_paques = date("m", $date_paques);
|
||||
if($jour_paques == $jour && $mois_paques == $mois) $ferie=true;
|
||||
// Easter sunday
|
||||
|
||||
// Monday after easter
|
||||
$date_eastermonday = mktime(
|
||||
date("H", $date_paques),
|
||||
date("i", $date_paques),
|
||||
date("s", $date_paques),
|
||||
date("m", $date_paques),
|
||||
date("d", $date_paques) + 1,
|
||||
date("Y", $date_paques)
|
||||
);
|
||||
$jour_eastermonday = date("d", $date_eastermonday);
|
||||
$mois_eastermonday = date("m", $date_eastermonday);
|
||||
if($jour_eastermonday == $jour && $mois_eastermonday == $mois) $ferie=true;
|
||||
// Easter monday
|
||||
|
||||
// Christi Himmelfahrt (39 days after easter sunday)
|
||||
$date_ch = mktime(
|
||||
date("H", $date_paques),
|
||||
date("i", $date_paques),
|
||||
date("s", $date_paques),
|
||||
date("m", $date_paques),
|
||||
date("d", $date_paques) + 39,
|
||||
date("Y", $date_paques)
|
||||
);
|
||||
$jour_ch = date("d", $date_ch);
|
||||
$mois_ch = date("m", $date_ch);
|
||||
if($jour_ch == $jour && $mois_ch == $mois) $ferie=true;
|
||||
// Christi Himmelfahrt
|
||||
|
||||
// Pfingsten (50 days after easter sunday)
|
||||
$date_pentecote = mktime(
|
||||
date("H", $date_paques),
|
||||
date("i", $date_paques),
|
||||
date("s", $date_paques),
|
||||
date("m", $date_paques),
|
||||
date("d", $date_paques) + 50,
|
||||
date("Y", $date_paques)
|
||||
);
|
||||
$jour_pentecote = date("d", $date_pentecote);
|
||||
$mois_pentecote = date("m", $date_pentecote);
|
||||
if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true;
|
||||
// Pfingsten
|
||||
|
||||
// Fronleichnam (60 days after easter sunday)
|
||||
$date_fronleichnam = mktime(
|
||||
$date_paques = easter_date($annee);
|
||||
$date_fronleichnam = mktime(
|
||||
date("H", $date_paques),
|
||||
date("i", $date_paques),
|
||||
date("s", $date_paques),
|
||||
@@ -831,15 +813,21 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $
|
||||
}
|
||||
|
||||
// If we have to include saturday and sunday
|
||||
if ($includesaturdayandsunday)
|
||||
if ($includesaturday || $includesunday)
|
||||
{
|
||||
$jour_julien = unixtojd($timestampStart);
|
||||
$jour_semaine = jddayofweek($jour_julien, 0);
|
||||
if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true;
|
||||
//Saturday (6) and Sunday (0)
|
||||
if ($includesaturday) //Saturday (6) and Sunday (0)
|
||||
{
|
||||
if ($jour_semaine == 6) $ferie=true;
|
||||
}
|
||||
if ($includesunday) //Saturday (6) and Sunday (0)
|
||||
{
|
||||
if($jour_semaine == 0) $ferie=true;
|
||||
}
|
||||
}
|
||||
|
||||
// On incremente compteur
|
||||
// We increase the counter of non working day
|
||||
if ($ferie) $nbFerie++;
|
||||
|
||||
// Increase number of days (on go up into loop)
|
||||
@@ -860,9 +848,9 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $
|
||||
* @param int $timestampEnd Timestamp end UTC
|
||||
* @param int $lastday Last day is included, 0: no, 1:yes
|
||||
* @return int Number of days
|
||||
* @see also num_public_holiday, num_open_day
|
||||
* @seealso num_public_holiday(), num_open_day()
|
||||
*/
|
||||
function num_between_day($timestampStart, $timestampEnd, $lastday=0)
|
||||
function num_between_day($timestampStart, $timestampEnd, $lastday = 0)
|
||||
{
|
||||
if ($timestampStart < $timestampEnd)
|
||||
{
|
||||
@@ -890,9 +878,9 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0)
|
||||
* @param int $halfday Tag to define half day when holiday start and end
|
||||
* @param string $country_code Country code (company country code if not defined)
|
||||
* @return int Number of days or hours
|
||||
* @see also num_between_day, num_public_holiday
|
||||
* @seealso num_between_day(), num_public_holiday()
|
||||
*/
|
||||
function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $halfday=0, $country_code='')
|
||||
function num_open_day($timestampStart, $timestampEnd, $inhour = 0, $lastday = 0, $halfday = 0, $country_code = '')
|
||||
{
|
||||
global $langs,$mysoc;
|
||||
|
||||
@@ -936,7 +924,7 @@ function num_open_day($timestampStart, $timestampEnd, $inhour=0, $lastday=0, $ha
|
||||
* @param int $short 0=Return long label, 1=Return short label
|
||||
* @return array Month string or array if selected < 0
|
||||
*/
|
||||
function monthArray($outputlangs,$short=0)
|
||||
function monthArray($outputlangs, $short = 0)
|
||||
{
|
||||
$montharray = array (
|
||||
1 => $outputlangs->trans("Month01"),
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -31,14 +31,14 @@
|
||||
/**
|
||||
* Return line description translated in outputlangs and encoded into UTF8
|
||||
*
|
||||
* @param Line $line Current line number (0 = first line, 1 = second line, ...)
|
||||
* @param Object $line Object of line
|
||||
* @param Translate $outputlangs Object langs for output
|
||||
* @param int $hideref Hide reference
|
||||
* @param int $hidedesc Hide description
|
||||
* @param int $issupplierline Is it a line for a supplier object ?
|
||||
* @return string String with line
|
||||
*/
|
||||
function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierline=0)
|
||||
function doc_getlinedesc($line, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0)
|
||||
{
|
||||
global $db, $conf, $langs;
|
||||
|
||||
@@ -74,28 +74,28 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli
|
||||
$discount=new DiscountAbsolute($db);
|
||||
$discount->fetch($line->fk_remise_except);
|
||||
$sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source;
|
||||
$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$sourceref);
|
||||
$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote", $sourceref);
|
||||
}
|
||||
elseif ($desc == '(DEPOSIT)' && $line->fk_remise_except)
|
||||
{
|
||||
$discount=new DiscountAbsolute($db);
|
||||
$discount->fetch($line->fk_remise_except);
|
||||
$sourceref=!empty($discount->discount_type)?$discount->ref_invoive_supplier_source:$discount->ref_facture_source;
|
||||
$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$sourceref);
|
||||
$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref);
|
||||
// Add date of deposit
|
||||
if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.=' ('.dol_print_date($discount->datec,'day','',$outputlangs).')';
|
||||
if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.=' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')';
|
||||
}
|
||||
elseif ($desc == '(EXCESS RECEIVED)' && $line->fk_remise_except)
|
||||
{
|
||||
$discount=new DiscountAbsolute($db);
|
||||
$discount->fetch($line->fk_remise_except);
|
||||
$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived",$discount->ref_facture_source);
|
||||
$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessReceived", $discount->ref_facture_source);
|
||||
}
|
||||
elseif ($desc == '(EXCESS PAID)' && $line->fk_remise_except)
|
||||
{
|
||||
$discount=new DiscountAbsolute($db);
|
||||
$discount->fetch($line->fk_remise_except);
|
||||
$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid",$discount->ref_invoice_supplier_source);
|
||||
$libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -148,15 +148,15 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli
|
||||
// Show duration if exists
|
||||
if ($line->date_start && $line->date_end)
|
||||
{
|
||||
$period='('.$outputlangs->transnoentitiesnoconv('DateFromTo',dol_print_date($line->date_start, $format, false, $outputlangs),dol_print_date($line->date_end, $format, false, $outputlangs)).')';
|
||||
$period='('.$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($line->date_start, $format, false, $outputlangs), dol_print_date($line->date_end, $format, false, $outputlangs)).')';
|
||||
}
|
||||
if ($line->date_start && ! $line->date_end)
|
||||
{
|
||||
$period='('.$outputlangs->transnoentitiesnoconv('DateFrom',dol_print_date($line->date_start, $format, false, $outputlangs)).')';
|
||||
$period='('.$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($line->date_start, $format, false, $outputlangs)).')';
|
||||
}
|
||||
if (! $line->date_start && $line->date_end)
|
||||
{
|
||||
$period='('.$outputlangs->transnoentitiesnoconv('DateUntil',dol_print_date($line->date_end, $format, false, $outputlangs)).')';
|
||||
$period='('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($line->date_end, $format, false, $outputlangs)).')';
|
||||
}
|
||||
//print '>'.$outputlangs->charset_output.','.$period;
|
||||
$libelleproduitservice=dol_concatdesc($libelleproduitservice, $period);
|
||||
@@ -165,4 +165,3 @@ function doc_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli
|
||||
|
||||
return $libelleproduitservice;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* 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
|
||||
@@ -14,8 +14,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,41 +31,41 @@
|
||||
* @param int $edit 1 to add edit form
|
||||
* @return void
|
||||
*/
|
||||
function show_skin($fuser,$edit=0)
|
||||
function show_skin($fuser, $edit = 0)
|
||||
{
|
||||
global $conf,$langs,$db;
|
||||
global $conf, $langs, $db;
|
||||
global $bc;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
|
||||
$formother = new FormOther($db);
|
||||
|
||||
$dirskins=array('/includes/ckeditor/ckeditor/skins');
|
||||
if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application
|
||||
$dirskins = array('/includes/ckeditor/ckeditor/skins');
|
||||
if (!empty($conf->modules_parts['theme'])) // Using this feature slow down application
|
||||
{
|
||||
foreach($conf->modules_parts['theme'] as $reldir)
|
||||
foreach ($conf->modules_parts['theme'] as $reldir)
|
||||
{
|
||||
$dirskins=array_merge($dirskins,(array) ($reldir.'theme'));
|
||||
$dirskins = array_merge($dirskins, (array) ($reldir.'theme'));
|
||||
}
|
||||
}
|
||||
$dirskins=array_unique($dirskins);
|
||||
$dirskins = array_unique($dirskins);
|
||||
// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
|
||||
|
||||
$selected_theme='';
|
||||
if (empty($conf->global->FCKEDITOR_SKIN)) $selected_theme='moono-lisa';
|
||||
else $selected_theme=$conf->global->FCKEDITOR_SKIN;
|
||||
$selected_theme = '';
|
||||
if (empty($conf->global->FCKEDITOR_SKIN)) $selected_theme = 'moono-lisa';
|
||||
else $selected_theme = $conf->global->FCKEDITOR_SKIN;
|
||||
|
||||
$colspan=2;
|
||||
$colspan = 2;
|
||||
|
||||
$thumbsbyrow=6;
|
||||
print '<table class="noborder" width="100%">';
|
||||
$thumbsbyrow = 6;
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
$var=false;
|
||||
$var = false;
|
||||
|
||||
// Title
|
||||
print '<tr class="liste_titre"><th width="35%">'.$langs->trans("DefaultSkin").'</th>';
|
||||
print '<th align="right">';
|
||||
$url='http://ckeditor.com/addons/skins/all';
|
||||
print '<th class="right">';
|
||||
$url = 'http://ckeditor.com/addons/skins/all';
|
||||
/*print '<a href="'.$url.'" target="_blank">';
|
||||
print $langs->trans('DownloadMoreSkins');
|
||||
print '</a>';*/
|
||||
@@ -74,7 +74,7 @@ function show_skin($fuser,$edit=0)
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("ThemeDir").'</td>';
|
||||
print '<td>';
|
||||
foreach($dirskins as $dirskin)
|
||||
foreach ($dirskins as $dirskin)
|
||||
{
|
||||
echo '"'.$dirskin.'" ';
|
||||
}
|
||||
@@ -84,37 +84,37 @@ function show_skin($fuser,$edit=0)
|
||||
//
|
||||
print '<tr class="oddeven"><td colspan="'.$colspan.'">';
|
||||
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td><div align="center">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
|
||||
|
||||
$i=0;
|
||||
foreach($dirskins as $dir)
|
||||
$i = 0;
|
||||
foreach ($dirskins as $dir)
|
||||
{
|
||||
//print $dirroot.$dir;exit;
|
||||
$dirskin=dol_buildpath($dir,0); // This include loop on $conf->file->dol_document_root
|
||||
$urltheme=dol_buildpath($dir,1);
|
||||
$dirskin = dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root
|
||||
$urltheme = dol_buildpath($dir, 1);
|
||||
|
||||
if (is_dir($dirskin))
|
||||
{
|
||||
$handle=opendir($dirskin);
|
||||
$handle = opendir($dirskin);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($subdir = readdir($handle))!==false)
|
||||
while (($subdir = readdir($handle)) !== false)
|
||||
{
|
||||
if (is_dir($dirskin."/".$subdir) && substr($subdir, 0, 1) <> '.'
|
||||
&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
|
||||
&& substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir))
|
||||
{
|
||||
// Disable not stable themes (dir ends with _exp or _dev)
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i',$subdir)) continue;
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i',$subdir)) continue;
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue;
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i', $subdir)) continue;
|
||||
|
||||
print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
|
||||
if ($subdir == $selected_theme)
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="fckeditor_skin" value="'.$subdir.'"> <b>'.$subdir.'</b>';
|
||||
print '<input '.($edit ? '' : 'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="fckeditor_skin" value="'.$subdir.'"> <b>'.$subdir.'</b>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="fckeditor_skin" value="'.$subdir.'"> '.$subdir;
|
||||
print '<input '.($edit ? '' : 'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="fckeditor_skin" value="'.$subdir.'"> '.$subdir;
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
@@ -131,4 +131,3 @@ function show_skin($fuser,$edit=0)
|
||||
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* 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
|
||||
@@ -12,7 +12,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ function donation_admin_prepare_head()
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'donation_admin');
|
||||
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/don/admin/donation_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes';
|
||||
@@ -57,7 +57,7 @@ function donation_admin_prepare_head()
|
||||
/**
|
||||
* Prepare array with list of tabs
|
||||
*
|
||||
* @param Donation $object Donation
|
||||
* @param Don $object Donation
|
||||
* @return array Array of tabs to show
|
||||
*/
|
||||
function donation_prepare_head($object)
|
||||
@@ -80,12 +80,12 @@ function donation_prepare_head($object)
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->don->dir_output . '/' . get_exdir($filename,2,0,1,$object,'donation'). '/'. dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$upload_dir = $conf->don->dir_output . '/' . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/don/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -94,10 +94,10 @@ function donation_prepare_head($object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/don/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Notes");
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -56,9 +56,9 @@ function ecm_prepare_dasboard_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'ecm');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ecm');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'ecm','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ecm', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ function ecm_prepare_dasboard_head($object)
|
||||
* @param string $section Section
|
||||
* @return array Array of tabs to show
|
||||
*/
|
||||
function ecm_prepare_head($object, $module='ecm', $section='')
|
||||
function ecm_prepare_head($object, $module = 'ecm', $section = '')
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
$h = 0;
|
||||
@@ -140,4 +140,3 @@ function ecm_prepare_head_fm($object)
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ function emailing_prepare_head(Mailing $object)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans("MailRecipients");
|
||||
if ($object->nbemail > 0) $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>';
|
||||
if ($object->nbemail > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$object->nbemail.'</span>';
|
||||
$head[$h][2] = 'targets';
|
||||
$h++;
|
||||
}
|
||||
@@ -61,10 +61,9 @@ function emailing_prepare_head(Mailing $object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'emailing');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'emailing','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'emailing', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -41,25 +41,25 @@ function expedition_prepare_head(Expedition $object)
|
||||
$h = 0;
|
||||
$head = array();
|
||||
$h = 0;
|
||||
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/confexped.php";
|
||||
$head[$h][1] = $langs->trans("Setup");
|
||||
$h++;
|
||||
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
|
||||
$head[$h][1] = $langs->trans("Shipment");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
|
||||
if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/livraison.php";
|
||||
$head[$h][1] = $langs->trans("Receivings");
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove');
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -76,13 +76,13 @@ function expedition_admin_prepare_head()
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/confexped.php";
|
||||
$head[$h][1] = $langs->trans("Setup");
|
||||
$head[$h][2] = 'general';
|
||||
$h++;
|
||||
|
||||
|
||||
|
||||
|
||||
if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
|
||||
@@ -90,24 +90,24 @@ function expedition_admin_prepare_head()
|
||||
$head[$h][2] = 'shipment';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes_shipment';
|
||||
$h++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes_shipment';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsLines");
|
||||
$head[$h][2] = 'attributeslines_shipment';
|
||||
$h++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsLines");
|
||||
$head[$h][2] = 'attributeslines_shipment';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/livraison.php";
|
||||
@@ -115,7 +115,7 @@ function expedition_admin_prepare_head()
|
||||
$head[$h][2] = 'receivings';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/livraison_extrafields.php';
|
||||
@@ -123,7 +123,7 @@ function expedition_admin_prepare_head()
|
||||
$head[$h][2] = 'attributes_receivings';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/livraisondet_extrafields.php';
|
||||
@@ -131,12 +131,10 @@ function expedition_admin_prepare_head()
|
||||
$head[$h][2] = 'attributeslines_receivings';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'expedition_admin','remove');
|
||||
|
||||
|
||||
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'expedition_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -43,16 +43,16 @@ function expensereport_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport');
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/expensereport/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -63,7 +63,7 @@ function expensereport_prepare_head($object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/expensereport/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ function expensereport_prepare_head($object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'expensereport','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'expensereport', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -102,14 +102,14 @@ function payment_expensereport_prepare_head(PaymentExpenseReport $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/expensereport/payment/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_expensereport', 'remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_expensereport', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ function expensereport_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/expensereport_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
@@ -167,7 +167,7 @@ function expensereport_admin_prepare_head()
|
||||
$h++;
|
||||
*/
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'expensereport_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'expensereport_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -48,10 +48,10 @@ function fichinter_prepare_head($object)
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fichinter/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('InterventionContact');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
@@ -60,29 +60,30 @@ function fichinter_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention');
|
||||
|
||||
// Tab to link resources
|
||||
if ($conf->resource->enabled)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
|
||||
$nbResource = 0;
|
||||
$objectres=new Dolresource($db);
|
||||
if (is_array($objectres->available_resources))
|
||||
{
|
||||
foreach ($objectres->available_resources as $modresources => $resources)
|
||||
{
|
||||
$resources=(array) $resources; // To be sure $resources is an array
|
||||
foreach($resources as $resource_obj)
|
||||
{
|
||||
$linked_resources = $object->getElementResources('fichinter',$object->id,$resource_obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
$objectres = new Dolresource($db);
|
||||
$linked_resources = $objectres->getElementResources('fichinter', $object->id);
|
||||
$nbResource = (is_array($linked_resources)?count($linked_resources):0);
|
||||
// if (is_array($objectres->available_resources))
|
||||
// {
|
||||
// foreach ($objectres->available_resources as $modresources => $resources)
|
||||
// {
|
||||
// $resources=(array) $resources; // To be sure $resources is an array
|
||||
// foreach($resources as $resource_obj)
|
||||
// {
|
||||
// $linked_resources = $object->getElementResources('fichinter', $object->id, $resource_obj);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=fichinter&element_id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Resources");
|
||||
if ($nbResource > 0) $head[$h][1].= ' <span class="badge">'.$nbResource.'</span>';
|
||||
if ($nbResource > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbResource.'</span>';
|
||||
$head[$h][2] = 'resource';
|
||||
$h++;
|
||||
}
|
||||
@@ -94,7 +95,7 @@ function fichinter_prepare_head($object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fichinter/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
@@ -102,11 +103,11 @@ function fichinter_prepare_head($object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fichinter/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -115,7 +116,7 @@ function fichinter_prepare_head($object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'intervention','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -143,7 +144,7 @@ function fichinter_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'fichinter_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fichinter/admin/fichinter_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
@@ -157,7 +158,7 @@ function fichinter_admin_prepare_head()
|
||||
|
||||
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'fichinter_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'fichinter_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -182,7 +183,7 @@ function fichinter_rec_prepare_head($object)
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec');
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h,'intervention-rec','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec', 'remove');
|
||||
|
||||
|
||||
return $head;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* 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
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -43,14 +43,14 @@ function fiscalyear_prepare_head(Fiscalyear $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'fiscalyear');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'fiscalyear');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_info.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'fiscalyear','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'fiscalyear', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -66,4 +66,3 @@ foreach($_Avery_Labels as $key => $val)
|
||||
{
|
||||
$_Avery_Labels[$key]['name'].=' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')';
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -45,10 +45,10 @@ function facturefourn_prepare_head($object)
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/contact.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ function facturefourn_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_invoice');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
@@ -66,19 +66,19 @@ function facturefourn_prepare_head($object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/note.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$object->ref;
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$object->ref;
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -87,7 +87,7 @@ function facturefourn_prepare_head($object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_invoice','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_invoice', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -113,15 +113,15 @@ function ordersupplier_prepare_head($object)
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
|
||||
if (! empty($conf->stock->enabled) && (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)))
|
||||
{
|
||||
$langs->load("stocks");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id;
|
||||
@@ -134,7 +134,7 @@ function ordersupplier_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_order');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
@@ -143,7 +143,7 @@ function ordersupplier_prepare_head($object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Notes");
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
@@ -151,11 +151,11 @@ function ordersupplier_prepare_head($object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -168,7 +168,7 @@ function ordersupplier_prepare_head($object)
|
||||
}
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order', 'remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_order', 'remove');
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ function supplierorder_admin_prepare_head()
|
||||
$head[$h][2] = 'supplierpayment';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'supplierorder_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/supplierorder_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsSupplierOrders");
|
||||
@@ -223,9 +223,7 @@ function supplierorder_admin_prepare_head()
|
||||
$head[$h][2] = 'supplierinvoicedet';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'supplierorder_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'supplierorder_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -154,15 +154,15 @@ function dol_ch_controle_bvrb($bvrb)
|
||||
|
||||
|
||||
// Clean data
|
||||
$bv=str_replace(' ','',$bvrb);
|
||||
$bv=str_replace(' ', '', $bvrb);
|
||||
|
||||
// Make control
|
||||
$report=0;
|
||||
while (dol_strlen($bv)>1)
|
||||
{
|
||||
$match=substr($bv,0,1);
|
||||
$match=substr($bv, 0, 1);
|
||||
$report=$tableau[$report][$match];
|
||||
$bv=substr($bv,1);
|
||||
$bv=substr($bv, 1);
|
||||
}
|
||||
$controle=$tableau[$report][10];
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
/**
|
||||
* \file htdocs/core/lib/functionsnumbertoword.lib.php
|
||||
* \file htdocs/core/lib/functionsnumtoword.lib.php
|
||||
* \brief A set of functions for Dolibarr
|
||||
* This file contains all frequently used functions.
|
||||
*/
|
||||
@@ -27,24 +27,24 @@
|
||||
* Function to return number in text.
|
||||
*
|
||||
*
|
||||
* @param float $num Number to convert
|
||||
* @param Lang $langs Language
|
||||
* @param boolean $currency 0=number to translate | 1=currency to translate
|
||||
* @param boolean $centimes 0=no centimes | 1=centimes to translate
|
||||
* @return string Text of the number
|
||||
* @param float $num Number to convert
|
||||
* @param Translate $langs Language
|
||||
* @param boolean $currency 0=number to translate | 1=currency to translate
|
||||
* @param boolean $centimes 0=no centimes | 1=centimes to translate
|
||||
* @return string|false Text of the number
|
||||
*/
|
||||
function dol_convertToWord($num, $langs, $currency=false, $centimes=false)
|
||||
function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$num = str_replace(array(',', ' '), '', trim($num));
|
||||
if(! $num) {
|
||||
if (! $num) {
|
||||
return false;
|
||||
}
|
||||
if($centimes && strlen($num) == 1) {
|
||||
if ($centimes && strlen($num) == 1) {
|
||||
$num = $num*10;
|
||||
}
|
||||
$TNum = explode('.',$num);
|
||||
$TNum = explode('.', $num);
|
||||
$num = (int) $TNum[0];
|
||||
$words = array();
|
||||
$list1 = array(
|
||||
@@ -139,19 +139,19 @@ function dol_convertToWord($num, $langs, $currency=false, $centimes=false)
|
||||
* Function to return number or amount in text.
|
||||
*
|
||||
* @deprecated
|
||||
* @param float $numero Number to convert
|
||||
* @param Lang $langs Language
|
||||
* @param string $numorcurrency 'number' or 'amount'
|
||||
* @return string Text of the number or -1 in case TOO LONG (more than 1000000000000.99)
|
||||
* @param float $numero Number to convert
|
||||
* @param Translate $langs Language
|
||||
* @param string $numorcurrency 'number' or 'amount'
|
||||
* @return string Text of the number or -1 in case TOO LONG (more than 1000000000000.99)
|
||||
*/
|
||||
function dolNumberToWord($numero, $langs, $numorcurrency='number')
|
||||
function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
|
||||
{
|
||||
// If the number is negative convert to positive and return -1 if is too long
|
||||
if ($numero < 0) $numero *= -1;
|
||||
if ($numero >= 1000000000001)
|
||||
return -1;
|
||||
// Get 2 decimals to cents, another functions round or truncate
|
||||
$strnumber = number_format ($numero,10);
|
||||
$strnumber = number_format($numero, 10);
|
||||
$len=strlen($strnumber);
|
||||
for ($i=0; $i<$len; $i++)
|
||||
{
|
||||
@@ -187,7 +187,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency='number')
|
||||
$numero = $numero - $DdMMillon * 10000000000;
|
||||
$UdMMillon = (int) ($numero / 1000000000);
|
||||
$numero = $numero - $UdMMillon * 1000000000;
|
||||
$entexto .= hundreds2text ($CdMMillon, $DdMMillon, $UdMMillon);
|
||||
$entexto .= hundreds2text($CdMMillon, $DdMMillon, $UdMMillon);
|
||||
$entexto .= " MIL ";
|
||||
}
|
||||
if ($number >= 1000000){
|
||||
@@ -197,7 +197,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency='number')
|
||||
$numero = $numero - $DdMILLON * 10000000;
|
||||
$udMILLON = (int) ($numero / 1000000);
|
||||
$numero = $numero - $udMILLON * 1000000;
|
||||
$entexto .= hundreds2text ($CdMILLON, $DdMILLON, $udMILLON);
|
||||
$entexto .= hundreds2text($CdMILLON, $DdMILLON, $udMILLON);
|
||||
if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON==1)
|
||||
$entexto .= " MILLÓN ";
|
||||
else
|
||||
@@ -210,7 +210,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency='number')
|
||||
$numero = $numero - $ddm * 10000;
|
||||
$udm = (int) ($numero / 1000);
|
||||
$numero = $numero - $udm * 1000;
|
||||
$entexto .= hundreds2text ($cdm, $ddm, $udm);
|
||||
$entexto .= hundreds2text($cdm, $ddm, $udm);
|
||||
if ($cdm || $ddm || $udm)
|
||||
$entexto .= " MIL ";
|
||||
}
|
||||
@@ -218,7 +218,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency='number')
|
||||
$numero = $numero - $c * 100;
|
||||
$d = (int) ($numero / 10);
|
||||
$u = (int) $numero - $d * 10;
|
||||
$entexto .= hundreds2text ($c, $d, $u);
|
||||
$entexto .= hundreds2text($c, $d, $u);
|
||||
if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number>1000000)
|
||||
$entexto .= " DE";
|
||||
$entexto .= " PESOS ".$parte_decimal." / 100 M.N.";
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -22,19 +22,19 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function get content from an URL (use proxy if proxy defined)
|
||||
* Function to get a content from an URL (use proxy if proxy defined)
|
||||
*
|
||||
* @param string $url URL to call.
|
||||
* @param string $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'DELETE'
|
||||
* @param string $postorget 'POST', 'GET', 'HEAD', 'PUT', 'PUTALREADYFORMATED', 'POSTALREADYFORMATED', 'DELETE'
|
||||
* @param string $param Parameters of URL (x=value1&y=value2) or may be a formated content with PUTALREADYFORMATED
|
||||
* @param integer $followlocation 1=Follow location, 0=Do not follow
|
||||
* @param string[] $addheaders Array of string to add into header. Example: ('Accept: application/xrds+xml', ....)
|
||||
* @return array Returns an associative array containing the response from the server array('content'=>response,'curl_error_no'=>errno,'curl_error_msg'=>errmsg...)
|
||||
*/
|
||||
function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addheaders=array())
|
||||
function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = 1, $addheaders = array())
|
||||
{
|
||||
//declaring of global variables
|
||||
global $conf, $langs;
|
||||
global $conf;
|
||||
$USE_PROXY=empty($conf->global->MAIN_PROXY_USE)?0:$conf->global->MAIN_PROXY_USE;
|
||||
$PROXY_HOST=empty($conf->global->MAIN_PROXY_HOST)?0:$conf->global->MAIN_PROXY_HOST;
|
||||
$PROXY_PORT=empty($conf->global->MAIN_PROXY_PORT)?0:$conf->global->MAIN_PROXY_PORT;
|
||||
@@ -72,14 +72,20 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT)?30:$conf->global->MAIN_USE_RESPONSE_TIMEOUT);
|
||||
|
||||
//curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true); // PHP 5.5
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // We want response
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // We want response
|
||||
if ($postorget == 'POST')
|
||||
{
|
||||
curl_setopt($ch, CURLOPT_POST, 1); // POST
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // Setting param x=a&y=z as POST fields
|
||||
}
|
||||
else if ($postorget == 'PUT')
|
||||
elseif ($postorget == 'POSTALREADYFORMATED')
|
||||
{
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); // HTTP request is 'POST' but param string is taken as it is
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string
|
||||
}
|
||||
elseif ($postorget == 'PUT')
|
||||
{
|
||||
$array_param=null;
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
|
||||
if (! is_array($param)) parse_str($param, $array_param);
|
||||
else
|
||||
@@ -89,17 +95,17 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param)); // Setting param x=a&y=z as PUT fields
|
||||
}
|
||||
else if ($postorget == 'PUTALREADYFORMATED')
|
||||
elseif ($postorget == 'PUTALREADYFORMATED')
|
||||
{
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $param); // param = content of post, like a xml string
|
||||
}
|
||||
else if ($postorget == 'HEAD')
|
||||
elseif ($postorget == 'HEAD')
|
||||
{
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'HEAD'); // HTTP request is 'HEAD'
|
||||
curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||
}
|
||||
else if ($postorget == 'DELETE')
|
||||
elseif ($postorget == 'DELETE')
|
||||
{
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); // POST
|
||||
}
|
||||
@@ -136,7 +142,7 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
$rep['curl_error_no']=curl_errno($ch);
|
||||
$rep['curl_error_msg']=curl_error($ch);
|
||||
|
||||
dol_syslog("getURLContent response array is ".join(',',$rep));
|
||||
dol_syslog("getURLContent response array is ".join(',', $rep));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -166,14 +172,25 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
* For example: https://www.abc.mydomain.com/dir/page.html return 'mydomain'
|
||||
*
|
||||
* @param string $url Full URL.
|
||||
* @param int $mode 0=return 'mydomain', 1=return 'mydomain.com', 2=return 'abc.mydomain.com'
|
||||
* @return string Returns domaine name
|
||||
*/
|
||||
function getDomainFromURL($url)
|
||||
function getDomainFromURL($url, $mode = 0)
|
||||
{
|
||||
$tmpdomain = preg_replace('/^https?:\/\//i', '', $url); // Remove http(s)://
|
||||
$tmpdomain = preg_replace('/\/.*$/i', '', $tmpdomain); // Remove part after domain
|
||||
$tmpdomain = preg_replace('/\.[^\.]+$/', '', $tmpdomain); // Remove first level domain (.com, .net, ...)
|
||||
$tmpdomain = preg_replace('/^[^\.]+\./', '', $tmpdomain); // Remove part www. before domain name
|
||||
if ($mode == 2)
|
||||
{
|
||||
$tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)\.([^\.]+)$/', '\1.\2.\3', $tmpdomain); // Remove part 'www.' before 'abc.mydomain.com'
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmpdomain = preg_replace('/^.*\.([^\.]+)\.([^\.]+)$/', '\1.\2', $tmpdomain); // Remove part 'www.abc.' before 'mydomain.com'
|
||||
}
|
||||
if (empty($mode))
|
||||
{
|
||||
$tmpdomain = preg_replace('/\.[^\.]+$/', '', $tmpdomain); // Remove first level domain (.com, .net, ...)
|
||||
}
|
||||
|
||||
return $tmpdomain;
|
||||
}
|
||||
@@ -190,6 +207,7 @@ function getRootURLFromURL($url)
|
||||
{
|
||||
$prefix='';
|
||||
$tmpurl = $url;
|
||||
$reg = null;
|
||||
if (preg_match('/^(https?:\/\/)/i', $tmpurl, $reg)) $prefix = $reg[1];
|
||||
$tmpurl = preg_replace('/^https?:\/\//i', '', $tmpurl); // Remove http(s)://
|
||||
$tmpurl = preg_replace('/\/.*$/i', '', $tmpurl); // Remove part after domain
|
||||
@@ -208,4 +226,3 @@ function removeHtmlComment($content)
|
||||
$content = preg_replace('/<!--[^\-]+-->/', '', $content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -43,11 +43,11 @@ function holiday_prepare_head($object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->holiday->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/holiday/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -55,9 +55,9 @@ function holiday_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -84,9 +84,14 @@ function holiday_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'holiday_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'holiday_admin');
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'holiday_admin','remove');
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/holiday_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'holiday_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* 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
|
||||
@@ -12,7 +12,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -20,7 +20,6 @@
|
||||
* \ingroup HRM
|
||||
* \brief Library for hrm
|
||||
*/
|
||||
$langs->load('hrm');
|
||||
|
||||
/**
|
||||
* Return head table for establishment tabs screen
|
||||
@@ -32,6 +31,8 @@ function establishment_prepare_head($object)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$langs->load('hrm');
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
@@ -44,14 +45,14 @@ function establishment_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'establishment');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'establishment');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'establishment','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'establishment', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -65,6 +66,8 @@ function hrm_admin_prepare_head()
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
|
||||
$langs->load('hrm');
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
@@ -82,10 +85,9 @@ function hrm_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,'',$head,$h,'hrm_admin');
|
||||
complete_head_from_modules($conf, $langs, '', $head, $h, 'hrm_admin');
|
||||
|
||||
complete_head_from_modules($conf,$langs,'',$head,$h,'hrm_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, '', $head, $h, 'hrm_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -23,8 +23,8 @@
|
||||
*/
|
||||
|
||||
// Define size of logo small and mini
|
||||
$maxwidthsmall=270;$maxheightsmall=150;
|
||||
$maxwidthmini=128;$maxheightmini=72;
|
||||
$maxwidthsmall = 270; $maxheightsmall = 150;
|
||||
$maxwidthmini = 128; $maxheightmini = 72;
|
||||
$quality = 80;
|
||||
|
||||
|
||||
@@ -33,17 +33,18 @@ $quality = 80;
|
||||
* Return if a filename is file name of a supported image format
|
||||
*
|
||||
* @param string $file Filename
|
||||
* @return int -1=Not image filename, 0=Image filename but format not supported by PHP, 1=Image filename with format supported
|
||||
* @return int -1=Not image filename, 0=Image filename but format not supported by PHP, 1=Image filename with format supported by this PHP
|
||||
*/
|
||||
function image_format_supported($file)
|
||||
{
|
||||
$regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php
|
||||
$regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php
|
||||
|
||||
// Case filename is not a format image
|
||||
if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) return -1;
|
||||
$reg = array();
|
||||
if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1;
|
||||
|
||||
// Case filename is a format image but not supported by this PHP
|
||||
$imgfonction='';
|
||||
$imgfonction = '';
|
||||
if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif';
|
||||
if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng';
|
||||
if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg';
|
||||
@@ -51,9 +52,10 @@ function image_format_supported($file)
|
||||
if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp';
|
||||
if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm';
|
||||
if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm';
|
||||
if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available
|
||||
if ($imgfonction)
|
||||
{
|
||||
if (! function_exists($imgfonction))
|
||||
if (!function_exists($imgfonction))
|
||||
{
|
||||
// Fonctions de conversion non presente dans ce PHP
|
||||
return 0;
|
||||
@@ -74,21 +76,21 @@ function image_format_supported($file)
|
||||
*/
|
||||
function dol_getImageSize($file, $url = false)
|
||||
{
|
||||
$ret=array();
|
||||
$ret = array();
|
||||
|
||||
if (image_format_supported($file) < 0) return $ret;
|
||||
|
||||
$filetoread = $file;
|
||||
if (!$url)
|
||||
{
|
||||
$filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image
|
||||
$filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image
|
||||
}
|
||||
|
||||
if ($filetoread)
|
||||
{
|
||||
$infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
|
||||
$ret['width']=$infoImg[0]; // Largeur de l'image
|
||||
$ret['height']=$infoImg[1]; // Hauteur de l'image
|
||||
$ret['width'] = $infoImg[0]; // Largeur de l'image
|
||||
$ret['height'] = $infoImg[1]; // Hauteur de l'image
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@@ -104,35 +106,35 @@ function dol_getImageSize($file, $url = false)
|
||||
* @param int $newHeight Hauteur maximum que dois faire l'image destination (0=keep ratio)
|
||||
* @param int $src_x Position of croping image in source image (not use if mode=0)
|
||||
* @param int $src_y Position of croping image in source image (not use if mode=0)
|
||||
* @return int File name if OK, error message if KO
|
||||
* @return string File name if OK, error message if KO
|
||||
*/
|
||||
function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $src_y=0)
|
||||
function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
global $conf,$langs;
|
||||
global $conf, $langs;
|
||||
|
||||
dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y);
|
||||
|
||||
// Clean parameters
|
||||
$file=trim($file);
|
||||
$file = trim($file);
|
||||
|
||||
// Check parameters
|
||||
if (! $file)
|
||||
if (!$file)
|
||||
{
|
||||
// Si le fichier n'a pas ete indique
|
||||
return 'Bad parameter file';
|
||||
}
|
||||
elseif (! file_exists($file))
|
||||
elseif (!file_exists($file))
|
||||
{
|
||||
// Si le fichier passe en parametre n'existe pas
|
||||
return $langs->trans("ErrorFileNotFound",$file);
|
||||
return $langs->trans("ErrorFileNotFound", $file);
|
||||
}
|
||||
elseif(image_format_supported($file) < 0)
|
||||
elseif (image_format_supported($file) < 0)
|
||||
{
|
||||
return 'This filename '.$file.' does not seem to be an image filename.';
|
||||
}
|
||||
elseif(!is_numeric($newWidth) && !is_numeric($newHeight))
|
||||
elseif (!is_numeric($newWidth) && !is_numeric($newHeight))
|
||||
{
|
||||
return 'Wrong value for parameter newWidth or newHeight';
|
||||
}
|
||||
@@ -145,7 +147,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s
|
||||
return 'Both newHeight or newWidth must be defined for croping';
|
||||
}
|
||||
|
||||
$filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image
|
||||
$filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image
|
||||
|
||||
$infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
|
||||
$imgWidth = $infoImg[0]; // Largeur de l'image
|
||||
@@ -153,18 +155,18 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s
|
||||
|
||||
if ($mode == 0) // If resize, we check parameters
|
||||
{
|
||||
if ($newWidth <= 0)
|
||||
if ($newWidth <= 0)
|
||||
{
|
||||
$newWidth=intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio
|
||||
$newWidth = intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio
|
||||
}
|
||||
if ($newHeight <= 0)
|
||||
{
|
||||
$newHeight=intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio
|
||||
$newHeight = intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio
|
||||
}
|
||||
}
|
||||
|
||||
$imgfonction='';
|
||||
switch($infoImg[2])
|
||||
$imgfonction = '';
|
||||
switch ($infoImg[2])
|
||||
{
|
||||
case 1: // IMG_GIF
|
||||
$imgfonction = 'imagecreatefromgif';
|
||||
@@ -181,7 +183,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s
|
||||
}
|
||||
if ($imgfonction)
|
||||
{
|
||||
if (! function_exists($imgfonction))
|
||||
if (!function_exists($imgfonction))
|
||||
{
|
||||
// Fonctions de conversion non presente dans ce PHP
|
||||
return 'Resize not possible. This PHP does not support GD functions '.$imgfonction;
|
||||
@@ -189,27 +191,27 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s
|
||||
}
|
||||
|
||||
// Initialisation des variables selon l'extension de l'image
|
||||
switch($infoImg[2])
|
||||
switch ($infoImg[2])
|
||||
{
|
||||
case 1: // Gif
|
||||
$img = imagecreatefromgif($filetoread);
|
||||
$extImg = '.gif'; // File name extension of image
|
||||
$newquality='NU'; // Quality is not used for this format
|
||||
$extImg = '.gif'; // File name extension of image
|
||||
$newquality = 'NU'; // Quality is not used for this format
|
||||
break;
|
||||
case 2: // Jpg
|
||||
$img = imagecreatefromjpeg($filetoread);
|
||||
$extImg = '.jpg';
|
||||
$newquality=100; // % quality maximum
|
||||
$newquality = 100; // % quality maximum
|
||||
break;
|
||||
case 3: // Png
|
||||
$img = imagecreatefrompng($filetoread);
|
||||
$extImg = '.png';
|
||||
$newquality=0; // No compression (0-9)
|
||||
$newquality = 0; // No compression (0-9)
|
||||
break;
|
||||
case 4: // Bmp
|
||||
$img = imagecreatefromwbmp($filetoread);
|
||||
$extImg = '.bmp';
|
||||
$newquality='NU'; // Quality is not used for this format
|
||||
$newquality = 'NU'; // Quality is not used for this format
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -237,18 +239,18 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s
|
||||
}
|
||||
|
||||
// Initialisation des variables selon l'extension de l'image
|
||||
switch($infoImg[2])
|
||||
switch ($infoImg[2])
|
||||
{
|
||||
case 1: // Gif
|
||||
$trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF
|
||||
imagecolortransparent($imgThumb,$trans_colour);
|
||||
imagecolortransparent($imgThumb, $trans_colour);
|
||||
break;
|
||||
case 2: // Jpg
|
||||
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
|
||||
break;
|
||||
case 3: // Png
|
||||
imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme
|
||||
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel
|
||||
imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme
|
||||
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel
|
||||
break;
|
||||
case 4: // Bmp
|
||||
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
|
||||
@@ -258,7 +260,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s
|
||||
|
||||
dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality");
|
||||
//imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee
|
||||
imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode==0?$imgWidth:$newWidth), ($mode==0?$imgHeight:$newHeight)); // Insere l'image de base redimensionnee
|
||||
imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode == 0 ? $imgWidth : $newWidth), ($mode == 0 ? $imgHeight : $newHeight)); // Insere l'image de base redimensionnee
|
||||
|
||||
$imgThumbName = $file;
|
||||
|
||||
@@ -267,7 +269,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s
|
||||
//fclose($fp);
|
||||
|
||||
// Create image on disk
|
||||
switch($infoImg[2])
|
||||
switch ($infoImg[2])
|
||||
{
|
||||
case 1: // Gif
|
||||
imagegif($imgThumb, $imgThumbName);
|
||||
@@ -279,18 +281,18 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s
|
||||
imagepng($imgThumb, $imgThumbName, $newquality);
|
||||
break;
|
||||
case 4: // Bmp
|
||||
image2wbmp($imgThumb, $imgThumbName);
|
||||
imagewbmp($imgThumb, $imgThumbName);
|
||||
break;
|
||||
}
|
||||
|
||||
// Set permissions on file
|
||||
if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
|
||||
if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
// Free memory. This does not delete image.
|
||||
imagedestroy($img);
|
||||
imagedestroy($imgThumb);
|
||||
|
||||
clearstatcache(); // File was replaced by a modified one, so we clear file caches.
|
||||
clearstatcache(); // File was replaced by a modified one, so we clear file caches.
|
||||
|
||||
return $imgThumbName;
|
||||
}
|
||||
@@ -306,35 +308,93 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s
|
||||
*/
|
||||
function dolRotateImage($file_path)
|
||||
{
|
||||
$exif = @exif_read_data($file_path);
|
||||
if ($exif === false) {
|
||||
return false;
|
||||
}
|
||||
$orientation = intval(@$exif['Orientation']);
|
||||
if (!in_array($orientation, array(3, 6, 8))) {
|
||||
return false;
|
||||
}
|
||||
$image = @imagecreatefromjpeg($file_path);
|
||||
switch ($orientation) {
|
||||
case 3:
|
||||
$image = @imagerotate($image, 180, 0);
|
||||
break;
|
||||
case 6:
|
||||
$image = @imagerotate($image, 270, 0);
|
||||
break;
|
||||
case 8:
|
||||
$image = @imagerotate($image, 90, 0);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
$success = imagejpeg($image, $file_path);
|
||||
// Free up memory (imagedestroy does not delete files):
|
||||
@imagedestroy($image);
|
||||
return $success;
|
||||
return correctExifImageOrientation($file_path, $file_path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add exif orientation correction for image
|
||||
*
|
||||
* @param string $fileSource Full path to source image to rotate
|
||||
* @param string $fileDest string : Full path to image to rotate | false return gd img | null the raw image stream will be outputted directly
|
||||
* @param int $quality output image quality
|
||||
* @return bool : true on success or false on failure or gd img if $fileDest is false.
|
||||
*/
|
||||
function correctExifImageOrientation($fileSource, $fileDest, $quality = 95)
|
||||
{
|
||||
if (function_exists('exif_read_data')) {
|
||||
$exif = @exif_read_data($fileSource);
|
||||
if ($exif && isset($exif['Orientation'])) {
|
||||
$infoImg = getimagesize($fileSource); // Get image infos
|
||||
|
||||
$orientation = $exif['Orientation'];
|
||||
if($orientation != 1){
|
||||
$img = imagecreatefromjpeg($fileSource);
|
||||
$deg = 0;
|
||||
switch ($orientation) {
|
||||
case 3:
|
||||
$deg = 180;
|
||||
break;
|
||||
case 6:
|
||||
$deg = 270;
|
||||
break;
|
||||
case 8:
|
||||
$deg = 90;
|
||||
break;
|
||||
}
|
||||
if ($deg) {
|
||||
if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case
|
||||
{
|
||||
imagealphablending($img, false);
|
||||
imagesavealpha($img, true);
|
||||
$img = imagerotate($img, $deg, imageColorAllocateAlpha($img, 0, 0, 0, 127));
|
||||
imagealphablending($img, false);
|
||||
imagesavealpha($img, true);
|
||||
}
|
||||
else {
|
||||
$img = imagerotate($img, $deg, 0);
|
||||
}
|
||||
}
|
||||
// then rewrite the rotated image back to the disk as $fileDest
|
||||
if ($fileDest === false) {
|
||||
return $img;
|
||||
}
|
||||
else
|
||||
{
|
||||
// In fact there exif is only for JPG but just in case
|
||||
// Create image on disk
|
||||
$image = false;
|
||||
|
||||
switch ($infoImg[2])
|
||||
{
|
||||
case IMAGETYPE_GIF: // 1
|
||||
$image = imagegif($img, $fileDest);
|
||||
break;
|
||||
case IMAGETYPE_JPEG: // 2
|
||||
$image = imagejpeg($img, $fileDest, $quality);
|
||||
break;
|
||||
case IMAGETYPE_PNG: // 3
|
||||
$image = imagepng($img, $fileDest, $quality);
|
||||
break;
|
||||
case IMAGETYPE_BMP: // 6
|
||||
// Not supported by PHP GD
|
||||
break;
|
||||
case IMAGETYPE_WBMP: // 15
|
||||
$image = imagewbmp($img, $fileDest);
|
||||
break;
|
||||
}
|
||||
|
||||
// Free up memory (imagedestroy does not delete files):
|
||||
@imagedestroy($img);
|
||||
|
||||
return $image;
|
||||
}
|
||||
} // if there is some rotation necessary
|
||||
} // if have the exif orientation info
|
||||
} // if function exists
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a thumbnail from an image file (Supported extensions are gif, jpg, png and bmp).
|
||||
@@ -349,7 +409,7 @@ function dolRotateImage($file_path)
|
||||
* @param int $targetformat New format of target (IMAGETYPE_GIF, IMAGETYPE_JPG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP ... or 0 to keep old format)
|
||||
* @return string Full path of thumb or '' if it fails or 'Error...' if it fails
|
||||
*/
|
||||
function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0)
|
||||
function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $quality = 50, $outdir = 'thumbs', $targetformat = 0)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
@@ -369,22 +429,22 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
elseif (! file_exists($file))
|
||||
{
|
||||
// Si le fichier passe en parametre n'existe pas
|
||||
dol_syslog($langs->trans("ErrorFileNotFound",$file),LOG_ERR);
|
||||
return $langs->trans("ErrorFileNotFound",$file);
|
||||
dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR);
|
||||
return $langs->trans("ErrorFileNotFound", $file);
|
||||
}
|
||||
elseif(image_format_supported($file) < 0)
|
||||
{
|
||||
dol_syslog('This file '.$file.' does not seem to be an image format file name.',LOG_WARNING);
|
||||
dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING);
|
||||
return 'ErrorBadImageFormat';
|
||||
}
|
||||
elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){
|
||||
elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) {
|
||||
// Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
|
||||
dol_syslog('Wrong value for parameter maxWidth',LOG_ERR);
|
||||
dol_syslog('Wrong value for parameter maxWidth', LOG_ERR);
|
||||
return 'Error: Wrong value for parameter maxWidth';
|
||||
}
|
||||
elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){
|
||||
elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) {
|
||||
// Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
|
||||
dol_syslog('Wrong value for parameter maxHeight',LOG_ERR);
|
||||
dol_syslog('Wrong value for parameter maxHeight', LOG_ERR);
|
||||
return 'Error: Wrong value for parameter maxHeight';
|
||||
}
|
||||
|
||||
@@ -394,6 +454,14 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
$imgWidth = $infoImg[0]; // Largeur de l'image
|
||||
$imgHeight = $infoImg[1]; // Hauteur de l'image
|
||||
|
||||
$ort = false;
|
||||
if (function_exists('exif_read_data')) {
|
||||
$exif = @exif_read_data($filetoread);
|
||||
if ($exif && !empty($exif['Orientation'])) {
|
||||
$ort = $exif['Orientation'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged
|
||||
if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged
|
||||
|
||||
@@ -401,12 +469,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
if ($infoImg[0] < $maxWidth && $infoImg[1] < $maxHeight)
|
||||
{
|
||||
// On cree toujours les vignettes
|
||||
dol_syslog("File size is smaller than thumb size",LOG_DEBUG);
|
||||
dol_syslog("File size is smaller than thumb size", LOG_DEBUG);
|
||||
//return 'Le fichier '.$file.' ne necessite pas de creation de vignette';
|
||||
}
|
||||
|
||||
$imgfonction='';
|
||||
switch($infoImg[2])
|
||||
$imgfonction = '';
|
||||
switch ($infoImg[2])
|
||||
{
|
||||
case IMAGETYPE_GIF: // 1
|
||||
$imgfonction = 'imagecreatefromgif';
|
||||
@@ -426,7 +494,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
}
|
||||
if ($imgfonction)
|
||||
{
|
||||
if (! function_exists($imgfonction))
|
||||
if (!function_exists($imgfonction))
|
||||
{
|
||||
// Fonctions de conversion non presente dans ce PHP
|
||||
return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction;
|
||||
@@ -434,12 +502,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
}
|
||||
|
||||
// On cree le repertoire contenant les vignettes
|
||||
$dirthumb = dirname($file).($outdir?'/'.$outdir:''); // Chemin du dossier contenant les vignettes
|
||||
$dirthumb = dirname($file).($outdir ? '/'.$outdir : ''); // Chemin du dossier contenant les vignettes
|
||||
dol_mkdir($dirthumb);
|
||||
|
||||
// Initialisation des variables selon l'extension de l'image
|
||||
$img=null;
|
||||
switch($infoImg[2])
|
||||
$img = null;
|
||||
switch ($infoImg[2])
|
||||
{
|
||||
case IMAGETYPE_GIF: // 1
|
||||
$img = imagecreatefromgif($filetoread);
|
||||
@@ -447,7 +515,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
break;
|
||||
case IMAGETYPE_JPEG: // 2
|
||||
$img = imagecreatefromjpeg($filetoread);
|
||||
$extImg = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg'); // Extension de l'image
|
||||
$extImg = (preg_match('/\.jpeg$/', $file) ? '.jpeg' : '.jpg'); // Extension de l'image
|
||||
break;
|
||||
case IMAGETYPE_PNG: // 3
|
||||
$img = imagecreatefrompng($filetoread);
|
||||
@@ -462,21 +530,68 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
$extImg = '.bmp';
|
||||
break;
|
||||
}
|
||||
|
||||
if (! is_resource($img))
|
||||
{
|
||||
dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Initialisation des dimensions de la vignette si elles sont superieures a l'original
|
||||
if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; }
|
||||
if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; }
|
||||
$exifAngle = false;
|
||||
if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) {
|
||||
switch($ort)
|
||||
{
|
||||
case 3: // 180 rotate left
|
||||
$exifAngle = 180;
|
||||
break;
|
||||
case 6: // 90 rotate right
|
||||
$exifAngle = -90;
|
||||
// changing sizes
|
||||
$trueImgWidth = $infoImg[1];
|
||||
$trueImgHeight = $infoImg[0];
|
||||
break;
|
||||
case 8: // 90 rotate left
|
||||
$exifAngle = 90;
|
||||
// changing sizes
|
||||
$trueImgWidth = $infoImg[1]; // Largeur de l'image
|
||||
$trueImgHeight = $infoImg[0]; // Hauteur de l'image
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$whFact = $maxWidth/$maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette
|
||||
$imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original
|
||||
if ($exifAngle)
|
||||
{
|
||||
$rotated = false;
|
||||
|
||||
if($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case
|
||||
{
|
||||
imagealphablending($img, false);
|
||||
imagesavealpha($img, true);
|
||||
$rotated = imagerotate($img, $exifAngle, imageColorAllocateAlpha($img, 0, 0, 0, 127));
|
||||
imagealphablending($rotated, false);
|
||||
imagesavealpha($rotated, true);
|
||||
}
|
||||
else {
|
||||
$rotated = imagerotate($img, $exifAngle, 0);
|
||||
}
|
||||
|
||||
// replace image with good orientation
|
||||
if (!empty($rotated)) {
|
||||
$img = $rotated;
|
||||
$imgWidth = $trueImgWidth;
|
||||
$imgHeight = $trueImgHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialisation des dimensions de la vignette si elles sont superieures a l'original
|
||||
if ($maxWidth > $imgWidth) { $maxWidth = $imgWidth; }
|
||||
if ($maxHeight > $imgHeight) { $maxHeight = $imgHeight; }
|
||||
|
||||
$whFact = $maxWidth / $maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette
|
||||
$imgWhFact = $imgWidth / $imgHeight; // Facteur largeur/hauteur de l'original
|
||||
|
||||
// Fixe les dimensions de la vignette
|
||||
if($whFact < $imgWhFact)
|
||||
if ($whFact < $imgWhFact)
|
||||
{
|
||||
// Si largeur determinante
|
||||
$thumbWidth = $maxWidth;
|
||||
@@ -488,11 +603,11 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
$thumbHeight = $maxHeight;
|
||||
$thumbWidth = $thumbHeight * $imgWhFact;
|
||||
}
|
||||
$thumbHeight=round($thumbHeight);
|
||||
$thumbWidth=round($thumbWidth);
|
||||
$thumbHeight = round($thumbHeight);
|
||||
$thumbWidth = round($thumbWidth);
|
||||
|
||||
// Define target format
|
||||
if (empty($targetformat)) $targetformat=$infoImg[2];
|
||||
if (empty($targetformat)) $targetformat = $infoImg[2];
|
||||
|
||||
// Create empty image
|
||||
if ($targetformat == IMAGETYPE_GIF)
|
||||
@@ -519,35 +634,35 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
|
||||
// Initialisation des variables selon l'extension de l'image
|
||||
// $targetformat is 0 by default, in such case, we keep original extension
|
||||
switch($targetformat)
|
||||
switch ($targetformat)
|
||||
{
|
||||
case IMAGETYPE_GIF: // 1
|
||||
$trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF
|
||||
imagecolortransparent($imgThumb,$trans_colour);
|
||||
imagecolortransparent($imgThumb, $trans_colour);
|
||||
$extImgTarget = '.gif';
|
||||
$newquality='NU';
|
||||
$newquality = 'NU';
|
||||
break;
|
||||
case IMAGETYPE_JPEG: // 2
|
||||
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
|
||||
$extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':'.jpg');
|
||||
$newquality=$quality;
|
||||
$extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg');
|
||||
$newquality = $quality;
|
||||
break;
|
||||
case IMAGETYPE_PNG: // 3
|
||||
imagealphablending($imgThumb,false); // Pour compatibilite sur certain systeme
|
||||
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel
|
||||
imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme
|
||||
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel
|
||||
$extImgTarget = '.png';
|
||||
$newquality=$quality-100;
|
||||
$newquality=round(abs($quality-100)*9/100);
|
||||
$newquality = $quality - 100;
|
||||
$newquality = round(abs($quality - 100) * 9 / 100);
|
||||
break;
|
||||
case IMAGETYPE_BMP: // 6
|
||||
// Not supported by PHP GD
|
||||
$extImgTarget = '.bmp';
|
||||
$newquality='NU';
|
||||
$newquality = 'NU';
|
||||
break;
|
||||
case IMAGETYPE_WBMP: // 15
|
||||
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
|
||||
$extImgTarget = '.bmp';
|
||||
$newquality='NU';
|
||||
$newquality = 'NU';
|
||||
break;
|
||||
}
|
||||
if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour);
|
||||
@@ -556,10 +671,10 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
//imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee
|
||||
imagecopyresampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee
|
||||
|
||||
$fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse
|
||||
$fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // On enleve extension quelquesoit la casse
|
||||
$fileName = basename($fileName);
|
||||
//$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file
|
||||
$imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file
|
||||
$imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file
|
||||
|
||||
|
||||
// Check if permission are ok
|
||||
@@ -567,7 +682,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
//fclose($fp);
|
||||
|
||||
// Create image on disk
|
||||
switch($targetformat)
|
||||
switch ($targetformat)
|
||||
{
|
||||
case IMAGETYPE_GIF: // 1
|
||||
imagegif($imgThumb, $imgThumbName);
|
||||
@@ -582,12 +697,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
|
||||
// Not supported by PHP GD
|
||||
break;
|
||||
case IMAGETYPE_WBMP: // 15
|
||||
image2wbmp($imgThumb, $imgThumbName);
|
||||
imagewbmp($imgThumb, $imgThumbName);
|
||||
break;
|
||||
}
|
||||
|
||||
// Set permissions on file
|
||||
if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
|
||||
if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
// Free memory. This does not delete image.
|
||||
imagedestroy($img);
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@
|
||||
* @param int $maxstep Limit steps to maxstep or no limit if 0
|
||||
* @return array Array of tabs
|
||||
*/
|
||||
function import_prepare_head($param, $maxstep=0)
|
||||
function import_prepare_head($param, $maxstep = 0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
@@ -52,4 +52,3 @@ function import_prepare_head($param, $maxstep=0)
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -47,10 +47,10 @@ function facture_prepare_head($object)
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ function facture_prepare_head($object)
|
||||
else dol_print_error($db);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('StandingOrders');
|
||||
if ($nbStandingOrders > 0) $head[$h][1].= ' <span class="badge">'.$nbStandingOrders.'</span>';
|
||||
if ($nbStandingOrders > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbStandingOrders.'</span>';
|
||||
$head[$h][2] = 'standingorders';
|
||||
$h++;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ function facture_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'invoice');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
@@ -89,7 +89,7 @@ function facture_prepare_head($object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
@@ -97,11 +97,11 @@ function facture_prepare_head($object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -110,7 +110,7 @@ function facture_prepare_head($object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'invoice', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -137,11 +137,18 @@ function invoice_admin_prepare_head()
|
||||
$head[$h][2] = 'payment';
|
||||
$h++;
|
||||
|
||||
if ($conf->global->INVOICE_USE_SITUATION) {
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php';
|
||||
$head[$h][1] = $langs->trans("InvoiceSituation");
|
||||
$head[$h][2] = 'situation';
|
||||
$h++;
|
||||
}
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'invoice_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/admin/facture_cust_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsCustomerInvoices");
|
||||
@@ -163,7 +170,7 @@ function invoice_admin_prepare_head()
|
||||
$head[$h][2] = 'attributeslinesrec';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'invoice_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'invoice_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -182,7 +189,7 @@ function invoice_rec_prepare_head($object)
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/fiche-rec.php?id='.$object->id;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/card-rec.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("CardBill");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
@@ -191,9 +198,9 @@ function invoice_rec_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice-rec');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'invoice-rec');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'invoice-rec','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'invoice-rec', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2009-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
/* Copyright (C) 2009-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@@ -13,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -36,10 +35,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
||||
* @param string $diroutputpdf Dir to output file
|
||||
* @param string $newlangid Lang id
|
||||
* @param array $filter Array with filters
|
||||
* @param date $dateafterdate Invoice after date
|
||||
* @param date $datebeforedate Invoice before date
|
||||
* @param date $paymentdateafter Payment after date (must includes hour)
|
||||
* @param date $paymentdatebefore Payment before date (must includes hour)
|
||||
* @param integer $dateafterdate Invoice after date
|
||||
* @param integer $datebeforedate Invoice before date
|
||||
* @param integer $paymentdateafter Payment after date (must includes hour)
|
||||
* @param integer $paymentdatebefore Payment before date (must includes hour)
|
||||
* @param int $usestdout Add information onto standard output
|
||||
* @param int $regenerate ''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template
|
||||
* @param string $filesuffix Suffix to add into file name of generated PDF
|
||||
@@ -48,17 +47,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
||||
* @param string $fileprefix Prefix to add into filename of generated PDF
|
||||
* @return int Error code
|
||||
*/
|
||||
function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate=0, $filesuffix='', $paymentbankid='', $thirdpartiesid='', $fileprefix='mergedpdf')
|
||||
function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate = 0, $filesuffix = '', $paymentbankid = '', $thirdpartiesid = '', $fileprefix = 'mergedpdf')
|
||||
{
|
||||
$sql = "SELECT DISTINCT f.rowid, f.facnumber";
|
||||
$sql = "SELECT DISTINCT f.rowid, f.ref";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sqlwhere='';
|
||||
$sqlorder='';
|
||||
if (in_array('all',$filter))
|
||||
if (in_array('all', $filter))
|
||||
{
|
||||
$sqlorder = " ORDER BY f.facnumber ASC";
|
||||
$sqlorder = " ORDER BY f.ref ASC";
|
||||
}
|
||||
if (in_array('date',$filter))
|
||||
if (in_array('date', $filter))
|
||||
{
|
||||
if (empty($sqlwhere)) $sqlwhere=' WHERE ';
|
||||
else $sqlwhere.=" AND";
|
||||
@@ -67,7 +66,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
|
||||
$sqlwhere.= " AND f.datef <= '".$db->idate($datebeforedate)."'";
|
||||
$sqlorder = " ORDER BY f.datef ASC";
|
||||
}
|
||||
if (in_array('nopayment',$filter))
|
||||
if (in_array('nopayment', $filter))
|
||||
{
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
|
||||
if (empty($sqlwhere)) $sqlwhere=' WHERE ';
|
||||
@@ -75,56 +74,56 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
|
||||
$sqlwhere.= " f.fk_statut > 0";
|
||||
$sqlwhere.= " AND pf.fk_paiement IS NULL";
|
||||
}
|
||||
if (in_array('payments',$filter) || in_array('bank',$filter))
|
||||
if (in_array('payments', $filter) || in_array('bank', $filter))
|
||||
{
|
||||
$sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
|
||||
if (in_array('bank',$filter)) $sql.= ", ".MAIN_DB_PREFIX."bank as b";
|
||||
if (in_array('bank', $filter)) $sql.= ", ".MAIN_DB_PREFIX."bank as b";
|
||||
if (empty($sqlwhere)) $sqlwhere=' WHERE ';
|
||||
else $sqlwhere.=" AND";
|
||||
$sqlwhere.= " f.fk_statut > 0";
|
||||
$sqlwhere.= " AND f.rowid = pf.fk_facture";
|
||||
$sqlwhere.= " AND pf.fk_paiement = p.rowid";
|
||||
if (in_array('payments',$filter))
|
||||
if (in_array('payments', $filter))
|
||||
{
|
||||
$sqlwhere.= " AND p.datep >= '".$db->idate($paymentdateafter)."'";
|
||||
$sqlwhere.= " AND p.datep <= '".$db->idate($paymentdatebefore)."'";
|
||||
}
|
||||
if (in_array('bank',$filter))
|
||||
if (in_array('bank', $filter))
|
||||
{
|
||||
$sqlwhere.= " AND p.fk_bank = b.rowid";
|
||||
$sqlwhere.= " AND b.fk_account = ".$paymentbankid;
|
||||
}
|
||||
$sqlorder = " ORDER BY p.datep ASC";
|
||||
}
|
||||
if (in_array('nodeposit',$filter))
|
||||
if (in_array('nodeposit', $filter))
|
||||
{
|
||||
if (empty($sqlwhere)) $sqlwhere=' WHERE ';
|
||||
else $sqlwhere.=" AND";
|
||||
$sqlwhere.=' type <> 3';
|
||||
}
|
||||
if (in_array('noreplacement',$filter))
|
||||
if (in_array('noreplacement', $filter))
|
||||
{
|
||||
if (empty($sqlwhere)) $sqlwhere=' WHERE ';
|
||||
else $sqlwhere.=" AND";
|
||||
$sqlwhere.=' type <> 1';
|
||||
}
|
||||
if (in_array('nocreditnote',$filter))
|
||||
if (in_array('nocreditnote', $filter))
|
||||
{
|
||||
if (empty($sqlwhere)) $sqlwhere=' WHERE ';
|
||||
else $sqlwhere.=" AND";
|
||||
$sqlwhere.=' type <> 2';
|
||||
}
|
||||
if (in_array('excludethirdparties',$filter) && is_array($thirdpartiesid))
|
||||
if (in_array('excludethirdparties', $filter) && is_array($thirdpartiesid))
|
||||
{
|
||||
if (empty($sqlwhere)) $sqlwhere=' WHERE ';
|
||||
else $sqlwhere.=" AND";
|
||||
$sqlwhere.=' f.fk_soc NOT IN ('.join(',',$thirdpartiesid).')';
|
||||
$sqlwhere.=' f.fk_soc NOT IN ('.join(',', $thirdpartiesid).')';
|
||||
}
|
||||
if (in_array('onlythirdparties',$filter) && is_array($thirdpartiesid))
|
||||
if (in_array('onlythirdparties', $filter) && is_array($thirdpartiesid))
|
||||
{
|
||||
if (empty($sqlwhere)) $sqlwhere=' WHERE ';
|
||||
else $sqlwhere.=" AND";
|
||||
$sqlwhere.=' f.fk_soc IN ('.join(',',$thirdpartiesid).')';
|
||||
$sqlwhere.=' f.fk_soc IN ('.join(',', $thirdpartiesid).')';
|
||||
}
|
||||
if ($sqlwhere) $sql.=$sqlwhere;
|
||||
if ($sqlorder) $sql.=$sqlorder;
|
||||
@@ -168,18 +167,18 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
|
||||
{
|
||||
if ($outputlangs->defaultlang != $newlangid)
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlangid);
|
||||
}
|
||||
}
|
||||
$filename=$conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf';
|
||||
if ($regenerate || ! dol_is_file($filename))
|
||||
{
|
||||
if ($usestdout) print "Build PDF for invoice ".$obj->facnumber." - Lang = ".$outputlangs->defaultlang."\n";
|
||||
if ($usestdout) print "Build PDF for invoice ".$obj->ref." - Lang = ".$outputlangs->defaultlang."\n";
|
||||
$result= $fac->generateDocument($regenerate?$regenerate:$fac->modelpdf, $outputlangs);
|
||||
}
|
||||
else {
|
||||
if ($usestdout) print "PDF for invoice ".$obj->facnumber." already exists\n";
|
||||
if ($usestdout) print "PDF for invoice ".$obj->ref." already exists\n";
|
||||
}
|
||||
|
||||
// Add file into files array
|
||||
@@ -203,8 +202,8 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
|
||||
$page_hauteur = $formatarray['height'];
|
||||
$format = array($page_largeur,$page_hauteur);
|
||||
|
||||
if ($usestdout) print "Using output PDF format ".join('x',$format)."\n";
|
||||
else dol_syslog("Using output PDF format ".join('x',$format), LOG_ERR);
|
||||
if ($usestdout) print "Using output PDF format ".join('x', $format)."\n";
|
||||
else dol_syslog("Using output PDF format ".join('x', $format), LOG_ERR);
|
||||
|
||||
|
||||
// Now, build a merged files with all files in $files array
|
||||
@@ -250,7 +249,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
|
||||
|
||||
if (! $error && $pagecount)
|
||||
{
|
||||
$pdf->Output($file,'F');
|
||||
$pdf->Output($file, 'F');
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
@@ -280,4 +279,3 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
|
||||
if ($error) return -1;
|
||||
else return $result;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -118,8 +118,7 @@ function _val($val)
|
||||
* escaping with a slash or encoding to UTF-8 where necessary
|
||||
*/
|
||||
for ($c = 0; $c < $strlen_var; ++$c) {
|
||||
|
||||
$ord_var_c = ord($val{$c});
|
||||
$ord_var_c = ord($val[$c]);
|
||||
|
||||
switch (true) {
|
||||
case $ord_var_c == 0x08:
|
||||
@@ -142,18 +141,18 @@ function _val($val)
|
||||
case $ord_var_c == 0x2F:
|
||||
case $ord_var_c == 0x5C:
|
||||
// double quote, slash, slosh
|
||||
$ascii .= '\\'.$val{$c};
|
||||
$ascii .= '\\'.$val[$c];
|
||||
break;
|
||||
|
||||
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
|
||||
// characters U-00000000 - U-0000007F (same as ASCII)
|
||||
$ascii .= $val{$c};
|
||||
$ascii .= $val[$c];
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xE0) == 0xC0):
|
||||
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c, ord($val{$c + 1}));
|
||||
$char = pack('C*', $ord_var_c, ord($val[$c + 1]));
|
||||
$c += 1;
|
||||
$utf16 = utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
@@ -162,7 +161,7 @@ function _val($val)
|
||||
case (($ord_var_c & 0xF0) == 0xE0):
|
||||
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}));
|
||||
$char = pack('C*', $ord_var_c, ord($val[$c + 1]), ord($val[$c + 2]));
|
||||
$c += 2;
|
||||
$utf16 = utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
@@ -171,7 +170,7 @@ function _val($val)
|
||||
case (($ord_var_c & 0xF8) == 0xF0):
|
||||
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3}));
|
||||
$char = pack('C*', $ord_var_c, ord($val[$c + 1]), ord($val[$c + 2]), ord($val[$c + 3]));
|
||||
$c += 3;
|
||||
$utf16 = utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
@@ -180,7 +179,7 @@ function _val($val)
|
||||
case (($ord_var_c & 0xFC) == 0xF8):
|
||||
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3}), ord($val{$c + 4}));
|
||||
$char = pack('C*', $ord_var_c, ord($val[$c + 1]), ord($val[$c + 2]), ord($val[$c + 3]), ord($val[$c + 4]));
|
||||
$c += 4;
|
||||
$utf16 = utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
@@ -189,7 +188,7 @@ function _val($val)
|
||||
case (($ord_var_c & 0xFE) == 0xFC):
|
||||
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3}), ord($val{$c + 4}), ord($val{$c + 5}));
|
||||
$char = pack('C*', $ord_var_c, ord($val[$c + 1]), ord($val[$c + 2]), ord($val[$c + 3]), ord($val[$c + 4]), ord($val[$c + 5]));
|
||||
$c += 5;
|
||||
$utf16 = utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
@@ -214,7 +213,7 @@ if (! function_exists('json_decode'))
|
||||
* @param bool $assoc False return an object, true return an array
|
||||
* @return mixed Object or Array
|
||||
*/
|
||||
function json_decode($json, $assoc=false)
|
||||
function json_decode($json, $assoc = false)
|
||||
{
|
||||
return dol_json_decode($json, $assoc);
|
||||
}
|
||||
@@ -229,7 +228,7 @@ if (! function_exists('json_decode'))
|
||||
* @return mixed Object or Array or false on error
|
||||
* @see json_decode()
|
||||
*/
|
||||
function dol_json_decode($json, $assoc=false)
|
||||
function dol_json_decode($json, $assoc = false)
|
||||
{
|
||||
dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING);
|
||||
|
||||
@@ -242,8 +241,8 @@ function dol_json_decode($json, $assoc=false)
|
||||
if (! $comment)
|
||||
{
|
||||
if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array(';
|
||||
else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')';
|
||||
else if ($json[$i] == ':') $out.= ' => ';
|
||||
elseif (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')';
|
||||
elseif ($json[$i] == ':') $out.= ' => ';
|
||||
else $out.=$json[$i];
|
||||
}
|
||||
else $out.= $json[$i];
|
||||
@@ -282,8 +281,8 @@ function dol_json_decode($json, $assoc=false)
|
||||
/**
|
||||
* Return text according to type
|
||||
*
|
||||
* @param string $val Value to decode
|
||||
* @return string Formated value
|
||||
* @param string $val Value to decode
|
||||
* @return string Formated value
|
||||
*/
|
||||
function _unval($val)
|
||||
{
|
||||
@@ -292,7 +291,7 @@ function _unval($val)
|
||||
// single, escaped unicode character
|
||||
$utf16 = chr(hexdec($reg[1])) . chr(hexdec($reg[2]));
|
||||
$utf8 = utf162utf8($utf16);
|
||||
$val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i',$utf8,$val);
|
||||
$val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i', $utf8, $val);
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
@@ -310,7 +309,7 @@ function _unval($val)
|
||||
function utf162utf8($utf16)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if(function_exists('mb_convert_encoding')) {
|
||||
if (function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
|
||||
}
|
||||
|
||||
@@ -318,19 +317,19 @@ function utf162utf8($utf16)
|
||||
|
||||
switch(true) {
|
||||
case ((0x7F & $bytes) == $bytes):
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr($bytes);
|
||||
|
||||
case (0x07FF & $bytes) == $bytes:
|
||||
// return a 2-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
// return a 2-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0xC0 | (($bytes >> 6) & 0x1F))
|
||||
. chr(0x80 | ($bytes & 0x3F));
|
||||
|
||||
case (0xFFFF & $bytes) == $bytes:
|
||||
// return a 3-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
// return a 3-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0xE0 | (($bytes >> 12) & 0x0F))
|
||||
. chr(0x80 | (($bytes >> 6) & 0x3F))
|
||||
. chr(0x80 | ($bytes & 0x3F));
|
||||
@@ -354,24 +353,24 @@ function utf82utf16($utf8)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if(function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
|
||||
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
|
||||
}
|
||||
|
||||
switch(strlen($utf8)) {
|
||||
case 1:
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return $utf8;
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return $utf8;
|
||||
|
||||
case 2:
|
||||
// return a UTF-16 character from a 2-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0x07 & (ord($utf8{0}) >> 2)) . chr((0xC0 & (ord($utf8{0}) << 6)) | (0x3F & ord($utf8{1})));
|
||||
// return a UTF-16 character from a 2-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0x07 & (ord($utf8{0}) >> 2)) . chr((0xC0 & (ord($utf8{0}) << 6)) | (0x3F & ord($utf8{1})));
|
||||
|
||||
case 3:
|
||||
// return a UTF-16 character from a 3-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr((0xF0 & (ord($utf8{0}) << 4)) | (0x0F & (ord($utf8{1}) >> 2))) . chr((0xC0 & (ord($utf8{1}) << 6)) | (0x7F & ord($utf8{2})));
|
||||
// return a UTF-16 character from a 3-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr((0xF0 & (ord($utf8{0}) << 4)) | (0x0F & (ord($utf8{1}) >> 2))) . chr((0xC0 & (ord($utf8{1}) << 6)) | (0x7F & ord($utf8{2})));
|
||||
}
|
||||
|
||||
// ignoring UTF-32 for now, sorry
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ function ldap_prepare_head()
|
||||
$langs->load("ldap");
|
||||
|
||||
// Onglets
|
||||
$head=array();
|
||||
$head = array();
|
||||
$h = 0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/ldap.php";
|
||||
@@ -43,7 +43,7 @@ function ldap_prepare_head()
|
||||
$head[$h][2] = 'ldap';
|
||||
$h++;
|
||||
|
||||
if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE))
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_users.php";
|
||||
$head[$h][1] = $langs->trans("LDAPUsersSynchro");
|
||||
@@ -51,7 +51,7 @@ function ldap_prepare_head()
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE))
|
||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_groups.php";
|
||||
$head[$h][1] = $langs->trans("LDAPGroupsSynchro");
|
||||
@@ -59,7 +59,7 @@ function ldap_prepare_head()
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (! empty($conf->societe->enabled) && ! empty($conf->global->LDAP_CONTACT_ACTIVE))
|
||||
if (!empty($conf->societe->enabled) && !empty($conf->global->LDAP_CONTACT_ACTIVE))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_contacts.php";
|
||||
$head[$h][1] = $langs->trans("LDAPContactsSynchro");
|
||||
@@ -67,7 +67,7 @@ function ldap_prepare_head()
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (! empty($conf->adherent->enabled) && ! empty($conf->global->LDAP_MEMBER_ACTIVE))
|
||||
if (!empty($conf->adherent->enabled) && !empty($conf->global->LDAP_MEMBER_ACTIVE))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_members.php";
|
||||
$head[$h][1] = $langs->trans("LDAPMembersSynchro");
|
||||
@@ -75,7 +75,7 @@ function ldap_prepare_head()
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (! empty($conf->adherent->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
|
||||
if (!empty($conf->adherent->enabled) && !empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_members_types.php";
|
||||
$head[$h][1] = $langs->trans("LDAPMembersTypesSynchro");
|
||||
@@ -87,7 +87,7 @@ function ldap_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,'',$head,$h,'ldap');
|
||||
complete_head_from_modules($conf, $langs, '', $head, $h, 'ldap');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -103,28 +103,28 @@ function ldap_prepare_head()
|
||||
* @param string $objectclass Class
|
||||
* @return void
|
||||
*/
|
||||
function show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass)
|
||||
function show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass)
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
//print 'key='.$key.' dn='.$dn.' objectclass='.$objectclass;
|
||||
|
||||
print '<br>';
|
||||
if (! function_exists("ldap_connect"))
|
||||
if (!function_exists("ldap_connect"))
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.$langs->trans('LDAPFunctionsNotAvailableOnPHP').'">'.$butlabel.'</a>';
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('LDAPFunctionsNotAvailableOnPHP').'">'.$butlabel.'</a>';
|
||||
}
|
||||
else if (empty($conf->global->LDAP_SERVER_HOST))
|
||||
elseif (empty($conf->global->LDAP_SERVER_HOST))
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.$langs->trans('LDAPSetupNotComplete').'">'.$butlabel.'</a>';
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('LDAPSetupNotComplete').'">'.$butlabel.'</a>';
|
||||
}
|
||||
else if (empty($key) || empty($dn) || empty($objectclass))
|
||||
elseif (empty($key) || empty($dn) || empty($objectclass))
|
||||
{
|
||||
$langs->load("errors");
|
||||
print '<a class="butActionRefused" href="#" title="'.$langs->trans('ErrorLDAPSetupNotComplete').'">'.$butlabel.'</a>';
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans('ErrorLDAPSetupNotComplete').'">'.$butlabel.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action='.$testlabel.'">'.$butlabel.'</a>';
|
||||
print '<a class="butAction reposition" href="'.$_SERVER["PHP_SELF"].'?action='.$testlabel.'">'.$butlabel.'</a>';
|
||||
}
|
||||
print '<br><br>';
|
||||
}
|
||||
@@ -141,42 +141,41 @@ function show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass)
|
||||
* @param int $subcount Subcount
|
||||
* @return int
|
||||
*/
|
||||
function show_ldap_content($result,$level,$count,$var,$hide=0,$subcount=0)
|
||||
function show_ldap_content($result, $level, $count, $var, $hide = 0, $subcount = 0)
|
||||
{
|
||||
global $bc, $conf;
|
||||
|
||||
$count--;
|
||||
if ($count == 0) return -1; // To stop loop
|
||||
if (! is_array($result)) return -1;
|
||||
if ($count == 0) return -1; // To stop loop
|
||||
if (!is_array($result)) return -1;
|
||||
|
||||
foreach($result as $key => $val)
|
||||
foreach ($result as $key => $val)
|
||||
{
|
||||
if ("$key" == "objectclass") continue;
|
||||
if ("$key" == "count") continue;
|
||||
if ("$key" == "dn") continue;
|
||||
if ("$val" == "objectclass") continue;
|
||||
|
||||
$lastkey[$level]=$key;
|
||||
$lastkey[$level] = $key;
|
||||
|
||||
if (is_array($val))
|
||||
{
|
||||
$hide=0;
|
||||
if (! is_numeric($key))
|
||||
$hide = 0;
|
||||
if (!is_numeric($key))
|
||||
{
|
||||
|
||||
print '<tr '.$bc[$var].' valign="top">';
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
print $key;
|
||||
print '</td><td>';
|
||||
if (strtolower($key) == 'userpassword') $hide=1;
|
||||
if (strtolower($key) == 'userpassword') $hide = 1;
|
||||
}
|
||||
show_ldap_content($val,$level+1,$count,$var,$hide,$val["count"]);
|
||||
show_ldap_content($val, $level + 1, $count, $var, $hide, $val["count"]);
|
||||
}
|
||||
else if ($subcount)
|
||||
elseif ($subcount)
|
||||
{
|
||||
$subcount--;
|
||||
$newstring=dol_htmlentitiesbr($val);
|
||||
if ($hide) print preg_replace('/./i','*',$newstring);
|
||||
$newstring = dol_htmlentitiesbr($val);
|
||||
if ($hide) print preg_replace('/./i', '*', $newstring);
|
||||
else print $newstring;
|
||||
print '<br>';
|
||||
}
|
||||
@@ -184,4 +183,3 @@ function show_ldap_content($result,$level,$count,$var,$hide=0,$subcount=0)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -13,7 +13,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -41,20 +41,25 @@ function loan_prepare_head($object)
|
||||
$head[$tab][2] = 'card';
|
||||
$tab++;
|
||||
|
||||
$head[$tab][0] = DOL_URL_ROOT.'/loan/schedule.php?loanid='.$object->id;
|
||||
$head[$tab][1] = $langs->trans('FinancialCommitment');
|
||||
$head[$tab][2] = 'FinancialCommitment';
|
||||
$tab++;
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $tab,'loan');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan');
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$tab][0] = DOL_URL_ROOT.'/loan/document.php?id='.$object->id;
|
||||
$head[$tab][1] = $langs->trans("Documents");
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$tab][2] = 'documents';
|
||||
$tab++;
|
||||
|
||||
@@ -63,7 +68,7 @@ function loan_prepare_head($object)
|
||||
$nbNote = (empty($object->note_private)?0:1)+(empty($object->note_public)?0:1);
|
||||
$head[$tab][0] = DOL_URL_ROOT."/loan/note.php?id=".$object->id;
|
||||
$head[$tab][1] = $langs->trans("Notes");
|
||||
if($nbNote > 0) $head[$tab][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if($nbNote > 0) $head[$tab][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$tab][2] = 'note';
|
||||
$tab++;
|
||||
}
|
||||
@@ -73,7 +78,7 @@ function loan_prepare_head($object)
|
||||
$head[$tab][2] = 'info';
|
||||
$tab++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$tab,'loan','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -43,4 +43,3 @@ function mailmanspip_admin_prepare_head()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||
*
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ function member_prepare_head(Adherent $object)
|
||||
$head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Subscriptions");
|
||||
$head[$h][2] = 'subscription';
|
||||
if ($nbSubscription > 0) $head[$h][1].= ' <span class="badge">'.$nbSubscription.'</span>';
|
||||
if ($nbSubscription > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbSubscription.'</span>';
|
||||
$h++;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ function member_prepare_head(Adherent $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'member');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'member');
|
||||
|
||||
$nbNote = 0;
|
||||
if(!empty($object->note)) $nbNote++;
|
||||
@@ -76,18 +76,18 @@ function member_prepare_head(Adherent $object)
|
||||
$head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Note");
|
||||
$head[$h][2] = 'note';
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$h++;
|
||||
|
||||
// Attachments
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0,0,0,1,$object,'member');
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member');
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'document';
|
||||
$h++;
|
||||
|
||||
@@ -105,7 +105,7 @@ function member_prepare_head(Adherent $object)
|
||||
$h++;
|
||||
}
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'member','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -128,6 +128,15 @@ function member_type_prepare_head(AdherentType $object)
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
// Multilangs
|
||||
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/adherents/type_translation.php?rowid=".$object->id;
|
||||
$head[$h][1] = $langs->trans("Translation");
|
||||
$head[$h][2] = 'translation';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE))
|
||||
&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
|
||||
{
|
||||
@@ -143,9 +152,9 @@ function member_type_prepare_head(AdherentType $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'membertype','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -176,7 +185,7 @@ function member_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,'',$head,$h,'member_admin');
|
||||
complete_head_from_modules($conf, $langs, '', $head, $h, 'member_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsMember");
|
||||
@@ -193,7 +202,7 @@ function member_admin_prepare_head()
|
||||
$head[$h][2] = 'website';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,'',$head,$h,'member_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, '', $head, $h, 'member_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -246,9 +255,9 @@ function member_stats_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'member_stats','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -280,9 +289,9 @@ function subscription_prepare_head(Subscription $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'subscription');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'subscription','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'subscription', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ $shmoffset=1000; // Max number of entries found into a language file. If too low
|
||||
* @param string $data Data to save
|
||||
* @return int <0 if KO, Nb of bytes written if OK
|
||||
*/
|
||||
function dol_setcache($memoryid,$data)
|
||||
function dol_setcache($memoryid, $data)
|
||||
{
|
||||
global $conf;
|
||||
$result=0;
|
||||
@@ -51,14 +51,14 @@ function dol_setcache($memoryid,$data)
|
||||
if (empty($dolmemcache) || ! is_object($dolmemcache))
|
||||
{
|
||||
$dolmemcache=new Memcached();
|
||||
$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
|
||||
$tmparray=explode(':', $conf->global->MEMCACHED_SERVER);
|
||||
$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
|
||||
if (! $result) return -1;
|
||||
}
|
||||
|
||||
|
||||
$memoryid=session_name().'_'.$memoryid;
|
||||
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
|
||||
$dolmemcache->add($memoryid,$data); // This fails if key already exists
|
||||
$dolmemcache->add($memoryid, $data); // This fails if key already exists
|
||||
$rescode=$dolmemcache->getResultCode();
|
||||
if ($rescode == 0)
|
||||
{
|
||||
@@ -69,20 +69,20 @@ function dol_setcache($memoryid,$data)
|
||||
return -$rescode;
|
||||
}
|
||||
}
|
||||
else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
|
||||
elseif (! empty($conf->memcached->enabled) && class_exists('Memcache'))
|
||||
{
|
||||
global $dolmemcache;
|
||||
if (empty($dolmemcache) || ! is_object($dolmemcache))
|
||||
{
|
||||
$dolmemcache=new Memcache();
|
||||
$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
|
||||
$tmparray=explode(':', $conf->global->MEMCACHED_SERVER);
|
||||
$result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
|
||||
if (! $result) return -1;
|
||||
}
|
||||
|
||||
|
||||
$memoryid=session_name().'_'.$memoryid;
|
||||
//$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false);
|
||||
$result=$dolmemcache->add($memoryid,$data); // This fails if key already exists
|
||||
$result=$dolmemcache->add($memoryid, $data); // This fails if key already exists
|
||||
if ($result)
|
||||
{
|
||||
return count($data);
|
||||
@@ -93,9 +93,9 @@ function dol_setcache($memoryid,$data)
|
||||
}
|
||||
}
|
||||
// Using shmop
|
||||
else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
|
||||
elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
|
||||
{
|
||||
$result=dol_setshmop($memoryid,$data);
|
||||
$result=dol_setshmop($memoryid, $data);
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -118,11 +118,11 @@ function dol_getcache($memoryid)
|
||||
if (empty($m) || ! is_object($m))
|
||||
{
|
||||
$m=new Memcached();
|
||||
$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
|
||||
$tmparray=explode(':', $conf->global->MEMCACHED_SERVER);
|
||||
$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
|
||||
if (! $result) return -1;
|
||||
}
|
||||
|
||||
|
||||
$memoryid=session_name().'_'.$memoryid;
|
||||
//$m->setOption(Memcached::OPT_COMPRESSION, false);
|
||||
//print "Get memoryid=".$memoryid;
|
||||
@@ -139,17 +139,17 @@ function dol_getcache($memoryid)
|
||||
return -$rescode;
|
||||
}
|
||||
}
|
||||
else if (! empty($conf->memcached->enabled) && class_exists('Memcache'))
|
||||
elseif (! empty($conf->memcached->enabled) && class_exists('Memcache'))
|
||||
{
|
||||
global $m;
|
||||
if (empty($m) || ! is_object($m))
|
||||
{
|
||||
$m=new Memcache();
|
||||
$tmparray=explode(':',$conf->global->MEMCACHED_SERVER);
|
||||
$tmparray=explode(':', $conf->global->MEMCACHED_SERVER);
|
||||
$result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211);
|
||||
if (! $result) return -1;
|
||||
}
|
||||
|
||||
|
||||
$memoryid=session_name().'_'.$memoryid;
|
||||
//$m->setOption(Memcached::OPT_COMPRESSION, false);
|
||||
$data=$m->get($memoryid);
|
||||
@@ -165,7 +165,7 @@ function dol_getcache($memoryid)
|
||||
}
|
||||
}
|
||||
// Using shmop
|
||||
else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
|
||||
elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
|
||||
{
|
||||
$data=dol_getshmop($memoryid);
|
||||
return $data;
|
||||
@@ -214,7 +214,7 @@ function dol_listshmop()
|
||||
* @param string $data Data to save
|
||||
* @return int <0 if KO, Nb of bytes written if OK
|
||||
*/
|
||||
function dol_setshmop($memoryid,$data)
|
||||
function dol_setshmop($memoryid, $data)
|
||||
{
|
||||
global $shmkeys,$shmoffset;
|
||||
|
||||
@@ -224,11 +224,11 @@ function dol_setshmop($memoryid,$data)
|
||||
$newdata=serialize($data);
|
||||
$size=strlen($newdata);
|
||||
//print 'dol_setshmop memoryid='.$memoryid." shmkey=".$shmkey." newdata=".$size."bytes<br>\n";
|
||||
$handle=shmop_open($shmkey,'c',0644,6+$size);
|
||||
$handle=shmop_open($shmkey, 'c', 0644, 6+$size);
|
||||
if ($handle)
|
||||
{
|
||||
$shm_bytes_written1=shmop_write($handle,str_pad($size,6),0);
|
||||
$shm_bytes_written2=shmop_write($handle,$newdata,6);
|
||||
$shm_bytes_written1=shmop_write($handle, str_pad($size, 6), 0);
|
||||
$shm_bytes_written2=shmop_write($handle, $newdata, 6);
|
||||
if (($shm_bytes_written1 + $shm_bytes_written2) != (6+dol_strlen($newdata)))
|
||||
{
|
||||
print "Couldn't write the entire length of data\n";
|
||||
@@ -256,11 +256,11 @@ function dol_getshmop($memoryid)
|
||||
if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0;
|
||||
$shmkey=dol_getshmopaddress($memoryid);
|
||||
//print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n";
|
||||
$handle=@shmop_open($shmkey,'a',0,0);
|
||||
$handle=@shmop_open($shmkey, 'a', 0, 0);
|
||||
if ($handle)
|
||||
{
|
||||
$size=trim(shmop_read($handle,0,6));
|
||||
if ($size) $data=unserialize(shmop_read($handle,6,$size));
|
||||
$size=trim(shmop_read($handle, 0, 6));
|
||||
if ($size) $data=unserialize(shmop_read($handle, 6, $size));
|
||||
else return -1;
|
||||
shmop_close($handle);
|
||||
}
|
||||
@@ -270,4 +270,3 @@ function dol_getshmop($memoryid)
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -35,16 +35,16 @@
|
||||
* @param string $addfieldentry Array of the field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure')
|
||||
* @param string $delfieldentry Id of field to remove
|
||||
* @return int|object <=0 if KO, Object if OK
|
||||
* @see rebuildObjectSql
|
||||
* @see rebuildObjectSql()
|
||||
*/
|
||||
function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='', $addfieldentry=array() ,$delfieldentry='')
|
||||
function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = '', $addfieldentry = array(), $delfieldentry = '')
|
||||
{
|
||||
global $db, $langs;
|
||||
|
||||
if (empty($objectname)) return -1;
|
||||
if (empty($readdir)) $readdir=$destdir;
|
||||
if (empty($readdir)) $readdir = $destdir;
|
||||
|
||||
if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval']))
|
||||
if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval']))
|
||||
{
|
||||
dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.');
|
||||
return -1;
|
||||
@@ -63,18 +63,17 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (! preg_match('/^(price|boolean|sellist|integer|date|timestamp|varchar|double|text|html)/', $addfieldentry['type']))
|
||||
|
||||
if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type'])
|
||||
&& !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type']))
|
||||
{
|
||||
setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors');
|
||||
setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors');
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
$pathoffiletoeditsrc=$readdir.'/class/'.strtolower($objectname).'.class.php';
|
||||
$pathoffiletoedittarget=$destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : '');
|
||||
if (! dol_is_file($pathoffiletoeditsrc))
|
||||
$pathoffiletoeditsrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
|
||||
$pathoffiletoedittarget = $destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : '');
|
||||
if (!dol_is_file($pathoffiletoeditsrc))
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
|
||||
@@ -87,7 +86,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
try
|
||||
{
|
||||
include_once $pathoffiletoeditsrc;
|
||||
if (class_exists($objectname)) $object=new $objectname($db);
|
||||
if (class_exists($objectname)) $object = new $objectname($db);
|
||||
else return -4;
|
||||
|
||||
// Backup old file
|
||||
@@ -101,83 +100,86 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
{
|
||||
if (is_array($addfieldentry) && count($addfieldentry))
|
||||
{
|
||||
$name=$addfieldentry['name'];
|
||||
$name = $addfieldentry['name'];
|
||||
unset($addfieldentry['name']);
|
||||
|
||||
$object->fields[$name]=$addfieldentry;
|
||||
$object->fields[$name] = $addfieldentry;
|
||||
}
|
||||
if (! empty($delfieldentry))
|
||||
if (!empty($delfieldentry))
|
||||
{
|
||||
$name=$delfieldentry;
|
||||
$name = $delfieldentry;
|
||||
unset($object->fields[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
dol_sort_array($object->fields, 'position');
|
||||
|
||||
$i=0;
|
||||
$i = 0;
|
||||
$texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n";
|
||||
$texttoinsert.= "\t".'/**'."\n";
|
||||
$texttoinsert.= "\t".' * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.'."\n";
|
||||
$texttoinsert.= "\t".' */'."\n";
|
||||
$texttoinsert.= "\t".'public $fields=array('."\n";
|
||||
$texttoinsert .= "\t".'/**'."\n";
|
||||
$texttoinsert .= "\t".' * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.'."\n";
|
||||
$texttoinsert .= "\t".' */'."\n";
|
||||
$texttoinsert .= "\t".'public $fields=array('."\n";
|
||||
|
||||
if (count($object->fields))
|
||||
{
|
||||
|
||||
foreach($object->fields as $key => $val)
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
$i++;
|
||||
$texttoinsert.= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
|
||||
$texttoinsert.= " 'enabled'=>".($val['enabled']!=''?$val['enabled']:1).",";
|
||||
$texttoinsert.= " 'visible'=>".($val['visible']!=''?$val['visible']:-1).",";
|
||||
$texttoinsert.= " 'position'=>".($val['position']!=''?$val['position']:50).",";
|
||||
$texttoinsert.= " 'notnull'=>".($val['notnull']!=''?$val['notnull']:-1).",";
|
||||
if ($val['default']) $texttoinsert.= " 'default'=>'".$val['default']."',";
|
||||
if ($val['index']) $texttoinsert.= " 'index'=>".$val['index'].",";
|
||||
if ($val['searchall']) $texttoinsert.= " 'searchall'=>".$val['searchall'].",";
|
||||
if ($val['isameasure']) $texttoinsert.= " 'isameasure'=>'".$val['isameasure']."',";
|
||||
if ($val['foreignkey']) $texttoinsert.= " 'foreignkey'=>'".$val['foreignkey']."',";
|
||||
if ($val['help']) $texttoinsert.= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
|
||||
if ($val['comment']) $texttoinsert.= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\",";
|
||||
if ($val['showoncombobox']) $texttoinsert.= " 'showoncombobox'=>'".$val['showoncombobox']."',";
|
||||
$texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
|
||||
$texttoinsert .= " 'enabled'=>".($val['enabled'] != '' ? $val['enabled'] : 1).",";
|
||||
$texttoinsert .= " 'position'=>".($val['position'] != '' ? $val['position'] : 50).",";
|
||||
$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
|
||||
$texttoinsert .= " 'visible'=>".($val['visible'] != '' ? $val['visible'] : -1).",";
|
||||
if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
|
||||
if ($val['default']) $texttoinsert .= " 'default'=>'".$val['default']."',";
|
||||
if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].",";
|
||||
if ($val['foreignkey']) $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',";
|
||||
if ($val['searchall']) $texttoinsert .= " 'searchall'=>".$val['searchall'].",";
|
||||
if ($val['isameasure']) $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',";
|
||||
if ($val['css']) $texttoinsert .= " 'css'=>'".$val['css']."',";
|
||||
if ($val['help']) $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
|
||||
if ($val['showoncombobox']) $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',";
|
||||
if ($val['disabled']) $texttoinsert .= " 'disabled'=>'".$val['disabled']."',";
|
||||
if ($val['arrayofkeyval'])
|
||||
{
|
||||
$texttoinsert.= " 'arrayofkeyval'=>array(";
|
||||
$i=0;
|
||||
foreach($val['arrayofkeyval'] as $key2 => $val2)
|
||||
$texttoinsert .= " 'arrayofkeyval'=>array(";
|
||||
$i = 0;
|
||||
foreach ($val['arrayofkeyval'] as $key2 => $val2)
|
||||
{
|
||||
if ($i) $texttoinsert.=", ";
|
||||
$texttoinsert.="'".$key2."'=>'".$val2."'";
|
||||
if ($i) $texttoinsert .= ", ";
|
||||
$texttoinsert .= "'".$key2."'=>'".$val2."'";
|
||||
$i++;
|
||||
}
|
||||
$texttoinsert.= ")";
|
||||
$texttoinsert .= "),";
|
||||
}
|
||||
$texttoinsert.= "),\n";
|
||||
if ($val['comment']) $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
|
||||
|
||||
$texttoinsert .= "),\n";
|
||||
}
|
||||
}
|
||||
|
||||
$texttoinsert.= "\t".');'."\n";
|
||||
$texttoinsert .= "\t".');'."\n";
|
||||
//print ($texttoinsert);exit;
|
||||
|
||||
if (count($object->fields))
|
||||
{
|
||||
$typetotypephp=array('integer'=>'integer', 'varchar'=>'string');
|
||||
//$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string');
|
||||
|
||||
foreach($object->fields as $key => $val)
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
$i++;
|
||||
//$typephp=$typetotypephp[$val['type']];
|
||||
$texttoinsert.= "\t".'public $'.$key.";";
|
||||
$texttoinsert .= "\t".'public $'.$key.";";
|
||||
//if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
|
||||
//if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
|
||||
//$texttoinsert.= ($val['notnull']?' NOT NULL':'');
|
||||
//if ($i < count($object->fields)) $texttoinsert.=";";
|
||||
$texttoinsert.= "\n";
|
||||
$texttoinsert .= "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$texttoinsert.= "\t".'// END MODULEBUILDER PROPERTIES';
|
||||
$texttoinsert .= "\t".'// END MODULEBUILDER PROPERTIES';
|
||||
|
||||
//print($texttoinsert);exit;
|
||||
|
||||
@@ -191,7 +193,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
|
||||
return $object;
|
||||
}
|
||||
catch(Exception $e)
|
||||
catch (Exception $e)
|
||||
{
|
||||
print $e->getMessage();
|
||||
return -5;
|
||||
@@ -208,23 +210,23 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
* @param string $readdir Directory source (use $destdir when not defined)
|
||||
* @param Object $object If object was already loaded/known, it is pass to avaoid another include and new.
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
* @see rebuildObjectClass
|
||||
* @see rebuildObjectClass()
|
||||
*/
|
||||
function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', $object=null)
|
||||
function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '', $object = null)
|
||||
{
|
||||
global $db, $langs;
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($objectname)) return -1;
|
||||
if (empty($readdir)) $readdir=$destdir;
|
||||
if (empty($readdir)) $readdir = $destdir;
|
||||
|
||||
$pathoffiletoclasssrc=$readdir.'/class/'.strtolower($objectname).'.class.php';
|
||||
$pathoffiletoclasssrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
|
||||
|
||||
// Edit .sql file
|
||||
$pathoffiletoeditsrc=$readdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql';
|
||||
$pathoffiletoedittarget=$destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
|
||||
if (! dol_is_file($pathoffiletoeditsrc))
|
||||
$pathoffiletoeditsrc = $readdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql';
|
||||
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
|
||||
if (!dol_is_file($pathoffiletoeditsrc))
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
|
||||
@@ -234,14 +236,14 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
|
||||
// Load object from myobject.class.php
|
||||
try
|
||||
{
|
||||
if (! is_object($object))
|
||||
if (!is_object($object))
|
||||
{
|
||||
include_once $pathoffiletoclasssrc;
|
||||
if (class_exists($objectname)) $object=new $objectname($db);
|
||||
if (class_exists($objectname)) $object = new $objectname($db);
|
||||
else return -1;
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
catch (Exception $e)
|
||||
{
|
||||
print $e->getMessage();
|
||||
}
|
||||
@@ -251,38 +253,38 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
|
||||
|
||||
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
|
||||
|
||||
$i=0;
|
||||
$i = 0;
|
||||
$texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n";
|
||||
if (count($object->fields))
|
||||
{
|
||||
foreach($object->fields as $key => $val)
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
$i++;
|
||||
|
||||
$type = $val['type'];
|
||||
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
|
||||
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
|
||||
|
||||
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
|
||||
else if ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
|
||||
else if ($type == 'link' || $type == 'sellist') $type = 'integer';
|
||||
$texttoinsert.= "\t".$key." ".$type;
|
||||
if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
|
||||
if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
|
||||
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
|
||||
elseif ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
|
||||
elseif (in_array($type, array('link', 'sellist', 'duration'))) $type = 'integer';
|
||||
$texttoinsert .= "\t".$key." ".$type;
|
||||
if ($key == 'rowid') $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
|
||||
if ($key == 'entity') $texttoinsert .= ' DEFAULT 1';
|
||||
else
|
||||
{
|
||||
if ($val['default'] != '')
|
||||
{
|
||||
if (preg_match('/^null$/i', $val['default'])) $texttoinsert.= " DEFAULT NULL";
|
||||
else if (preg_match('/varchar/', $type )) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'";
|
||||
else $texttoinsert.= (($val['default'] > 0)?' DEFAULT '.$val['default']:'');
|
||||
if (preg_match('/^null$/i', $val['default'])) $texttoinsert .= " DEFAULT NULL";
|
||||
elseif (preg_match('/varchar/', $type)) $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'";
|
||||
else $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : '');
|
||||
}
|
||||
}
|
||||
$texttoinsert.= (($val['notnull'] > 0)?' NOT NULL':'');
|
||||
if ($i < count($object->fields)) $texttoinsert.=", ";
|
||||
$texttoinsert.= "\n";
|
||||
$texttoinsert .= (($val['notnull'] > 0) ? ' NOT NULL' : '');
|
||||
if ($i < count($object->fields)) $texttoinsert .= ", ";
|
||||
$texttoinsert .= "\n";
|
||||
}
|
||||
}
|
||||
$texttoinsert.= "\t".'-- END MODULEBUILDER FIELDS';
|
||||
$texttoinsert .= "\t".'-- END MODULEBUILDER FIELDS';
|
||||
|
||||
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql);
|
||||
|
||||
@@ -297,35 +299,35 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='',
|
||||
}
|
||||
|
||||
// Edit .key.sql file
|
||||
$pathoffiletoeditsrc=$destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql';
|
||||
$pathoffiletoedittarget=$destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : '');
|
||||
$pathoffiletoeditsrc = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql';
|
||||
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : '');
|
||||
|
||||
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
|
||||
|
||||
$i=0;
|
||||
$i = 0;
|
||||
$texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n";
|
||||
if (count($object->fields))
|
||||
{
|
||||
foreach($object->fields as $key => $val)
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
$i++;
|
||||
if (! empty($val['index']))
|
||||
if (!empty($val['index']))
|
||||
{
|
||||
$texttoinsert.= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");";
|
||||
$texttoinsert.= "\n";
|
||||
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");";
|
||||
$texttoinsert .= "\n";
|
||||
}
|
||||
if (! empty($val['foreignkey']))
|
||||
if (!empty($val['foreignkey']))
|
||||
{
|
||||
$tmp=explode('.',$val['foreignkey']);
|
||||
if (! empty($tmp[0]) && ! empty($tmp[1]))
|
||||
$tmp = explode('.', $val['foreignkey']);
|
||||
if (!empty($tmp[0]) && !empty($tmp[1]))
|
||||
{
|
||||
$texttoinsert.= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES ".$tmp[0]."(".$tmp[1].");";
|
||||
$texttoinsert.= "\n";
|
||||
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES llx_".preg_replace('/^llx_/', '', $tmp[0])."(".$tmp[1].");";
|
||||
$texttoinsert .= "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$texttoinsert.= '-- END MODULEBUILDER INDEXES';
|
||||
$texttoinsert .= '-- END MODULEBUILDER INDEXES';
|
||||
|
||||
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER INDEXES.*END MODULEBUILDER INDEXES/ims', $texttoinsert, $contentsql);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,7 @@ function multicurrencyAdminPrepareHead()
|
||||
$head[$h][2] = 'settings';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'multicurrency');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -271,7 +271,7 @@ $list = array (
|
||||
*/
|
||||
function oauthadmin_prepare_head()
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
global $langs, $conf;
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -34,13 +34,13 @@
|
||||
function commande_prepare_head(Commande $object)
|
||||
{
|
||||
global $db, $langs, $conf, $user;
|
||||
if (! empty($conf->expedition->enabled)) $langs->load("sendings");
|
||||
if (!empty($conf->expedition->enabled)) $langs->load("sendings");
|
||||
$langs->load("orders");
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
|
||||
if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("OrderCard");
|
||||
@@ -50,10 +50,10 @@ function commande_prepare_head(Commande $object)
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
@@ -67,8 +67,8 @@ function commande_prepare_head(Commande $object)
|
||||
if ($conf->expedition_bon->enabled) $text.=$langs->trans("Shipments");
|
||||
if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
|
||||
if ($conf->livraison_bon->enabled) $text.=$langs->trans("Receivings");
|
||||
if ($nbShipments > 0 || $nbReceiption > 0) $text.= ' <span class="badge">'.($nbShipments?$nbShipments:0);
|
||||
if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
|
||||
if ($nbShipments > 0 || $nbReceiption > 0) $text.= '<span class="badge marginleftonlyshort">'.($nbShipments?$nbShipments:0);
|
||||
if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.='/';
|
||||
if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.= ($nbReceiption?$nbReceiption:0);
|
||||
if ($nbShipments > 0 || $nbReceiption > 0) $text.= '</span>';
|
||||
$head[$h][1] = $text;
|
||||
@@ -80,7 +80,7 @@ function commande_prepare_head(Commande $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'order');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'order');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
@@ -89,19 +89,19 @@ function commande_prepare_head(Commande $object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$upload_dir = $conf->commande->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -110,7 +110,7 @@ function commande_prepare_head(Commande $object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ function order_admin_prepare_head()
|
||||
$head[$h][2] = 'general';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'order_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
@@ -144,9 +144,7 @@ function order_admin_prepare_head()
|
||||
$head[$h][2] = 'attributeslines';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'order_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@
|
||||
* @param string $replaceimagepath Replace path to image with another path. Exemple: ('doc/'=>'xxx/aaa/')
|
||||
* @return string Parsed content
|
||||
*/
|
||||
function dolMd2Html($content, $parser='parsedown',$replaceimagepath=null)
|
||||
function dolMd2Html($content, $parser = 'parsedown', $replaceimagepath = null)
|
||||
{
|
||||
if (is_array($replaceimagepath))
|
||||
{
|
||||
@@ -37,7 +37,7 @@ function dolMd2Html($content, $parser='parsedown',$replaceimagepath=null)
|
||||
{
|
||||
$keytoreplace = ']('.$key;
|
||||
$valafter = ']('.$val;
|
||||
$content = preg_replace('/'.preg_quote($keytoreplace,'/').'/m', $valafter, $content);
|
||||
$content = preg_replace('/'.preg_quote($keytoreplace, '/').'/m', $valafter, $content);
|
||||
}
|
||||
}
|
||||
if ($parser == 'parsedown')
|
||||
@@ -54,3 +54,34 @@ function dolMd2Html($content, $parser='parsedown',$replaceimagepath=null)
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to parse MD content into ASCIIDOC
|
||||
*
|
||||
* @param string $content MD content
|
||||
* @param string $parser 'dolibarr'
|
||||
* @param string $replaceimagepath Replace path to image with another path. Exemple: ('doc/'=>'xxx/aaa/')
|
||||
* @return string Parsed content
|
||||
*/
|
||||
function dolMd2Asciidoc($content, $parser = 'dolibarr', $replaceimagepath = null)
|
||||
{
|
||||
if (is_array($replaceimagepath))
|
||||
{
|
||||
foreach($replaceimagepath as $key => $val)
|
||||
{
|
||||
$keytoreplace = ']('.$key;
|
||||
$valafter = ']('.$val;
|
||||
$content = preg_replace('/'.preg_quote($keytoreplace, '/').'/m', $valafter, $content);
|
||||
}
|
||||
}
|
||||
//if ($parser == 'dolibarr')
|
||||
//{
|
||||
$content = preg_replace('/<!--.*-->/msU', '', $content);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// $content = $content;
|
||||
//}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -42,14 +42,14 @@ function payment_prepare_head(Paiement $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'payment');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/paiement/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'payment', 'remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -77,14 +77,14 @@ function payment_supplier_prepare_head(Paiement $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_supplier');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_supplier');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/fourn/paiement/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Info');
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'payment_supplier', 'remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'payment_supplier', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -95,24 +95,30 @@ function payment_supplier_prepare_head(Paiement $object)
|
||||
* @param string $paymentmethod Filter on this payment method (''=none, 'paypal', ...)
|
||||
* @return array Array of valid payment method
|
||||
*/
|
||||
function getValidOnlinePaymentMethods($paymentmethod='')
|
||||
function getValidOnlinePaymentMethods($paymentmethod = '')
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $langs;
|
||||
|
||||
$validpaymentmethod=array();
|
||||
|
||||
if ((empty($paymentmethod) || $paymentmethod == 'paypal') && ! empty($conf->paypal->enabled))
|
||||
{
|
||||
$langs->load("paypal");
|
||||
$validpaymentmethod['paypal']='valid';
|
||||
}
|
||||
if ((empty($paymentmethod) || $paymentmethod == 'paybox') && ! empty($conf->paybox->enabled))
|
||||
{
|
||||
$langs->load("paybox");
|
||||
$validpaymentmethod['paybox']='valid';
|
||||
}
|
||||
if ((empty($paymentmethod) || $paymentmethod == 'stripe') && ! empty($conf->stripe->enabled))
|
||||
{
|
||||
$langs->load("stripe");
|
||||
$validpaymentmethod['stripe']='valid';
|
||||
}
|
||||
// TODO Add trigger
|
||||
|
||||
|
||||
return $validpaymentmethod;
|
||||
}
|
||||
|
||||
@@ -123,51 +129,61 @@ function getValidOnlinePaymentMethods($paymentmethod='')
|
||||
* @param string $ref Ref of object
|
||||
* @return string Url string
|
||||
*/
|
||||
function showOnlinePaymentUrl($type,$ref)
|
||||
function showOnlinePaymentUrl($type, $ref)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $langs;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('payment', 'paybox'));
|
||||
$langs->loadLangs(array('payment', 'stripe'));
|
||||
|
||||
$servicename='Online';
|
||||
$servicename = $langs->transnoentitiesnoconv('Online');
|
||||
|
||||
$out = img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment",$servicename).'<br>';
|
||||
$url = getOnlinePaymentUrl(0,$type,$ref);
|
||||
$out.= '<input type="text" id="onlinepaymenturl" class="quatrevingtpercent" value="'.$url.'">';
|
||||
$out.= ajax_autoselect("onlinepaymenturl", 0);
|
||||
$out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'<br>';
|
||||
$url = getOnlinePaymentUrl(0, $type, $ref);
|
||||
$out .= '<input type="text" id="onlinepaymenturl" class="quatrevingtpercent" value="'.$url.'">';
|
||||
$out .= ajax_autoselect("onlinepaymenturl", 0);
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return string with full Url
|
||||
*
|
||||
* @param int $mode 0=True url, 1=Url formated with colors
|
||||
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...)
|
||||
* @param string $ref Ref of object
|
||||
* @param int $amount Amount (required for $type='free' only)
|
||||
* @param string $freetag Free tag
|
||||
* @return string Url string
|
||||
* @param int $mode 0=True url, 1=Url formated with colors
|
||||
* @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...)
|
||||
* @param string $ref Ref of object
|
||||
* @param int $amount Amount (required for $type='free' only)
|
||||
* @param string $freetag Free tag
|
||||
* @param string $localorexternal 0=Url for browser, 1=Url for external access
|
||||
* @return string Url string
|
||||
*/
|
||||
function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='your_free_tag')
|
||||
function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 0)
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $dolibarr_main_url_root;
|
||||
|
||||
$ref=str_replace(' ','',$ref);
|
||||
$out='';
|
||||
$ref = str_replace(' ', '', $ref);
|
||||
$out = '';
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
|
||||
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
$urltouse = DOL_MAIN_URL_ROOT;
|
||||
if ($localorexternal) $urltouse = $urlwithroot;
|
||||
|
||||
if ($type == 'free')
|
||||
{
|
||||
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?amount='.($mode?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':'');
|
||||
$out=$urltouse.'/public/payment/newpayment.php?amount='.($mode?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':'');
|
||||
if (! empty($conf->global->PAYMENT_SECURITY_TOKEN))
|
||||
{
|
||||
if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
|
||||
else $out.='&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
|
||||
}
|
||||
//if ($mode) $out.='&noidempotency=1';
|
||||
}
|
||||
elseif ($type == 'order')
|
||||
{
|
||||
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=order&ref='.($mode?'<font color="#666666">':'');
|
||||
$out=$urltouse.'/public/payment/newpayment.php?source=order&ref='.($mode?'<font color="#666666">':'');
|
||||
if ($mode == 1) $out.='order_ref';
|
||||
if ($mode == 0) $out.=urlencode($ref);
|
||||
$out.=($mode?'</font>':'');
|
||||
@@ -185,7 +201,7 @@ function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='yo
|
||||
}
|
||||
elseif ($type == 'invoice')
|
||||
{
|
||||
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':'');
|
||||
$out=$urltouse.'/public/payment/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':'');
|
||||
if ($mode == 1) $out.='invoice_ref';
|
||||
if ($mode == 0) $out.=urlencode($ref);
|
||||
$out.=($mode?'</font>':'');
|
||||
@@ -203,7 +219,7 @@ function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='yo
|
||||
}
|
||||
elseif ($type == 'contractline')
|
||||
{
|
||||
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':'');
|
||||
$out=$urltouse.'/public/payment/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':'');
|
||||
if ($mode == 1) $out.='contractline_ref';
|
||||
if ($mode == 0) $out.=urlencode($ref);
|
||||
$out.=($mode?'</font>':'');
|
||||
@@ -221,7 +237,7 @@ function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='yo
|
||||
}
|
||||
elseif ($type == 'member' || $type == 'membersubscription')
|
||||
{
|
||||
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':'');
|
||||
$out=$urltouse.'/public/payment/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':'');
|
||||
if ($mode == 1) $out.='member_ref';
|
||||
if ($mode == 0) $out.=urlencode($ref);
|
||||
$out.=($mode?'</font>':'');
|
||||
@@ -239,7 +255,7 @@ function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='yo
|
||||
}
|
||||
if ($type == 'donation')
|
||||
{
|
||||
$out=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?source=donation&ref='.($mode?'<font color="#666666">':'');
|
||||
$out=$urltouse.'/public/payment/newpayment.php?source=donation&ref='.($mode?'<font color="#666666">':'');
|
||||
if ($mode == 1) $out.='donation_ref';
|
||||
if ($mode == 0) $out.=urlencode($ref);
|
||||
$out.=($mode?'</font>':'');
|
||||
@@ -274,56 +290,56 @@ function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='yo
|
||||
* @param Object $object Object related to payment
|
||||
* @return void
|
||||
*/
|
||||
function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
|
||||
function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// Juridical status
|
||||
$line1="";
|
||||
$line1 = "";
|
||||
if ($fromcompany->forme_juridique_code)
|
||||
{
|
||||
$line1.=($line1?" - ":"").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
|
||||
$line1 .= ($line1 ? " - " : "").getFormeJuridiqueLabel($fromcompany->forme_juridique_code);
|
||||
}
|
||||
// Capital
|
||||
if ($fromcompany->capital)
|
||||
{
|
||||
$line1.=($line1?" - ":"").$langs->transnoentities("CapitalOf",$fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency);
|
||||
$line1 .= ($line1 ? " - " : "").$langs->transnoentities("CapitalOf", $fromcompany->capital)." ".$langs->transnoentities("Currency".$conf->currency);
|
||||
}
|
||||
// Prof Id 1
|
||||
if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || ! $fromcompany->idprof2))
|
||||
if ($fromcompany->idprof1 && ($fromcompany->country_code != 'FR' || !$fromcompany->idprof2))
|
||||
{
|
||||
$field=$langs->transcountrynoentities("ProfId1",$fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
|
||||
$line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof1;
|
||||
$field = $langs->transcountrynoentities("ProfId1", $fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
|
||||
$line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof1;
|
||||
}
|
||||
// Prof Id 2
|
||||
if ($fromcompany->idprof2)
|
||||
{
|
||||
$field=$langs->transcountrynoentities("ProfId2",$fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
|
||||
$line1.=($line1?" - ":"").$field.": ".$fromcompany->idprof2;
|
||||
$field = $langs->transcountrynoentities("ProfId2", $fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
|
||||
$line1 .= ($line1 ? " - " : "").$field.": ".$fromcompany->idprof2;
|
||||
}
|
||||
|
||||
// Second line of company infos
|
||||
$line2="";
|
||||
$line2 = "";
|
||||
// Prof Id 3
|
||||
if ($fromcompany->idprof3)
|
||||
{
|
||||
$field=$langs->transcountrynoentities("ProfId3",$fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
|
||||
$line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof3;
|
||||
$field = $langs->transcountrynoentities("ProfId3", $fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
|
||||
$line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof3;
|
||||
}
|
||||
// Prof Id 4
|
||||
if ($fromcompany->idprof4)
|
||||
{
|
||||
$field=$langs->transcountrynoentities("ProfId4",$fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i',$field,$reg)) $field=$reg[1];
|
||||
$line2.=($line2?" - ":"").$field.": ".$fromcompany->idprof4;
|
||||
$field = $langs->transcountrynoentities("ProfId4", $fromcompany->country_code);
|
||||
if (preg_match('/\((.*)\)/i', $field, $reg)) $field = $reg[1];
|
||||
$line2 .= ($line2 ? " - " : "").$field.": ".$fromcompany->idprof4;
|
||||
}
|
||||
// IntraCommunautary VAT
|
||||
if ($fromcompany->tva_intra != '')
|
||||
{
|
||||
$line2.=($line2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra;
|
||||
$line2 .= ($line2 ? " - " : "").$langs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra;
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
@@ -334,16 +350,16 @@ function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage=0, $
|
||||
print '<!-- object = '.$object->element.' -->';
|
||||
print '<br>';
|
||||
|
||||
$parammessageform='ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix;
|
||||
if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform);
|
||||
elseif (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM);
|
||||
$parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORM_'.$suffix;
|
||||
if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform);
|
||||
elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORM)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORM);
|
||||
|
||||
// Add other message if VAT exists
|
||||
if ($object->total_vat != 0 || $object->total_tva != 0)
|
||||
{
|
||||
$parammessageform='ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix;
|
||||
if (! empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform);
|
||||
elseif (! empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT);
|
||||
$parammessageform = 'ONLINE_PAYMENT_MESSAGE_FORMIFVAT_'.$suffix;
|
||||
if (!empty($conf->global->$parammessageform)) print $langs->transnoentities($conf->global->$parammessageform);
|
||||
elseif (!empty($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT)) print $langs->transnoentities($conf->global->ONLINE_PAYMENT_MESSAGE_FORMIFVAT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,8 +14,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -63,9 +63,9 @@ function prelevement_prepare_head(BonPrelevement $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'prelevement');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'prelevement','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -83,4 +83,3 @@ function prelevement_check_config()
|
||||
if(empty($conf->global->PRELEVEMENT_USER)) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@
|
||||
* @param int $qty Quantity
|
||||
* @param float $pu Unit price (HT or TTC selon price_base_type)
|
||||
* @param float $remise_percent_ligne Discount for line
|
||||
* @param float $txtva 0=do not apply standard tax, Vat rate=apply
|
||||
* @param float $txtva 0=do not apply VAT tax, VAT rate=apply (this is VAT rate only without text code, we don't need text code because we alreaydy have all tax info into $localtaxes_array)
|
||||
* @param float $uselocaltax1_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1.
|
||||
* @param float $uselocaltax2_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1.
|
||||
* @param float $remise_percent_global 0
|
||||
@@ -51,6 +51,7 @@
|
||||
* @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default)
|
||||
* @param double $multicurrency_tx Currency rate (1 by default)
|
||||
* @param double $pu_devise Amount in currency
|
||||
* @param string $multicurrency_code Value of the foreign currency if multicurrency is used ('EUR', 'USD', ...). It will be used for rounding according to currency.
|
||||
* @return array [
|
||||
* 0=total_ht,
|
||||
* 1=total_vat, (main vat only)
|
||||
@@ -82,47 +83,47 @@
|
||||
* 25=multicurrency_total_tax1 for total_ht
|
||||
* 26=multicurrency_total_tax2 for total_ht
|
||||
*/
|
||||
function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_devise=0)
|
||||
function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array = '', $progress = 100, $multicurrency_tx = 1, $pu_devise = 0, $multicurrency_code = '')
|
||||
{
|
||||
global $conf,$mysoc,$db;
|
||||
global $conf, $mysoc, $db;
|
||||
|
||||
$result=array();
|
||||
$result = array();
|
||||
|
||||
// Clean parameters
|
||||
if (empty($info_bits)) $info_bits=0;
|
||||
if (empty($txtva)) $txtva=0;
|
||||
if (empty($seller) || ! is_object($seller))
|
||||
if (empty($info_bits)) $info_bits = 0;
|
||||
if (empty($txtva)) $txtva = 0;
|
||||
if (empty($seller) || !is_object($seller))
|
||||
{
|
||||
dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter seller that is missing", LOG_WARNING);
|
||||
if (! is_object($mysoc)) // mysoc may be not defined (during migration process)
|
||||
if (!is_object($mysoc)) // mysoc may be not defined (during migration process)
|
||||
{
|
||||
$mysoc=new Societe($db);
|
||||
$mysoc = new Societe($db);
|
||||
$mysoc->setMysoc($conf);
|
||||
}
|
||||
$seller=$mysoc; // If sell is done to a customer, $seller is not provided, we use $mysoc
|
||||
$seller = $mysoc; // If sell is done to a customer, $seller is not provided, we use $mysoc
|
||||
//var_dump($seller->country_id);exit;
|
||||
}
|
||||
if (empty($localtaxes_array) || ! is_array($localtaxes_array))
|
||||
if (empty($localtaxes_array) || !is_array($localtaxes_array))
|
||||
{
|
||||
dol_syslog("Price.lib::calcul_price_total Warning: function is called with parameter localtaxes_array that is missing", LOG_WARNING);
|
||||
}
|
||||
// Too verbose. Enable for debug only
|
||||
//dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress);
|
||||
|
||||
$countryid=$seller->country_id;
|
||||
$countryid = $seller->country_id;
|
||||
|
||||
if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate=(float) $uselocaltax1_rate;
|
||||
if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate=(float) $uselocaltax2_rate;
|
||||
if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate = (float) $uselocaltax1_rate;
|
||||
if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate = (float) $uselocaltax2_rate;
|
||||
|
||||
if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj;
|
||||
if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj;
|
||||
if ($uselocaltax1_rate < 0) $uselocaltax1_rate = $seller->localtax1_assuj;
|
||||
if ($uselocaltax2_rate < 0) $uselocaltax2_rate = $seller->localtax2_assuj;
|
||||
|
||||
//var_dump($uselocaltax1_rate.' - '.$uselocaltax2_rate);
|
||||
dol_syslog('Price.lib::calcul_price_total qty='.$qty.' pu='.$pu.' remise_percent_ligne='.$remise_percent_ligne.' txtva='.$txtva.' uselocaltax1_rate='.$uselocaltax1_rate.' uselocaltax2_rate='.$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$price_base_type.' type='.$type.' progress='.$progress);
|
||||
|
||||
// Now we search localtaxes information ourself (rates and types).
|
||||
$localtax1_type=0;
|
||||
$localtax2_type=0;
|
||||
$localtax1_type = 0;
|
||||
$localtax2_type = 0;
|
||||
|
||||
if (is_array($localtaxes_array))
|
||||
{
|
||||
@@ -131,23 +132,24 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
||||
$localtax2_type = $localtaxes_array[2];
|
||||
$localtax2_rate = $localtaxes_array[3];
|
||||
}
|
||||
else // deprecated method. values and type for localtaxes must be provided by caller and loaded with getLocalTaxesFromRate
|
||||
else // deprecated method. values and type for localtaxes must be provided by caller and loaded with getLocalTaxesFromRate using the full vat rate (including text code)
|
||||
{
|
||||
$sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as cv";
|
||||
$sql.= " WHERE cv.taux = ".$txtva;
|
||||
$sql.= " AND cv.fk_pays = ".$countryid;
|
||||
dol_syslog("Price.lib::calcul_price_total search vat information using old deprecated method", LOG_WARNING);
|
||||
dol_syslog("Price.lib::calcul_price_total search vat information using old deprecated method", LOG_WARNING);
|
||||
|
||||
$sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as cv";
|
||||
$sql .= " WHERE cv.taux = ".$txtva;
|
||||
$sql .= " AND cv.fk_pays = ".$countryid;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
$localtax1_rate=$obj->localtax1;
|
||||
$localtax2_rate=$obj->localtax2;
|
||||
$localtax1_type=$obj->localtax1_type;
|
||||
$localtax2_type=$obj->localtax2_type;
|
||||
$localtax1_rate = $obj->localtax1;
|
||||
$localtax2_rate = $obj->localtax2;
|
||||
$localtax1_type = $obj->localtax1_type;
|
||||
$localtax2_type = $obj->localtax2_type;
|
||||
//var_dump($localtax1_rate.' '.$localtax2_rate.' '.$localtax1_type.' '.$localtax2_type);exit;
|
||||
}
|
||||
}
|
||||
@@ -156,14 +158,14 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
||||
|
||||
// pu calculation from pu_devise if pu empty
|
||||
if (empty($pu) && !empty($pu_devise)) {
|
||||
if (! empty($multicurrency_tx)) $pu = $pu_devise / $multicurrency_tx;
|
||||
if (!empty($multicurrency_tx)) $pu = $pu_devise / $multicurrency_tx;
|
||||
else
|
||||
{
|
||||
dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (multicurrency_tx empty when pu_devise not) ', LOG_ERR);
|
||||
return array();
|
||||
}
|
||||
}
|
||||
if ($pu === '') $pu=0;
|
||||
if ($pu === '') $pu = 0;
|
||||
// pu_devise calculation from pu
|
||||
if (empty($pu_devise) && !empty($multicurrency_tx)) {
|
||||
if (is_numeric($pu) && is_numeric($multicurrency_tx)) $pu_devise = $pu * $multicurrency_tx;
|
||||
@@ -176,20 +178,20 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
||||
|
||||
// initialize total (may be HT or TTC depending on price_base_type)
|
||||
$tot_sans_remise = $pu * $qty * $progress / 100;
|
||||
$tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100));
|
||||
$tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100));
|
||||
$tot_avec_remise = $tot_avec_remise_ligne * (1 - ($remise_percent_global / 100));
|
||||
|
||||
// initialize result array
|
||||
for ($i=0; $i <= 15; $i++) $result[$i] = 0;
|
||||
for ($i = 0; $i <= 15; $i++) $result[$i] = 0;
|
||||
|
||||
// if there's some localtax including vat, we calculate localtaxes (we will add later)
|
||||
|
||||
//If input unit price is 'HT', we need to have the totals with main VAT for a correct calculation
|
||||
// if input unit price is 'HT', we need to have the totals with main VAT for a correct calculation
|
||||
if ($price_base_type != 'TTC')
|
||||
{
|
||||
$tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)),'MU');
|
||||
$tot_avec_remise_wt = price2num($tot_avec_remise * (1 + ($txtva / 100)),'MU');
|
||||
$pu_wt = price2num($pu * (1 + ($txtva / 100)),'MU');
|
||||
$tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)), 'MU');
|
||||
$tot_avec_remise_wt = price2num($tot_avec_remise * (1 + ($txtva / 100)), 'MU');
|
||||
$pu_wt = price2num($pu * (1 + ($txtva / 100)), 'MU');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -200,51 +202,51 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
||||
|
||||
//print 'rr'.$price_base_type.'-'.$txtva.'-'.$tot_sans_remise_wt."-".$pu_wt."-".$uselocaltax1_rate."-".$localtax1_rate."-".$localtax1_type."\n";
|
||||
|
||||
$localtaxes = array(0,0,0);
|
||||
$localtaxes = array(0, 0, 0);
|
||||
$apply_tax = false;
|
||||
switch($localtax1_type) {
|
||||
case '2': // localtax on product or service
|
||||
$apply_tax = true;
|
||||
break;
|
||||
case '4': // localtax on product
|
||||
if ($type == 0) $apply_tax = true;
|
||||
break;
|
||||
case '6': // localtax on service
|
||||
if ($type == 1) $apply_tax = true;
|
||||
break;
|
||||
switch ($localtax1_type) {
|
||||
case '2': // localtax on product or service
|
||||
$apply_tax = true;
|
||||
break;
|
||||
case '4': // localtax on product
|
||||
if ($type == 0) $apply_tax = true;
|
||||
break;
|
||||
case '6': // localtax on service
|
||||
if ($type == 1) $apply_tax = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($uselocaltax1_rate && $apply_tax) {
|
||||
$result[14] = price2num(($tot_sans_remise_wt * (1 + ( $localtax1_rate / 100))) - $tot_sans_remise_wt, 'MT');
|
||||
$result[14] = price2num(($tot_sans_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_sans_remise_wt, 'MT');
|
||||
$localtaxes[0] += $result[14];
|
||||
|
||||
$result[9] = price2num(($tot_avec_remise_wt * (1 + ( $localtax1_rate / 100))) - $tot_avec_remise_wt, 'MT');
|
||||
$result[9] = price2num(($tot_avec_remise_wt * (1 + ($localtax1_rate / 100))) - $tot_avec_remise_wt, 'MT');
|
||||
$localtaxes[1] += $result[9];
|
||||
|
||||
$result[11] = price2num(($pu_wt * (1 + ( $localtax1_rate / 100))) - $pu_wt, 'MU');
|
||||
$result[11] = price2num(($pu_wt * (1 + ($localtax1_rate / 100))) - $pu_wt, 'MU');
|
||||
$localtaxes[2] += $result[11];
|
||||
}
|
||||
|
||||
$apply_tax = false;
|
||||
switch($localtax2_type) {
|
||||
case '2': // localtax on product or service
|
||||
$apply_tax = true;
|
||||
break;
|
||||
case '4': // localtax on product
|
||||
if ($type == 0) $apply_tax = true;
|
||||
break;
|
||||
case '6': // localtax on service
|
||||
if ($type == 1) $apply_tax = true;
|
||||
break;
|
||||
switch ($localtax2_type) {
|
||||
case '2': // localtax on product or service
|
||||
$apply_tax = true;
|
||||
break;
|
||||
case '4': // localtax on product
|
||||
if ($type == 0) $apply_tax = true;
|
||||
break;
|
||||
case '6': // localtax on service
|
||||
if ($type == 1) $apply_tax = true;
|
||||
break;
|
||||
}
|
||||
if ($uselocaltax2_rate && $apply_tax) {
|
||||
$result[15] = price2num(($tot_sans_remise_wt * (1 + ( $localtax2_rate / 100))) - $tot_sans_remise_wt, 'MT');
|
||||
$result[15] = price2num(($tot_sans_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_sans_remise_wt, 'MT');
|
||||
$localtaxes[0] += $result[15];
|
||||
|
||||
$result[10] = price2num(($tot_avec_remise_wt * (1 + ( $localtax2_rate / 100))) - $tot_avec_remise_wt, 'MT');
|
||||
$result[10] = price2num(($tot_avec_remise_wt * (1 + ($localtax2_rate / 100))) - $tot_avec_remise_wt, 'MT');
|
||||
$localtaxes[1] += $result[10];
|
||||
|
||||
$result[12] = price2num(($pu_wt * (1 + ( $localtax2_rate / 100))) - $pu_wt, 'MU');
|
||||
$result[12] = price2num(($pu_wt * (1 + ($localtax2_rate / 100))) - $pu_wt, 'MU');
|
||||
$localtaxes[2] += $result[12];
|
||||
}
|
||||
|
||||
@@ -253,36 +255,36 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
||||
{
|
||||
// We work to define prices using the price without tax
|
||||
$result[6] = price2num($tot_sans_remise, 'MT');
|
||||
$result[8] = price2num($tot_sans_remise * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[0], 'MT'); // Selon TVA NPR ou non
|
||||
$result8bis= price2num($tot_sans_remise * (1 + ( $txtva / 100)) + $localtaxes[0], 'MT'); // Si TVA consideree normale (non NPR)
|
||||
$result[8] = price2num($tot_sans_remise * (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)) + $localtaxes[0], 'MT'); // Selon TVA NPR ou non
|
||||
$result8bis = price2num($tot_sans_remise * (1 + ($txtva / 100)) + $localtaxes[0], 'MT'); // Si TVA consideree normale (non NPR)
|
||||
$result[7] = price2num($result8bis - ($result[6] + $localtaxes[0]), 'MT');
|
||||
|
||||
$result[0] = price2num($tot_avec_remise, 'MT');
|
||||
$result[2] = price2num($tot_avec_remise * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[1], 'MT'); // Selon TVA NPR ou non
|
||||
$result2bis= price2num($tot_avec_remise * (1 + ( $txtva / 100)) + $localtaxes[1], 'MT'); // Si TVA consideree normale (non NPR)
|
||||
$result[1] = price2num($result2bis - ($result[0] + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax)
|
||||
$result[2] = price2num($tot_avec_remise * (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)) + $localtaxes[1], 'MT'); // Selon TVA NPR ou non
|
||||
$result2bis = price2num($tot_avec_remise * (1 + ($txtva / 100)) + $localtaxes[1], 'MT'); // Si TVA consideree normale (non NPR)
|
||||
$result[1] = price2num($result2bis - ($result[0] + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax)
|
||||
|
||||
$result[3] = price2num($pu, 'MU');
|
||||
$result[5] = price2num($pu * (1 + ( (($info_bits & 1)?0:$txtva) / 100)) + $localtaxes[2], 'MU'); // Selon TVA NPR ou non
|
||||
$result5bis= price2num($pu * (1 + ($txtva / 100)) + $localtaxes[2], 'MU'); // Si TVA consideree normale (non NPR)
|
||||
$result[5] = price2num($pu * (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)) + $localtaxes[2], 'MU'); // Selon TVA NPR ou non
|
||||
$result5bis = price2num($pu * (1 + ($txtva / 100)) + $localtaxes[2], 'MU'); // Si TVA consideree normale (non NPR)
|
||||
$result[4] = price2num($result5bis - ($result[3] + $localtaxes[2]), 'MU');
|
||||
}
|
||||
else
|
||||
{
|
||||
// We work to define prices using the price with tax
|
||||
$result[8] = price2num($tot_sans_remise + $localtaxes[0], 'MT');
|
||||
$result[6] = price2num($tot_sans_remise / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
|
||||
$result6bis= price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
|
||||
$result[6] = price2num($tot_sans_remise / (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)), 'MT'); // Selon TVA NPR ou non
|
||||
$result6bis = price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
|
||||
$result[7] = price2num($result[8] - ($result6bis + $localtaxes[0]), 'MT');
|
||||
|
||||
$result[2] = price2num($tot_avec_remise + $localtaxes[1], 'MT');
|
||||
$result[0] = price2num($tot_avec_remise / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MT'); // Selon TVA NPR ou non
|
||||
$result0bis= price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
|
||||
$result[1] = price2num($result[2] - ($result0bis + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax)
|
||||
$result[0] = price2num($tot_avec_remise / (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)), 'MT'); // Selon TVA NPR ou non
|
||||
$result0bis = price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MT'); // Si TVA consideree normale (non NPR)
|
||||
$result[1] = price2num($result[2] - ($result0bis + $localtaxes[1]), 'MT'); // Total VAT = TTC - (HT + localtax)
|
||||
|
||||
$result[5] = price2num($pu + $localtaxes[2], 'MU');
|
||||
$result[3] = price2num($pu / (1 + ((($info_bits & 1)?0:$txtva) / 100)), 'MU'); // Selon TVA NPR ou non
|
||||
$result3bis= price2num($pu / (1 + ($txtva / 100)), 'MU'); // Si TVA consideree normale (non NPR)
|
||||
$result[3] = price2num($pu / (1 + ((($info_bits & 1) ? 0 : $txtva) / 100)), 'MU'); // Selon TVA NPR ou non
|
||||
$result3bis = price2num($pu / (1 + ($txtva / 100)), 'MU'); // Si TVA consideree normale (non NPR)
|
||||
$result[4] = price2num($result[5] - ($result3bis + $localtaxes[2]), 'MU');
|
||||
}
|
||||
|
||||
@@ -291,83 +293,106 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
||||
//If input unit price is 'TTC', we need to have the totals without main VAT for a correct calculation
|
||||
if ($price_base_type == 'TTC')
|
||||
{
|
||||
$tot_sans_remise= price2num($tot_sans_remise / (1 + ($txtva / 100)),'MU');
|
||||
$tot_avec_remise= price2num($tot_avec_remise / (1 + ($txtva / 100)),'MU');
|
||||
$pu = price2num($pu / (1 + ($txtva / 100)),'MU');
|
||||
$tot_sans_remise = price2num($tot_sans_remise / (1 + ($txtva / 100)), 'MU');
|
||||
$tot_avec_remise = price2num($tot_avec_remise / (1 + ($txtva / 100)), 'MU');
|
||||
$pu = price2num($pu / (1 + ($txtva / 100)), 'MU');
|
||||
}
|
||||
|
||||
$apply_tax = false;
|
||||
switch($localtax1_type) {
|
||||
case '1': // localtax on product or service
|
||||
$apply_tax = true;
|
||||
break;
|
||||
case '3': // localtax on product
|
||||
if ($type == 0) $apply_tax = true;
|
||||
break;
|
||||
case '5': // localtax on service
|
||||
if ($type == 1) $apply_tax = true;
|
||||
break;
|
||||
switch ($localtax1_type) {
|
||||
case '1': // localtax on product or service
|
||||
$apply_tax = true;
|
||||
break;
|
||||
case '3': // localtax on product
|
||||
if ($type == 0) $apply_tax = true;
|
||||
break;
|
||||
case '5': // localtax on service
|
||||
if ($type == 1) $apply_tax = true;
|
||||
break;
|
||||
}
|
||||
if ($uselocaltax1_rate && $apply_tax) {
|
||||
$result[14] = price2num(($tot_sans_remise * (1 + ( $localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount
|
||||
$result[8] += $result[14]; // total_ttc_without_discount + tax1
|
||||
$result[14] = price2num(($tot_sans_remise * (1 + ($localtax1_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax1 for total_ht_without_discount
|
||||
$result[8] += $result[14]; // total_ttc_without_discount + tax1
|
||||
|
||||
$result[9] = price2num(($tot_avec_remise * (1 + ( $localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht
|
||||
$result[2] += $result[9]; // total_ttc + tax1
|
||||
$result[9] = price2num(($tot_avec_remise * (1 + ($localtax1_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax1 for total_ht
|
||||
$result[2] += $result[9]; // total_ttc + tax1
|
||||
|
||||
$result[11] = price2num(($pu * (1 + ( $localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht
|
||||
$result[5] += $result[11]; // pu_ht + tax1
|
||||
$result[11] = price2num(($pu * (1 + ($localtax1_rate / 100))) - $pu, 'MU'); // amount tax1 for pu_ht
|
||||
$result[5] += $result[11]; // pu_ht + tax1
|
||||
}
|
||||
|
||||
$apply_tax = false;
|
||||
switch($localtax2_type) {
|
||||
case '1': // localtax on product or service
|
||||
$apply_tax = true;
|
||||
break;
|
||||
case '3': // localtax on product
|
||||
if ($type == 0) $apply_tax = true;
|
||||
break;
|
||||
case '5': // localtax on service
|
||||
if ($type == 1) $apply_tax = true;
|
||||
break;
|
||||
switch ($localtax2_type) {
|
||||
case '1': // localtax on product or service
|
||||
$apply_tax = true;
|
||||
break;
|
||||
case '3': // localtax on product
|
||||
if ($type == 0) $apply_tax = true;
|
||||
break;
|
||||
case '5': // localtax on service
|
||||
if ($type == 1) $apply_tax = true;
|
||||
break;
|
||||
}
|
||||
if ($uselocaltax2_rate && $apply_tax) {
|
||||
$result[15] = price2num(($tot_sans_remise * (1 + ( $localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount
|
||||
$result[8] += $result[15]; // total_ttc_without_discount + tax2
|
||||
$result[15] = price2num(($tot_sans_remise * (1 + ($localtax2_rate / 100))) - $tot_sans_remise, 'MT'); // amount tax2 for total_ht_without_discount
|
||||
$result[8] += $result[15]; // total_ttc_without_discount + tax2
|
||||
|
||||
$result[10] = price2num(($tot_avec_remise * (1 + ( $localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht
|
||||
$result[2] += $result[10]; // total_ttc + tax2
|
||||
$result[10] = price2num(($tot_avec_remise * (1 + ($localtax2_rate / 100))) - $tot_avec_remise, 'MT'); // amount tax2 for total_ht
|
||||
$result[2] += $result[10]; // total_ttc + tax2
|
||||
|
||||
$result[12] = price2num(($pu * (1 + ( $localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht
|
||||
$result[5] += $result[12]; // pu_ht + tax2
|
||||
$result[12] = price2num(($pu * (1 + ($localtax2_rate / 100))) - $pu, 'MU'); // amount tax2 for pu_ht
|
||||
$result[5] += $result[12]; // pu_ht + tax2
|
||||
}
|
||||
|
||||
// If rounding is not using base 10 (rare)
|
||||
if (! empty($conf->global->MAIN_ROUNDING_RULE_TOT))
|
||||
if (!empty($conf->global->MAIN_ROUNDING_RULE_TOT))
|
||||
{
|
||||
if ($price_base_type == 'HT')
|
||||
{
|
||||
$result[0]=round($result[0]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[1]=round($result[1]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[2]=price2num($result[0]+$result[1], 'MT');
|
||||
$result[9]=round($result[9]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[0] = round($result[0] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[2] = price2num($result[0] + $result[1], 'MT');
|
||||
$result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result[1]=round($result[1]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[2]=round($result[2]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[0]=price2num($result[2]-$result[1], 'MT');
|
||||
$result[9]=round($result[9]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[1] = round($result[1] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[2] = round($result[2] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[0] = price2num($result[2] - $result[1], 'MT');
|
||||
$result[9] = round($result[9] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
$result[10] = round($result[10] / $conf->global->MAIN_ROUNDING_RULE_TOT, 0) * $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
}
|
||||
}
|
||||
|
||||
// Multicurrency
|
||||
if ($multicurrency_tx != 1)
|
||||
{
|
||||
if ($multicurrency_code) {
|
||||
$savMAIN_MAX_DECIMALS_UNIT = $conf->global->MAIN_MAX_DECIMALS_UNIT;
|
||||
$savMAIN_MAX_DECIMALS_TOT = $conf->global->MAIN_MAX_DECIMALS_TOT;
|
||||
$savMAIN_ROUNDING_RULE_TOT = $conf->global->MAIN_ROUNDING_RULE_TOT;
|
||||
|
||||
// Set parameter for currency accurency according to the value of $multicurrency_code (this is because a foreign currency may have different rounding rules)
|
||||
$keyforforeignMAIN_MAX_DECIMALS_UNIT = 'MAIN_MAX_DECIMALS_UNIT_'.$multicurrency_code;
|
||||
$keyforforeignMAIN_MAX_DECIMALS_TOT = 'MAIN_MAX_DECIMALS_TOT_'.$multicurrency_code;
|
||||
$keyforforeignMAIN_ROUNDING_RULE_TOT = 'MAIN_ROUNDING_RULE_TOT_'.$multicurrency_code;
|
||||
if (!empty($conf->global->$keyforforeignMAIN_ROUNDING_RULE_TOT)) {
|
||||
$conf->global->MAIN_MAX_DECIMALS_UNIT = $keyforforeignMAIN_MAX_DECIMALS_UNIT;
|
||||
$conf->global->MAIN_MAX_DECIMALS_TOT = $keyforforeignMAIN_MAX_DECIMALS_TOT;
|
||||
$conf->global->MAIN_ROUNDING_RULE_TOT = $keyforforeignMAIN_ROUNDING_RULE_TOT;
|
||||
}
|
||||
}
|
||||
|
||||
// Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop.
|
||||
$newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0);
|
||||
$newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0, '');
|
||||
|
||||
if ($multicurrency_code) {
|
||||
// Restore setup of currency accurency
|
||||
$conf->global->MAIN_MAX_DECIMALS_UNIT = $savMAIN_MAX_DECIMALS_UNIT;
|
||||
$conf->global->MAIN_MAX_DECIMALS_TOT = $savMAIN_MAX_DECIMALS_TOT;
|
||||
$conf->global->MAIN_ROUNDING_RULE_TOT = $savMAIN_ROUNDING_RULE_TOT;
|
||||
}
|
||||
|
||||
$result[16] = $newresult[0];
|
||||
$result[17] = $newresult[1];
|
||||
@@ -380,12 +405,6 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
||||
$result[24] = $newresult[8];
|
||||
$result[25] = $newresult[9];
|
||||
$result[26] = $newresult[10];
|
||||
/*
|
||||
$result[16] = price2num($result[0] * $multicurrency_tx, 'MT');
|
||||
$result[17] = price2num($result[1] * $multicurrency_tx, 'MT');
|
||||
$result[18] = price2num($result[2] * $multicurrency_tx, 'MT');
|
||||
$result[19] = price2num($pu_devise, 'MU');
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -410,4 +429,3 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -45,7 +45,7 @@ function product_prepare_head($object)
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
if (! empty($object->status))
|
||||
if (!empty($object->status))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans("SellingPrices");
|
||||
@@ -53,10 +53,10 @@ function product_prepare_head($object)
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (! empty($object->status_buy) || (! empty($conf->margin->enabled) && ! empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase
|
||||
if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status))) // If margin is on and product on sell, we may need the cost price even if product os not on purchase
|
||||
{
|
||||
if ((! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
|
||||
|| (! empty($conf->margin->enabled) && $user->rights->margin->liretous)
|
||||
if ((!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
|
||||
|| (!empty($conf->margin->enabled) && $user->rights->margin->liretous)
|
||||
)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id;
|
||||
@@ -67,7 +67,7 @@ function product_prepare_head($object)
|
||||
}
|
||||
|
||||
// Multilangs
|
||||
if (! empty($conf->global->MAIN_MULTILANGS))
|
||||
if (!empty($conf->global->MAIN_MULTILANGS))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/traduction.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans("Translation");
|
||||
@@ -82,7 +82,7 @@ function product_prepare_head($object)
|
||||
$head[$h][1] = $langs->trans('AssociatedProducts');
|
||||
|
||||
$nbFatherAndChild = $object->hasFatherOrChild();
|
||||
if ($nbFatherAndChild > 0) $head[$h][1].= ' <span class="badge">'.$nbFatherAndChild.'</span>';
|
||||
if ($nbFatherAndChild > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbFatherAndChild.'</span>';
|
||||
$head[$h][2] = 'subproduct';
|
||||
$h++;
|
||||
}
|
||||
@@ -98,7 +98,6 @@ function product_prepare_head($object)
|
||||
$h++;
|
||||
|
||||
if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) {
|
||||
|
||||
global $db;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
@@ -111,7 +110,7 @@ function product_prepare_head($object)
|
||||
$head[$h][1] = $langs->trans('ProductCombinations');
|
||||
$head[$h][2] = 'combinations';
|
||||
$nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id);
|
||||
if ($nbVariant > 0) $head[$h][1].= ' <span class="badge">'.$nbVariant.'</span>';
|
||||
if ($nbVariant > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbVariant.'</span>';
|
||||
}
|
||||
|
||||
$h++;
|
||||
@@ -128,11 +127,30 @@ function product_prepare_head($object)
|
||||
}
|
||||
}
|
||||
|
||||
// Tab to link resources
|
||||
if (!empty($conf->resource->enabled))
|
||||
{
|
||||
if ($object->isProduct() && !empty($conf->global->RESOURCE_ON_PRODUCTS))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=product&ref='.$object->ref;
|
||||
$head[$h][1] = $langs->trans("Resources");
|
||||
$head[$h][2] = 'resources';
|
||||
$h++;
|
||||
}
|
||||
if ($object->isService() && !empty($conf->global->RESOURCE_ON_SERVICES))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=service&ref='.$object->ref;
|
||||
$head[$h][1] = $langs->trans("Resources");
|
||||
$head[$h][2] = 'resources';
|
||||
$h++;
|
||||
}
|
||||
}
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'product');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'product');
|
||||
|
||||
// Notes
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
@@ -142,7 +160,7 @@ function product_prepare_head($object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
@@ -152,28 +170,28 @@ function product_prepare_head($object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
|
||||
if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
|
||||
if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->produit->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos';
|
||||
if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id,2,0,0,$object,'product').$object->id.'/photos';
|
||||
$nbFiles += count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
|
||||
if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
|
||||
$nbFiles += count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
}
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'product', 'remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'product', 'remove');
|
||||
|
||||
// Log
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/agenda.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Events");
|
||||
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
|
||||
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
|
||||
{
|
||||
$head[$h][1].= '/';
|
||||
$head[$h][1].= $langs->trans("Agenda");
|
||||
$head[$h][1] .= '/';
|
||||
$head[$h][1] .= $langs->trans("Agenda");
|
||||
}
|
||||
$head[$h][2] = 'agenda';
|
||||
$h++;
|
||||
@@ -192,7 +210,7 @@ function productlot_prepare_head($object)
|
||||
global $db, $langs, $conf, $user;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("products","productbatch"));
|
||||
$langs->loadLangs(array("products", "productbatch"));
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
@@ -206,11 +224,11 @@ function productlot_prepare_head($object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_document.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -218,9 +236,9 @@ function productlot_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'productlot');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'productlot');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'productlot', 'remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'productlot', 'remove');
|
||||
|
||||
// Log
|
||||
/*
|
||||
@@ -252,7 +270,7 @@ function product_admin_prepare_head()
|
||||
$head[$h][2] = 'general';
|
||||
$h++;
|
||||
|
||||
if (!empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL))
|
||||
if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL))
|
||||
{
|
||||
$head[$h] = array(
|
||||
0 => DOL_URL_ROOT."/product/admin/price_rules.php",
|
||||
@@ -266,14 +284,19 @@ function product_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'product_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'product_admin','remove');
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_supplier_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ProductSupplierExtraFields");
|
||||
$head[$h][2] = 'supplierAttributes';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'product_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -296,14 +319,14 @@ function product_lot_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'product_lot_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'product_lot_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/admin/product_lot_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'product_lot_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'product_lot_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -317,142 +340,142 @@ function product_lot_admin_prepare_head()
|
||||
* @param int $socid Thirdparty id
|
||||
* @return integer NB of lines shown into array
|
||||
*/
|
||||
function show_stats_for_company($product,$socid)
|
||||
function show_stats_for_company($product, $socid)
|
||||
{
|
||||
global $conf,$langs,$user,$db;
|
||||
global $conf, $langs, $user, $db;
|
||||
|
||||
$nblines = 0;
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="left" width="25%">'.$langs->trans("Referers").'</td>';
|
||||
print '<td align="right" width="25%">'.$langs->trans("NbOfThirdParties").'</td>';
|
||||
print '<td align="right" width="25%">'.$langs->trans("NbOfObjectReferers").'</td>';
|
||||
print '<td align="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
|
||||
print '<td class="left" width="25%">'.$langs->trans("Referers").'</td>';
|
||||
print '<td class="right" width="25%">'.$langs->trans("NbOfThirdParties").'</td>';
|
||||
print '<td class="right" width="25%">'.$langs->trans("NbOfObjectReferers").'</td>';
|
||||
print '<td class="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Customer proposals
|
||||
if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
|
||||
if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
|
||||
{
|
||||
$nblines++;
|
||||
$ret=$product->load_stats_propale($socid);
|
||||
$ret = $product->load_stats_propale($socid);
|
||||
if ($ret < 0) dol_print_error($db);
|
||||
$langs->load("propal");
|
||||
print '<tr><td>';
|
||||
print '<a href="propal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("Proposals").'</a>';
|
||||
print '</td><td align="right">';
|
||||
print '<a href="propal.php?id='.$product->id.'">'.img_object('', 'propal').' '.$langs->trans("Proposals").'</a>';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_propale['customers'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_propale['nb'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_propale['qty'];
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Supplier proposals
|
||||
if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
|
||||
if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
|
||||
{
|
||||
$nblines++;
|
||||
$ret=$product->load_stats_proposal_supplier($socid);
|
||||
$ret = $product->load_stats_proposal_supplier($socid);
|
||||
if ($ret < 0) dol_print_error($db);
|
||||
$langs->load("propal");
|
||||
print '<tr><td>';
|
||||
print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('','propal').' '.$langs->trans("SupplierProposals").'</a>';
|
||||
print '</td><td align="right">';
|
||||
print '<a href="supplier_proposal.php?id='.$product->id.'">'.img_object('', 'propal').' '.$langs->trans("SupplierProposals").'</a>';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_proposal_supplier['suppliers'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_proposal_supplier['nb'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_proposal_supplier['qty'];
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Customer orders
|
||||
if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
|
||||
if (!empty($conf->commande->enabled) && $user->rights->commande->lire)
|
||||
{
|
||||
$nblines++;
|
||||
$ret=$product->load_stats_commande($socid);
|
||||
$ret = $product->load_stats_commande($socid);
|
||||
if ($ret < 0) dol_print_error($db);
|
||||
$langs->load("orders");
|
||||
print '<tr><td>';
|
||||
print '<a href="commande.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("CustomersOrders").'</a>';
|
||||
print '</td><td align="right">';
|
||||
print '<a href="commande.php?id='.$product->id.'">'.img_object('', 'order').' '.$langs->trans("CustomersOrders").'</a>';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_commande['customers'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_commande['nb'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_commande['qty'];
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Supplier orders
|
||||
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
|
||||
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
|
||||
{
|
||||
$nblines++;
|
||||
$ret=$product->load_stats_commande_fournisseur($socid);
|
||||
$ret = $product->load_stats_commande_fournisseur($socid);
|
||||
if ($ret < 0) dol_print_error($db);
|
||||
$langs->load("orders");
|
||||
print '<tr><td>';
|
||||
print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('','order').' '.$langs->trans("SuppliersOrders").'</a>';
|
||||
print '</td><td align="right">';
|
||||
print '<a href="commande_fournisseur.php?id='.$product->id.'">'.img_object('', 'order').' '.$langs->trans("SuppliersOrders").'</a>';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_commande_fournisseur['suppliers'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_commande_fournisseur['nb'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_commande_fournisseur['qty'];
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Customer invoices
|
||||
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
{
|
||||
$nblines++;
|
||||
$ret=$product->load_stats_facture($socid);
|
||||
$ret = $product->load_stats_facture($socid);
|
||||
if ($ret < 0) dol_print_error($db);
|
||||
$langs->load("bills");
|
||||
print '<tr><td>';
|
||||
print '<a href="facture.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("CustomersInvoices").'</a>';
|
||||
print '</td><td align="right">';
|
||||
print '<a href="facture.php?id='.$product->id.'">'.img_object('', 'bill').' '.$langs->trans("CustomersInvoices").'</a>';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_facture['customers'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_facture['nb'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_facture['qty'];
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
// Supplier invoices
|
||||
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
|
||||
if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire)
|
||||
{
|
||||
$nblines++;
|
||||
$ret=$product->load_stats_facture_fournisseur($socid);
|
||||
$ret = $product->load_stats_facture_fournisseur($socid);
|
||||
if ($ret < 0) dol_print_error($db);
|
||||
$langs->load("bills");
|
||||
print '<tr><td>';
|
||||
print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('','bill').' '.$langs->trans("SuppliersInvoices").'</a>';
|
||||
print '</td><td align="right">';
|
||||
print '<a href="facture_fournisseur.php?id='.$product->id.'">'.img_object('', 'bill').' '.$langs->trans("SuppliersInvoices").'</a>';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_facture_fournisseur['suppliers'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_facture_fournisseur['nb'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_facture_fournisseur['qty'];
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Contracts
|
||||
if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
|
||||
if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire)
|
||||
{
|
||||
$nblines++;
|
||||
$ret=$product->load_stats_contrat($socid);
|
||||
$ret = $product->load_stats_contrat($socid);
|
||||
if ($ret < 0) dol_print_error($db);
|
||||
$langs->load("contracts");
|
||||
print '<tr><td>';
|
||||
print '<a href="contrat.php?id='.$product->id.'">'.img_object('','contract').' '.$langs->trans("Contracts").'</a>';
|
||||
print '</td><td align="right">';
|
||||
print '<a href="contrat.php?id='.$product->id.'">'.img_object('', 'contract').' '.$langs->trans("Contracts").'</a>';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_contrat['customers'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_contrat['nb'];
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $product->stats_contrat['qty'];
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@@ -461,74 +484,89 @@ function show_stats_for_company($product,$socid)
|
||||
return $nblines++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return translation label of a unit key.
|
||||
* Function kept for backward compatibility.
|
||||
*
|
||||
* @param string $scale Scale of unit: '0', '-3', '6', ...
|
||||
* @param string $measuring_style Style of unit: weight, volume,...
|
||||
* @param int $unit ID of unit (rowid in llx_c_units table)
|
||||
* @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
|
||||
* @return string Unit string
|
||||
* @see measuringUnitString() formproduct->selectMeasuringUnits()
|
||||
*/
|
||||
function measuring_units_string($scale = '', $measuring_style = '', $unit = 0, $use_short_label = 0)
|
||||
{
|
||||
return measuringUnitString($unit, $measuring_style, $scale, $use_short_label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return translation label of a unit key
|
||||
*
|
||||
* @param int $unit Unit key (-3,0,3,98,99...)
|
||||
* @param int $unit ID of unit (rowid in llx_c_units table)
|
||||
* @param string $measuring_style Style of unit: weight, volume,...
|
||||
* @param string $scale Scale of unit: '0', '-3', '6', ...
|
||||
* @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
|
||||
* @return string Unit string
|
||||
* @see formproduct->load_measuring_units
|
||||
* @see formproduct->selectMeasuringUnits()
|
||||
*/
|
||||
function measuring_units_string($unit,$measuring_style='')
|
||||
function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_short_label = 0)
|
||||
{
|
||||
global $langs;
|
||||
global $langs, $db;
|
||||
global $measuring_unit_cache;
|
||||
|
||||
$measuring_units=array();
|
||||
if ($measuring_style == 'weight')
|
||||
if (empty($measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label]))
|
||||
{
|
||||
$measuring_units[3] = $langs->transnoentitiesnoconv("WeightUnitton");
|
||||
$measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg");
|
||||
$measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg");
|
||||
$measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg");
|
||||
$measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce");
|
||||
$measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound");
|
||||
}
|
||||
else if ($measuring_style == 'size')
|
||||
{
|
||||
$measuring_units[0] = $langs->transnoentitiesnoconv("SizeUnitm");
|
||||
$measuring_units[-1] = $langs->transnoentitiesnoconv("SizeUnitdm");
|
||||
$measuring_units[-2] = $langs->transnoentitiesnoconv("SizeUnitcm");
|
||||
$measuring_units[-3] = $langs->transnoentitiesnoconv("SizeUnitmm");
|
||||
$measuring_units[98] = $langs->transnoentitiesnoconv("SizeUnitfoot");
|
||||
$measuring_units[99] = $langs->transnoentitiesnoconv("SizeUnitinch");
|
||||
}
|
||||
else if ($measuring_style == 'surface')
|
||||
{
|
||||
$measuring_units[0] = $langs->transnoentitiesnoconv("SurfaceUnitm2");
|
||||
$measuring_units[-2] = $langs->transnoentitiesnoconv("SurfaceUnitdm2");
|
||||
$measuring_units[-4] = $langs->transnoentitiesnoconv("SurfaceUnitcm2");
|
||||
$measuring_units[-6] = $langs->transnoentitiesnoconv("SurfaceUnitmm2");
|
||||
$measuring_units[98] = $langs->transnoentitiesnoconv("SurfaceUnitfoot2");
|
||||
$measuring_units[99] = $langs->transnoentitiesnoconv("SurfaceUnitinch2");
|
||||
}
|
||||
else if ($measuring_style == 'volume')
|
||||
{
|
||||
$measuring_units[0] = $langs->transnoentitiesnoconv("VolumeUnitm3");
|
||||
$measuring_units[-3] = $langs->transnoentitiesnoconv("VolumeUnitdm3");
|
||||
$measuring_units[-6] = $langs->transnoentitiesnoconv("VolumeUnitcm3");
|
||||
$measuring_units[-9] = $langs->transnoentitiesnoconv("VolumeUnitmm3");
|
||||
$measuring_units[88] = $langs->transnoentitiesnoconv("VolumeUnitfoot3");
|
||||
$measuring_units[89] = $langs->transnoentitiesnoconv("VolumeUnitinch3");
|
||||
$measuring_units[97] = $langs->transnoentitiesnoconv("VolumeUnitounce");
|
||||
$measuring_units[98] = $langs->transnoentitiesnoconv("VolumeUnitlitre");
|
||||
$measuring_units[99] = $langs->transnoentitiesnoconv("VolumeUnitgallon");
|
||||
}
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
|
||||
$measuringUnits= new CUnits($db);
|
||||
|
||||
return $measuring_units[$unit];
|
||||
if ($scale !== '')
|
||||
{
|
||||
$arrayforfilter = array(
|
||||
't.scale' => $scale,
|
||||
't.unit_type' => $measuring_style,
|
||||
't.active' => 1
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$arrayforfilter = array(
|
||||
't.rowid' => $unit,
|
||||
't.unit_type' => $measuring_style,
|
||||
't.active' => 1
|
||||
);
|
||||
}
|
||||
$result = $measuringUnits->fetchAll('', '', 0, 0, $arrayforfilter);
|
||||
|
||||
if ($result < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
if (is_array($measuringUnits->records) && count($measuringUnits->records) > 0) {
|
||||
if ($use_short_label) $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label;
|
||||
else $labeltoreturn = $langs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label);
|
||||
} else {
|
||||
$labeltoreturn = '';
|
||||
}
|
||||
$measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label] = $labeltoreturn;
|
||||
return $labeltoreturn;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a given unit into the square of that unit, if known
|
||||
* Transform a given unit scale into the square of that unit, if known.
|
||||
*
|
||||
* @param int $unit Unit key (-3,-2,-1,0,98,99...)
|
||||
* @param int $unit Unit scale key (-3,-2,-1,0,98,99...)
|
||||
* @return int Squared unit key (-6,-4,-2,0,98,99...)
|
||||
* @see formproduct->load_measuring_units
|
||||
* @see formproduct->selectMeasuringUnits
|
||||
*/
|
||||
function measuring_units_squared($unit)
|
||||
{
|
||||
$measuring_units=array();
|
||||
$measuring_units[0] = 0; // m -> m3
|
||||
$measuring_units = array();
|
||||
$measuring_units[0] = 0; // m -> m3
|
||||
$measuring_units[-1] = -2; // dm-> dm2
|
||||
$measuring_units[-2] = -4; // cm -> cm2
|
||||
$measuring_units[-3] = -6; // mm -> mm2
|
||||
@@ -539,16 +577,16 @@ function measuring_units_squared($unit)
|
||||
|
||||
|
||||
/**
|
||||
* Transform a given unit into the cube of that unit, if known
|
||||
* Transform a given unit scale into the cube of that unit, if known
|
||||
*
|
||||
* @param int $unit Unit key (-3,-2,-1,0,98,99...)
|
||||
* @param int $unit Unit scale key (-3,-2,-1,0,98,99...)
|
||||
* @return int Cubed unit key (-9,-6,-3,0,88,89...)
|
||||
* @see formproduct->load_measuring_units
|
||||
* @see formproduct->selectMeasuringUnits
|
||||
*/
|
||||
function measuring_units_cubed($unit)
|
||||
{
|
||||
$measuring_units=array();
|
||||
$measuring_units[0] = 0; // m -> m2
|
||||
$measuring_units = array();
|
||||
$measuring_units[0] = 0; // m -> m2
|
||||
$measuring_units[-1] = -3; // dm-> dm3
|
||||
$measuring_units[-2] = -6; // cm -> cm3
|
||||
$measuring_units[-3] = -9; // mm -> mm3
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,8 +13,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -42,8 +42,8 @@ function propal_prepare_head($object)
|
||||
$head[$h][2] = 'comm';
|
||||
$h++;
|
||||
|
||||
if ((empty($conf->commande->enabled) && ((! empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire)
|
||||
|| (! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire))))
|
||||
if ((empty($conf->commande->enabled) && ((! empty($conf->expedition->enabled) && ! empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire)
|
||||
|| (! empty($conf->expedition->enabled) && ! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire))))
|
||||
{
|
||||
$langs->load("sendings");
|
||||
$text = '';
|
||||
@@ -57,10 +57,10 @@ function propal_prepare_head($object)
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ function propal_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'propal');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'propal');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
@@ -78,7 +78,7 @@ function propal_prepare_head($object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
@@ -86,11 +86,11 @@ function propal_prepare_head($object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'document';
|
||||
$h++;
|
||||
|
||||
@@ -99,7 +99,7 @@ function propal_prepare_head($object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'propal','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'propal', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ function propal_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'propal_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
@@ -137,9 +137,7 @@ function propal_admin_prepare_head()
|
||||
$head[$h][2] = 'attributeslines';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'propal_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -68,5 +68,3 @@ function receiptprinteradmin_prepare_head($mode)
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
127
htdocs/core/lib/reception.lib.php
Normal file
127
htdocs/core/lib/reception.lib.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/lib/reception.lib.php
|
||||
* \brief Function for reception module
|
||||
* \ingroup reception
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prepare array with list of tabs
|
||||
*
|
||||
* @param Reception $object Object related to tabs
|
||||
* @return array Array of tabs to show
|
||||
*/
|
||||
function reception_prepare_head(Reception $object)
|
||||
{
|
||||
global $db, $langs, $conf, $user;
|
||||
|
||||
$langs->load("sendings");
|
||||
$langs->load("deliveries");
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/reception/card.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans("ReceptionCard");
|
||||
$head[$h][2] = 'reception';
|
||||
$h++;
|
||||
|
||||
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$objectsrc = $object;
|
||||
if ($object->origin == 'commande' && $object->origin_id > 0)
|
||||
{
|
||||
$objectsrc = new Commande($db);
|
||||
$objectsrc->fetch($object->origin_id);
|
||||
}
|
||||
$nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans("ContactsAddresses");
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
|
||||
$nbNote = 0;
|
||||
if (!empty($object->note_private)) $nbNote++;
|
||||
if (!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans("Notes");
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array head with list of tabs to view object informations.
|
||||
*
|
||||
* @return array head array with tabs
|
||||
*/
|
||||
function reception_admin_prepare_head()
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
$langs->load("receptions");
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT."/admin/reception_setup.php";
|
||||
$head[$h][1] = $langs->trans("Reception");
|
||||
$head[$h][2] = 'reception';
|
||||
$h++;
|
||||
|
||||
|
||||
if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes_reception';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_SUBMODULE_RECEPTION))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsLines");
|
||||
$head[$h][2] = 'attributeslines_reception';
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -31,23 +31,23 @@
|
||||
* @param string $period Period of report
|
||||
* @param string $periodlink Link to switch period
|
||||
* @param string $description Description
|
||||
* @param timestamp|integer $builddate Date generation
|
||||
* @param integer $builddate Date generation
|
||||
* @param string $exportlink Link for export or ''
|
||||
* @param array $moreparam Array with list of params to add into form
|
||||
* @param string $calcmode Calculation mode
|
||||
* @param string $varlink Add a variable into the address of the page
|
||||
* @return void
|
||||
*/
|
||||
function report_header($reportname,$notused,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='')
|
||||
function report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if (empty($hselected)) $hselected='report';
|
||||
|
||||
print "\n\n<!-- start banner of report -->\n";
|
||||
|
||||
if(! empty($varlink)) $varlink = '?'.$varlink;
|
||||
|
||||
$head = array();
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = $_SERVER["PHP_SELF"].$varlink;
|
||||
$head[$h][1] = $langs->trans("Report");
|
||||
@@ -61,7 +61,8 @@ function report_header($reportname,$notused,$period,$periodlink,$description,$bu
|
||||
{
|
||||
print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
|
||||
}
|
||||
print '<table width="100%" class="border">';
|
||||
|
||||
print '<table class="border tableforfield centpercent">';
|
||||
|
||||
$variante = ($periodlink || $exportlink);
|
||||
|
||||
@@ -91,7 +92,7 @@ function report_header($reportname,$notused,$period,$periodlink,$description,$bu
|
||||
print '<td>'.$langs->trans("ReportPeriod").'</td>';
|
||||
print '<td>';
|
||||
if ($period) print $period;
|
||||
if ($variante) print '<td>'.$periodlink.'</td>';
|
||||
if ($variante) print '<td class="nowraponall">'.$periodlink.'</td>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@@ -122,4 +123,3 @@ function report_header($reportname,$notused,$period,$periodlink,$description,$bu
|
||||
|
||||
print "\n<!-- end banner of report -->\n\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -35,17 +35,17 @@ function resource_prepare_head($object)
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = dol_buildpath('/resource/card.php',1).'?id='.$object->id;
|
||||
$head[$h][0] = dol_buildpath('/resource/card.php', 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("ResourceCard");
|
||||
$head[$h][2] = 'resource';
|
||||
$h++;
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && (empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER) || empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ function resource_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'resource');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'resource');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
@@ -63,17 +63,17 @@ function resource_prepare_head($object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/resource/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$upload_dir = $conf->resource->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/resource/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
|
||||
if($nbFiles > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbFiles.'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -92,7 +92,7 @@ function resource_prepare_head($object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;*/
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'resource', 'remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'resource', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -119,14 +119,14 @@ function resource_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'resource_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'resource_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
*
|
||||
* 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
|
||||
@@ -13,8 +14,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -27,39 +28,72 @@
|
||||
function salaries_prepare_head($object)
|
||||
{
|
||||
|
||||
global $db, $langs, $conf;
|
||||
global $db, $langs, $conf;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries');
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$upload_dir = $conf->salaries->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge ">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/salaries/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'salaries', 'remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
|
||||
|
||||
return $head;
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array head with list of tabs to view object informations
|
||||
*
|
||||
* @return array head
|
||||
*/
|
||||
function salaries_admin_prepare_head()
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
|
||||
$head[$h][1] = $langs->trans("Miscellaneous");
|
||||
$head[$h][2] = 'general';
|
||||
$h++;
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf, $langs, '', $head, $h, 'salaries_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsSalaries");
|
||||
$head[$h][2] = 'attributes';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, '', $head, $h, 'salaries_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -32,30 +32,30 @@
|
||||
* @param string $chain string to encode
|
||||
* @param string $key rule to use for delta ('0', '1' or 'myownkey')
|
||||
* @return string encoded string
|
||||
* @see dol_decode
|
||||
* @see dol_decode()
|
||||
*/
|
||||
function dol_encode($chain, $key='1')
|
||||
function dol_encode($chain, $key = '1')
|
||||
{
|
||||
if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char
|
||||
{
|
||||
$output_tab=array();
|
||||
$strlength=dol_strlen($chain);
|
||||
for ($i=0; $i < $strlength; $i++)
|
||||
$output_tab = array();
|
||||
$strlength = dol_strlen($chain);
|
||||
for ($i = 0; $i < $strlength; $i++)
|
||||
{
|
||||
$output_tab[$i] = chr(ord(substr($chain,$i,1))+17);
|
||||
$output_tab[$i] = chr(ord(substr($chain, $i, 1)) + 17);
|
||||
}
|
||||
$chain = implode("",$output_tab);
|
||||
$chain = implode("", $output_tab);
|
||||
}
|
||||
elseif ($key)
|
||||
{
|
||||
$result='';
|
||||
$strlength=dol_strlen($chain);
|
||||
for ($i=0; $i < $strlength; $i++)
|
||||
$result = '';
|
||||
$strlength = dol_strlen($chain);
|
||||
for ($i = 0; $i < $strlength; $i++)
|
||||
{
|
||||
$keychar = substr($key, ($i % strlen($key))-1, 1);
|
||||
$result.= chr(ord(substr($chain,$i,1))+(ord($keychar)-65));
|
||||
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
|
||||
$result .= chr(ord(substr($chain, $i, 1)) + (ord($keychar) - 65));
|
||||
}
|
||||
$chain=$result;
|
||||
$chain = $result;
|
||||
}
|
||||
|
||||
return base64_encode($chain);
|
||||
@@ -68,33 +68,33 @@ function dol_encode($chain, $key='1')
|
||||
* @param string $chain string to decode
|
||||
* @param string $key rule to use for delta ('0', '1' or 'myownkey')
|
||||
* @return string decoded string
|
||||
* @see dol_encode
|
||||
* @see dol_encode()
|
||||
*/
|
||||
function dol_decode($chain, $key='1')
|
||||
function dol_decode($chain, $key = '1')
|
||||
{
|
||||
$chain = base64_decode($chain);
|
||||
|
||||
if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char
|
||||
{
|
||||
$output_tab=array();
|
||||
$strlength=dol_strlen($chain);
|
||||
for ($i=0; $i < $strlength;$i++)
|
||||
$output_tab = array();
|
||||
$strlength = dol_strlen($chain);
|
||||
for ($i = 0; $i < $strlength; $i++)
|
||||
{
|
||||
$output_tab[$i] = chr(ord(substr($chain,$i,1))-17);
|
||||
$output_tab[$i] = chr(ord(substr($chain, $i, 1)) - 17);
|
||||
}
|
||||
|
||||
$chain = implode("",$output_tab);
|
||||
$chain = implode("", $output_tab);
|
||||
}
|
||||
elseif ($key)
|
||||
{
|
||||
$result='';
|
||||
$strlength=dol_strlen($chain);
|
||||
for ($i=0; $i < $strlength; $i++)
|
||||
$result = '';
|
||||
$strlength = dol_strlen($chain);
|
||||
for ($i = 0; $i < $strlength; $i++)
|
||||
{
|
||||
$keychar = substr($key, ($i % strlen($key))-1, 1);
|
||||
$result.= chr(ord(substr($chain, $i, 1))-(ord($keychar)-65));
|
||||
$keychar = substr($key, ($i % strlen($key)) - 1, 1);
|
||||
$result .= chr(ord(substr($chain, $i, 1)) - (ord($keychar) - 65));
|
||||
}
|
||||
$chain=$result;
|
||||
$chain = $result;
|
||||
}
|
||||
|
||||
return $chain;
|
||||
@@ -109,28 +109,28 @@ function dol_decode($chain, $key='1')
|
||||
* @param string $chain String to hash
|
||||
* @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'.
|
||||
* @return string Hash of string
|
||||
* @getRandomPassword
|
||||
* @see getRandomPassword()
|
||||
*/
|
||||
function dol_hash($chain, $type='0')
|
||||
function dol_hash($chain, $type = '0')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// No need to add salt for password_hash
|
||||
if (($type == '0' || $type == 'auto') && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash'))
|
||||
if (($type == '0' || $type == 'auto') && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash'))
|
||||
{
|
||||
return password_hash($chain, PASSWORD_DEFAULT);
|
||||
}
|
||||
|
||||
// Salt value
|
||||
if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain;
|
||||
if (!empty($conf->global->MAIN_SECURITY_SALT)) $chain = $conf->global->MAIN_SECURITY_SALT.$chain;
|
||||
|
||||
if ($type == '1' || $type == 'sha1') return sha1($chain);
|
||||
else if ($type == '2' || $type == 'sha1md5') return sha1(md5($chain));
|
||||
else if ($type == '3' || $type == 'md5') return md5($chain);
|
||||
else if ($type == '4' || $type == 'md5openldap') return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain)); // For OpenLdap with md5 (based on an unencrypted password in base)
|
||||
else if ($type == '5') return hash('sha256',$chain);
|
||||
else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain);
|
||||
else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain));
|
||||
elseif ($type == '2' || $type == 'sha1md5') return sha1(md5($chain));
|
||||
elseif ($type == '3' || $type == 'md5') return md5($chain);
|
||||
elseif ($type == '4' || $type == 'md5openldap') return '{md5}'.base64_encode(mhash(MHASH_MD5, $chain)); // For OpenLdap with md5 (based on an unencrypted password in base)
|
||||
elseif ($type == '5') return hash('sha256', $chain);
|
||||
elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain);
|
||||
elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain));
|
||||
|
||||
// No particular encoding defined, use default
|
||||
return md5($chain);
|
||||
@@ -142,19 +142,19 @@ function dol_hash($chain, $type='0')
|
||||
* If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function.
|
||||
* If constant MAIN_SECURITY_SALT is defined, we use it as a salt.
|
||||
*
|
||||
* @param string $chain String to hash
|
||||
* @param string $chain String to hash (not hashed string)
|
||||
* @param string $hash hash to compare
|
||||
* @param string $type Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'.
|
||||
* @return bool True if the computed hash is the same as the given one
|
||||
*/
|
||||
function dol_verifyHash($chain, $hash, $type='0')
|
||||
function dol_verifyHash($chain, $hash, $type = '0')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if ($type == '0' && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) {
|
||||
if ($type == '0' && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) {
|
||||
if ($hash[0] == '$') return password_verify($chain, $hash);
|
||||
else if(strlen($hash) == 32) return dol_verifyHash($chain, $hash, '3'); // md5
|
||||
else if(strlen($hash) == 40) return dol_verifyHash($chain, $hash, '2'); // sha1md5
|
||||
elseif (strlen($hash) == 32) return dol_verifyHash($chain, $hash, '3'); // md5
|
||||
elseif (strlen($hash) == 40) return dol_verifyHash($chain, $hash, '2'); // sha1md5
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -176,9 +176,9 @@ function dol_verifyHash($chain, $hash, $type='0')
|
||||
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
|
||||
* @param int $isdraft 1=The object with id=$objectid is a draft
|
||||
* @return int Always 1, die process if not allowed
|
||||
* @see dol_check_secure_access_document
|
||||
* @see dol_check_secure_access_document()
|
||||
*/
|
||||
function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
|
||||
function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid', $isdraft = 0)
|
||||
{
|
||||
global $db, $conf;
|
||||
global $hookmanager;
|
||||
@@ -189,9 +189,9 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu
|
||||
//print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."<br>";
|
||||
|
||||
// Get more permissions checks from hooks
|
||||
$parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select);
|
||||
$reshook=$hookmanager->executeHooks('restrictedArea',$parameters);
|
||||
if (! empty($hookmanager->resArray['result'])) return true;
|
||||
$parameters = array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select);
|
||||
$reshook = $hookmanager->executeHooks('restrictedArea', $parameters);
|
||||
if (!empty($hookmanager->resArray['result'])) return true;
|
||||
if ($reshook > 0) return false;
|
||||
|
||||
if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'";
|
||||
@@ -199,220 +199,231 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu
|
||||
// Features/modules to check
|
||||
$featuresarray = array($features);
|
||||
if (preg_match('/&/', $features)) $featuresarray = explode("&", $features);
|
||||
else if (preg_match('/\|/', $features)) $featuresarray = explode("|", $features);
|
||||
elseif (preg_match('/\|/', $features)) $featuresarray = explode("|", $features);
|
||||
|
||||
// More subfeatures to check
|
||||
if (! empty($feature2)) $feature2 = explode("|", $feature2);
|
||||
if (!empty($feature2)) $feature2 = explode("|", $feature2);
|
||||
|
||||
// More parameters
|
||||
$params = explode('&', $tableandshare);
|
||||
$dbtablename=(! empty($params[0]) ? $params[0] : '');
|
||||
$sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename);
|
||||
$dbtablename = (!empty($params[0]) ? $params[0] : '');
|
||||
$sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
|
||||
|
||||
$listofmodules=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL);
|
||||
$listofmodules = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
|
||||
|
||||
// Check read permission from module
|
||||
$readok=1; $nbko=0;
|
||||
$readok = 1; $nbko = 0;
|
||||
foreach ($featuresarray as $feature) // first we check nb of test ko
|
||||
{
|
||||
$featureforlistofmodule=$feature;
|
||||
if ($featureforlistofmodule == 'produit') $featureforlistofmodule='product';
|
||||
if (! empty($user->societe_id) && ! empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && ! in_array($featureforlistofmodule,$listofmodules)) // If limits on modules for external users, module must be into list of modules for external users
|
||||
$featureforlistofmodule = $feature;
|
||||
if ($featureforlistofmodule == 'produit') $featureforlistofmodule = 'product';
|
||||
if (!empty($user->socid) && !empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && !in_array($featureforlistofmodule, $listofmodules)) // If limits on modules for external users, module must be into list of modules for external users
|
||||
{
|
||||
$readok=0; $nbko++;
|
||||
$readok = 0; $nbko++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($feature == 'societe')
|
||||
{
|
||||
if (! $user->rights->societe->lire && ! $user->rights->fournisseur->lire) { $readok=0; $nbko++; }
|
||||
if (!$user->rights->societe->lire && !$user->rights->fournisseur->lire) { $readok = 0; $nbko++; }
|
||||
}
|
||||
else if ($feature == 'contact')
|
||||
elseif ($feature == 'contact')
|
||||
{
|
||||
if (! $user->rights->societe->contact->lire) { $readok=0; $nbko++; }
|
||||
if (!$user->rights->societe->contact->lire) { $readok = 0; $nbko++; }
|
||||
}
|
||||
else if ($feature == 'produit|service')
|
||||
elseif ($feature == 'produit|service')
|
||||
{
|
||||
if (! $user->rights->produit->lire && ! $user->rights->service->lire) { $readok=0; $nbko++; }
|
||||
if (!$user->rights->produit->lire && !$user->rights->service->lire) { $readok = 0; $nbko++; }
|
||||
}
|
||||
else if ($feature == 'prelevement')
|
||||
elseif ($feature == 'prelevement')
|
||||
{
|
||||
if (! $user->rights->prelevement->bons->lire) { $readok=0; $nbko++; }
|
||||
if (!$user->rights->prelevement->bons->lire) { $readok = 0; $nbko++; }
|
||||
}
|
||||
else if ($feature == 'cheque')
|
||||
elseif ($feature == 'cheque')
|
||||
{
|
||||
if (! $user->rights->banque->cheque) { $readok=0; $nbko++; }
|
||||
if (!$user->rights->banque->cheque) { $readok = 0; $nbko++; }
|
||||
}
|
||||
else if ($feature == 'projet')
|
||||
elseif ($feature == 'projet')
|
||||
{
|
||||
if (! $user->rights->projet->lire && ! $user->rights->projet->all->lire) { $readok=0; $nbko++; }
|
||||
if (!$user->rights->projet->lire && !$user->rights->projet->all->lire) { $readok = 0; $nbko++; }
|
||||
}
|
||||
else if (! empty($feature2)) // This should be used for future changes
|
||||
elseif (!empty($feature2)) // This is for permissions on 2 levels
|
||||
{
|
||||
$tmpreadok=1;
|
||||
foreach($feature2 as $subfeature)
|
||||
$tmpreadok = 1;
|
||||
foreach ($feature2 as $subfeature)
|
||||
{
|
||||
if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; }
|
||||
else if (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; }
|
||||
else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok
|
||||
if ($subfeature == 'user' && $user->id == $objectid) continue; // A user can always read its own card
|
||||
if (!empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok = 0; }
|
||||
elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok = 0; }
|
||||
else { $tmpreadok = 1; break; } // Break is to bypass second test if the first is ok
|
||||
}
|
||||
if (! $tmpreadok) // We found a test on feature that is ko
|
||||
if (!$tmpreadok) // We found a test on feature that is ko
|
||||
{
|
||||
$readok=0; // All tests are ko (we manage here the and, the or will be managed later using $nbko).
|
||||
$readok = 0; // All tests are ko (we manage here the and, the or will be managed later using $nbko).
|
||||
$nbko++;
|
||||
}
|
||||
}
|
||||
else if (! empty($feature) && ($feature!='user' && $feature!='usergroup')) // This is for old permissions
|
||||
elseif (!empty($feature) && ($feature != 'user' && $feature != 'usergroup')) // This is permissions on 1 level
|
||||
{
|
||||
if (empty($user->rights->$feature->lire)
|
||||
&& empty($user->rights->$feature->read)
|
||||
&& empty($user->rights->$feature->run)) { $readok=0; $nbko++; }
|
||||
&& empty($user->rights->$feature->run)) { $readok = 0; $nbko++; }
|
||||
}
|
||||
}
|
||||
|
||||
// If a or and at least one ok
|
||||
if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok=1;
|
||||
if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok = 1;
|
||||
|
||||
if (! $readok) accessforbidden();
|
||||
if (!$readok) accessforbidden();
|
||||
//print "Read access is ok";
|
||||
|
||||
// Check write permission from module (we need to know write permission to create but also to delete drafts record)
|
||||
$createok=1; $nbko=0;
|
||||
if (GETPOST('action','aZ09') == 'create' || ((GETPOST("action","aZ09") == 'confirm_delete' && GETPOST("confirm","aZ09") == 'yes') || GETPOST("action","aZ09") == 'delete'))
|
||||
$createok = 1; $nbko = 0;
|
||||
if (GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete'))
|
||||
{
|
||||
foreach ($featuresarray as $feature)
|
||||
{
|
||||
if ($feature == 'contact')
|
||||
{
|
||||
if (! $user->rights->societe->contact->creer) { $createok=0; $nbko++; }
|
||||
if (!$user->rights->societe->contact->creer) { $createok = 0; $nbko++; }
|
||||
}
|
||||
else if ($feature == 'produit|service')
|
||||
elseif ($feature == 'produit|service')
|
||||
{
|
||||
if (! $user->rights->produit->creer && ! $user->rights->service->creer) { $createok=0; $nbko++; }
|
||||
if (!$user->rights->produit->creer && !$user->rights->service->creer) { $createok = 0; $nbko++; }
|
||||
}
|
||||
else if ($feature == 'prelevement')
|
||||
elseif ($feature == 'prelevement')
|
||||
{
|
||||
if (! $user->rights->prelevement->bons->creer) { $createok=0; $nbko++; }
|
||||
if (!$user->rights->prelevement->bons->creer) { $createok = 0; $nbko++; }
|
||||
}
|
||||
else if ($feature == 'commande_fournisseur')
|
||||
elseif ($feature == 'commande_fournisseur')
|
||||
{
|
||||
if (! $user->rights->fournisseur->commande->creer) { $createok=0; $nbko++; }
|
||||
if (!$user->rights->fournisseur->commande->creer) { $createok = 0; $nbko++; }
|
||||
}
|
||||
else if ($feature == 'banque')
|
||||
elseif ($feature == 'banque')
|
||||
{
|
||||
if (! $user->rights->banque->modifier) { $createok=0; $nbko++; }
|
||||
if (!$user->rights->banque->modifier) { $createok = 0; $nbko++; }
|
||||
}
|
||||
else if ($feature == 'cheque')
|
||||
elseif ($feature == 'cheque')
|
||||
{
|
||||
if (! $user->rights->banque->cheque) { $createok=0; $nbko++; }
|
||||
if (!$user->rights->banque->cheque) { $createok = 0; $nbko++; }
|
||||
}
|
||||
else if (! empty($feature2)) // This should be used
|
||||
elseif (!empty($feature2)) // This is for permissions on one level
|
||||
{
|
||||
foreach($feature2 as $subfeature)
|
||||
foreach ($feature2 as $subfeature)
|
||||
{
|
||||
if (empty($user->rights->$feature->$subfeature->creer)
|
||||
&& empty($user->rights->$feature->$subfeature->write)
|
||||
&& empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; }
|
||||
else { $createok=1; break; } // Break to bypass second test if the first is ok
|
||||
&& empty($user->rights->$feature->$subfeature->write)
|
||||
&& empty($user->rights->$feature->$subfeature->create)) {
|
||||
$createok = 0;
|
||||
$nbko++;
|
||||
} else {
|
||||
$createok = 1;
|
||||
// Break to bypass second test if the first is ok
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (! empty($feature)) // This is for old permissions ('creer' or 'write')
|
||||
elseif (!empty($feature)) // This is for permissions on 2 levels ('creer' or 'write')
|
||||
{
|
||||
//print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write;
|
||||
if (empty($user->rights->$feature->creer)
|
||||
&& empty($user->rights->$feature->write)
|
||||
&& empty($user->rights->$feature->create)) { $createok=0; $nbko++; }
|
||||
&& empty($user->rights->$feature->write)
|
||||
&& empty($user->rights->$feature->create)) {
|
||||
$createok = 0;
|
||||
$nbko++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If a or and at least one ok
|
||||
if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1;
|
||||
if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok = 1;
|
||||
|
||||
if (GETPOST('action','aZ09') == 'create' && ! $createok) accessforbidden();
|
||||
if ((GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update') && !$createok) accessforbidden();
|
||||
//print "Write access is ok";
|
||||
}
|
||||
|
||||
// Check create user permission
|
||||
$createuserok=1;
|
||||
if (GETPOST('action','aZ09') == 'confirm_create_user' && GETPOST("confirm",'aZ09') == 'yes')
|
||||
$createuserok = 1;
|
||||
if (GETPOST('action', 'aZ09') == 'confirm_create_user' && GETPOST("confirm", 'aZ09') == 'yes')
|
||||
{
|
||||
if (! $user->rights->user->user->creer) $createuserok=0;
|
||||
if (!$user->rights->user->user->creer) $createuserok = 0;
|
||||
|
||||
if (! $createuserok) accessforbidden();
|
||||
if (!$createuserok) accessforbidden();
|
||||
//print "Create user access is ok";
|
||||
}
|
||||
|
||||
// Check delete permission from module
|
||||
$deleteok=1; $nbko=0;
|
||||
if ((GETPOST("action","aZ09") == 'confirm_delete' && GETPOST("confirm","aZ09") == 'yes') || GETPOST("action","aZ09") == 'delete')
|
||||
$deleteok = 1; $nbko = 0;
|
||||
if ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete')
|
||||
{
|
||||
foreach ($featuresarray as $feature)
|
||||
{
|
||||
if ($feature == 'contact')
|
||||
{
|
||||
if (! $user->rights->societe->contact->supprimer) $deleteok=0;
|
||||
if (!$user->rights->societe->contact->supprimer) $deleteok = 0;
|
||||
}
|
||||
else if ($feature == 'produit|service')
|
||||
elseif ($feature == 'produit|service')
|
||||
{
|
||||
if (! $user->rights->produit->supprimer && ! $user->rights->service->supprimer) $deleteok=0;
|
||||
if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) $deleteok = 0;
|
||||
}
|
||||
else if ($feature == 'commande_fournisseur')
|
||||
elseif ($feature == 'commande_fournisseur')
|
||||
{
|
||||
if (! $user->rights->fournisseur->commande->supprimer) $deleteok=0;
|
||||
if (!$user->rights->fournisseur->commande->supprimer) $deleteok = 0;
|
||||
}
|
||||
else if ($feature == 'banque')
|
||||
elseif ($feature == 'banque')
|
||||
{
|
||||
if (! $user->rights->banque->modifier) $deleteok=0;
|
||||
if (!$user->rights->banque->modifier) $deleteok = 0;
|
||||
}
|
||||
else if ($feature == 'cheque')
|
||||
elseif ($feature == 'cheque')
|
||||
{
|
||||
if (! $user->rights->banque->cheque) $deleteok=0;
|
||||
if (!$user->rights->banque->cheque) $deleteok = 0;
|
||||
}
|
||||
else if ($feature == 'ecm')
|
||||
elseif ($feature == 'ecm')
|
||||
{
|
||||
if (! $user->rights->ecm->upload) $deleteok=0;
|
||||
if (!$user->rights->ecm->upload) $deleteok = 0;
|
||||
}
|
||||
else if ($feature == 'ftp')
|
||||
elseif ($feature == 'ftp')
|
||||
{
|
||||
if (! $user->rights->ftp->write) $deleteok=0;
|
||||
}else if ($feature == 'salaries')
|
||||
if (!$user->rights->ftp->write) $deleteok = 0;
|
||||
}elseif ($feature == 'salaries')
|
||||
{
|
||||
if (! $user->rights->salaries->delete) $deleteok=0;
|
||||
if (!$user->rights->salaries->delete) $deleteok = 0;
|
||||
}
|
||||
else if ($feature == 'salaries')
|
||||
elseif ($feature == 'salaries')
|
||||
{
|
||||
if (! $user->rights->salaries->delete) $deleteok=0;
|
||||
if (!$user->rights->salaries->delete) $deleteok = 0;
|
||||
}
|
||||
else if (! empty($feature2)) // This should be used for permissions on 2 levels
|
||||
elseif (!empty($feature2)) // This is for permissions on 2 levels
|
||||
{
|
||||
foreach($feature2 as $subfeature)
|
||||
foreach ($feature2 as $subfeature)
|
||||
{
|
||||
if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0;
|
||||
else { $deleteok=1; break; } // For bypass the second test if the first is ok
|
||||
if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok = 0;
|
||||
else { $deleteok = 1; break; } // For bypass the second test if the first is ok
|
||||
}
|
||||
}
|
||||
else if (! empty($feature)) // This is used for permissions on 1 level
|
||||
elseif (!empty($feature)) // This is used for permissions on 1 level
|
||||
{
|
||||
//print '<br>feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete;
|
||||
if (empty($user->rights->$feature->supprimer)
|
||||
&& empty($user->rights->$feature->delete)
|
||||
&& empty($user->rights->$feature->run)) $deleteok=0;
|
||||
&& empty($user->rights->$feature->run)) $deleteok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// If a or and at least one ok
|
||||
if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok=1;
|
||||
if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok = 1;
|
||||
|
||||
if (! $deleteok && ! ($isdraft && $createok)) accessforbidden();
|
||||
if (!$deleteok && !($isdraft && $createok)) accessforbidden();
|
||||
//print "Delete access is ok";
|
||||
}
|
||||
|
||||
// If we have a particular object to check permissions on, we check this object
|
||||
// is linked to a company allowed to $user.
|
||||
if (! empty($objectid) && $objectid > 0)
|
||||
if (!empty($objectid) && $objectid > 0)
|
||||
{
|
||||
$ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select);
|
||||
return $ok ? 1 : accessforbidden();
|
||||
$params = array('objectid' => $objectid, 'features' => join(',', $featuresarray), 'features2' => $feature2);
|
||||
return $ok ? 1 : accessforbidden('', 1, 1, 0, $params);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -430,76 +441,76 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu
|
||||
* @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
|
||||
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
|
||||
* @return bool True if user has access, False otherwise
|
||||
* @see restrictedArea
|
||||
* @see restrictedArea()
|
||||
*/
|
||||
function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='', $dbt_select='rowid')
|
||||
function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableandshare = '', $feature2 = '', $dbt_keyfield = '', $dbt_select = 'rowid')
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
// More parameters
|
||||
$params = explode('&', $tableandshare);
|
||||
$dbtablename=(! empty($params[0]) ? $params[0] : '');
|
||||
$sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename);
|
||||
$dbtablename = (!empty($params[0]) ? $params[0] : '');
|
||||
$sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);
|
||||
|
||||
foreach ($featuresarray as $feature)
|
||||
{
|
||||
$sql='';
|
||||
$sql = '';
|
||||
|
||||
// For backward compatibility
|
||||
if ($feature == 'member') $feature='adherent';
|
||||
if ($feature == 'project') $feature='projet';
|
||||
if ($feature == 'task') $feature='projet_task';
|
||||
if ($feature == 'member') $feature = 'adherent';
|
||||
if ($feature == 'project') $feature = 'projet';
|
||||
if ($feature == 'task') $feature = 'projet_task';
|
||||
|
||||
$check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company)
|
||||
$checksoc = array('societe'); // Test for societe object
|
||||
$checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...).
|
||||
$checkproject = array('projet','project'); // Test for project object
|
||||
$check = array('adherent', 'banque', 'bom', 'don', 'user', 'usergroup', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday'); // Test on entity only (Objects with no link to company)
|
||||
$checksoc = array('societe'); // Test for societe object
|
||||
$checkother = array('contact', 'agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...).
|
||||
$checkproject = array('projet', 'project'); // Test for project object
|
||||
$checktask = array('projet_task');
|
||||
$nocheck = array('barcode','stock'); // No test
|
||||
$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...).
|
||||
$nocheck = array('barcode', 'stock'); // No test
|
||||
//$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...).
|
||||
|
||||
// If dbtablename not defined, we use same name for table than module name
|
||||
if (empty($dbtablename))
|
||||
{
|
||||
$dbtablename = $feature;
|
||||
$sharedelement = (! empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too.
|
||||
$sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too.
|
||||
}
|
||||
|
||||
// Check permission for object with entity
|
||||
if (in_array($feature,$check))
|
||||
if (in_array($feature, $check))
|
||||
{
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled))
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
if (($feature == 'user' || $feature == 'usergroup') && !empty($conf->multicompany->enabled))
|
||||
{
|
||||
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
if ($conf->entity == 1 && $user->admin && ! $user->entity)
|
||||
if ($conf->entity == 1 && $user->admin && !$user->entity)
|
||||
{
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.entity IS NOT NULL";
|
||||
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql .= " AND dbt.entity IS NOT NULL";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND (ug.fk_user = dbt.rowid";
|
||||
$sql.= " AND ug.entity IN (".getEntity('user')."))";
|
||||
$sql.= " OR dbt.entity = 0"; // Show always superadmin
|
||||
$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql .= " AND ((ug.fk_user = dbt.rowid";
|
||||
$sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
|
||||
$sql .= " OR dbt.entity = 0)"; // Show always superadmin
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
else if (in_array($feature,$checksoc)) // We check feature = checksoc
|
||||
elseif (in_array($feature, $checksoc)) // We check feature = checksoc
|
||||
{
|
||||
// If external user: Check permission for external users
|
||||
if ($user->socid > 0)
|
||||
@@ -507,135 +518,135 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
|
||||
if ($user->socid <> $objectid) return false;
|
||||
}
|
||||
// If internal user: Check permission for internal users that are restricted on their objects
|
||||
else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
|
||||
elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir))
|
||||
{
|
||||
$sql = "SELECT COUNT(sc.fk_soc) as nb";
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s)";
|
||||
$sql.= " WHERE sc.fk_soc IN (".$objectid.")";
|
||||
$sql.= " AND sc.fk_user = ".$user->id;
|
||||
$sql.= " AND sc.fk_soc = s.rowid";
|
||||
$sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql .= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe as s)";
|
||||
$sql .= " WHERE sc.fk_soc IN (".$objectid.")";
|
||||
$sql .= " AND sc.fk_user = ".$user->id;
|
||||
$sql .= " AND sc.fk_soc = s.rowid";
|
||||
$sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
// If multicompany and internal users with all permissions, check user is in correct entity
|
||||
else if (! empty($conf->multicompany->enabled))
|
||||
elseif (!empty($conf->multicompany->enabled))
|
||||
{
|
||||
$sql = "SELECT COUNT(s.rowid) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= " WHERE s.rowid IN (".$objectid.")";
|
||||
$sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= " WHERE s.rowid IN (".$objectid.")";
|
||||
$sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
else if (in_array($feature,$checkother)) // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
|
||||
elseif (in_array($feature, $checkother)) // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
|
||||
{
|
||||
// If external user: Check permission for external users
|
||||
if ($user->socid > 0)
|
||||
{
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.fk_soc = ".$user->socid;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql .= " AND dbt.fk_soc = ".$user->socid;
|
||||
}
|
||||
// If internal user: Check permission for internal users that are restricted on their objects
|
||||
else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
|
||||
elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir))
|
||||
{
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '".$user->id."'";
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '".$user->id."'";
|
||||
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql .= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user
|
||||
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
// If multicompany and internal users with all permissions, check user is in correct entity
|
||||
else if (! empty($conf->multicompany->enabled))
|
||||
elseif (!empty($conf->multicompany->enabled))
|
||||
{
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
else if (in_array($feature,$checkproject))
|
||||
elseif (in_array($feature, $checkproject))
|
||||
{
|
||||
if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
|
||||
if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$projectstatic=new Project($db);
|
||||
$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
|
||||
$tmparray=explode(',',$tmps);
|
||||
if (! in_array($objectid,$tmparray)) return false;
|
||||
$projectstatic = new Project($db);
|
||||
$tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
|
||||
$tmparray = explode(',', $tmps);
|
||||
if (!in_array($objectid, $tmparray)) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
else if (in_array($feature,$checktask))
|
||||
elseif (in_array($feature, $checktask))
|
||||
{
|
||||
if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
|
||||
if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
|
||||
{
|
||||
$task = new Task($db);
|
||||
$task->fetch($objectid);
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$projectstatic=new Project($db);
|
||||
$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
|
||||
$tmparray=explode(',',$tmps);
|
||||
if (! in_array($task->fk_project,$tmparray)) return false;
|
||||
$projectstatic = new Project($db);
|
||||
$tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
|
||||
$tmparray = explode(',', $tmps);
|
||||
if (!in_array($task->fk_project, $tmparray)) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
else if (! in_array($feature,$nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
|
||||
elseif (!in_array($feature, $nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
|
||||
{
|
||||
// If external user: Check permission for external users
|
||||
if ($user->socid > 0)
|
||||
{
|
||||
if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined');
|
||||
if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined');
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.rowid IN (".$objectid.")";
|
||||
$sql.= " AND dbt.".$dbt_keyfield." = ".$user->socid;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql .= " WHERE dbt.rowid IN (".$objectid.")";
|
||||
$sql .= " AND dbt.".$dbt_keyfield." = ".$user->socid;
|
||||
}
|
||||
// If internal user: Check permission for internal users that are restricted on their objects
|
||||
else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir))
|
||||
elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir))
|
||||
{
|
||||
if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined');
|
||||
if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined');
|
||||
$sql = "SELECT COUNT(sc.fk_soc) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND sc.fk_soc = dbt.".$dbt_keyfield;
|
||||
$sql.= " AND dbt.".$dbt_keyfield." = s.rowid";
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql.= " AND sc.fk_user = ".$user->id;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql .= " AND sc.fk_soc = dbt.".$dbt_keyfield;
|
||||
$sql .= " AND dbt.".$dbt_keyfield." = s.rowid";
|
||||
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql .= " AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
// If multicompany and internal users with all permissions, check user is in correct entity
|
||||
else if (! empty($conf->multicompany->enabled))
|
||||
elseif (!empty($conf->multicompany->enabled))
|
||||
{
|
||||
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
|
||||
if ($sql)
|
||||
{
|
||||
$resql=$db->query($sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if (! $obj || $obj->nb < count(explode(',', $objectid))) return false;
|
||||
if (!$obj || $obj->nb < count(explode(',', $objectid))) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -650,19 +661,20 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
|
||||
* Show a message to say access is forbidden and stop program
|
||||
* Calling this function terminate execution of PHP.
|
||||
*
|
||||
* @param string $message Force error message
|
||||
* @param int $printheader Show header before
|
||||
* @param int $printfooter Show footer after
|
||||
* @param int $showonlymessage Show only message parameter. Otherwise add more information.
|
||||
* @param string $message Force error message
|
||||
* @param int $printheader Show header before
|
||||
* @param int $printfooter Show footer after
|
||||
* @param int $showonlymessage Show only message parameter. Otherwise add more information.
|
||||
* @param array|null $params Send params
|
||||
* @return void
|
||||
*/
|
||||
function accessforbidden($message='',$printheader=1,$printfooter=1,$showonlymessage=0)
|
||||
function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null)
|
||||
{
|
||||
global $conf, $db, $user, $langs;
|
||||
if (! is_object($langs))
|
||||
global $conf, $db, $user, $langs, $hookmanager;
|
||||
if (!is_object($langs))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
|
||||
$langs=new Translate('',$conf);
|
||||
$langs = new Translate('', $conf);
|
||||
$langs->setDefaultLang();
|
||||
}
|
||||
|
||||
@@ -671,23 +683,36 @@ function accessforbidden($message='',$printheader=1,$printfooter=1,$showonlymess
|
||||
if ($printheader)
|
||||
{
|
||||
if (function_exists("llxHeader")) llxHeader('');
|
||||
else if (function_exists("llxHeaderVierge")) llxHeaderVierge('');
|
||||
elseif (function_exists("llxHeaderVierge")) llxHeaderVierge('');
|
||||
}
|
||||
print '<div class="error">';
|
||||
if (! $message) print $langs->trans("ErrorForbidden");
|
||||
if (!$message) print $langs->trans("ErrorForbidden");
|
||||
else print $message;
|
||||
print '</div>';
|
||||
print '<br>';
|
||||
if (empty($showonlymessage))
|
||||
{
|
||||
if ($user->login)
|
||||
global $action, $object;
|
||||
if (empty($hookmanager))
|
||||
{
|
||||
print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>';
|
||||
print $langs->trans("ErrorForbidden2",$langs->trans("Home"),$langs->trans("Users"));
|
||||
$hookmanager = new HookManager($db);
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('main'));
|
||||
}
|
||||
else
|
||||
$parameters = array('message'=>$message, 'params'=>$params);
|
||||
$reshook = $hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook))
|
||||
{
|
||||
print $langs->trans("ErrorForbidden3");
|
||||
if ($user->login)
|
||||
{
|
||||
print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>';
|
||||
print $langs->trans("ErrorForbidden2", $langs->transnoentitiesnoconv("Home"), $langs->transnoentitiesnoconv("Users"));
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ErrorForbidden3");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($printfooter && function_exists("llxFooter")) llxFooter();
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -47,9 +47,10 @@ function dol_getwebuser($mode)
|
||||
* @param string $passwordtotest Password value to test
|
||||
* @param string $entitytotest Instance of data we must check
|
||||
* @param array $authmode Array list of selected authentication mode array('http', 'dolibarr', 'xxx'...)
|
||||
* @param string $context Context checkLoginPassEntity was created for ('api', 'dav', 'ws', '')
|
||||
* @return string Login or ''
|
||||
*/
|
||||
function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmode)
|
||||
function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode, $context = '')
|
||||
{
|
||||
global $conf,$langs;
|
||||
//global $dolauthmode; // To return authentication finally used
|
||||
@@ -57,7 +58,7 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod
|
||||
// Check parameters
|
||||
if ($entitytotest == '') $entitytotest=1;
|
||||
|
||||
dol_syslog("checkLoginPassEntity usertotest=".$usertotest." entitytotest=".$entitytotest." authmode=".join(',',$authmode));
|
||||
dol_syslog("checkLoginPassEntity usertotest=".$usertotest." entitytotest=".$entitytotest." authmode=".join(',', $authmode));
|
||||
$login = '';
|
||||
|
||||
// Validation of login/pass/entity with standard modules
|
||||
@@ -73,14 +74,14 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod
|
||||
$authfile='functions_'.$mode.'.php';
|
||||
$fullauthfile='';
|
||||
|
||||
$dirlogin=array_merge(array("/core/login"),(array) $conf->modules_parts['login']);
|
||||
$dirlogin=array_merge(array("/core/login"), (array) $conf->modules_parts['login']);
|
||||
foreach($dirlogin as $reldir)
|
||||
{
|
||||
$dir=dol_buildpath($reldir,0);
|
||||
$dir=dol_buildpath($reldir, 0);
|
||||
$newdir=dol_osencode($dir);
|
||||
|
||||
// Check if file found (do not use dol_is_file to avoid loading files.lib.php)
|
||||
$tmpnewauthfile = $newdir.(preg_match('/\/$/',$newdir)?'':'/').$authfile;
|
||||
$tmpnewauthfile = $newdir.(preg_match('/\/$/', $newdir)?'':'/').$authfile;
|
||||
if (is_file($tmpnewauthfile)) $fullauthfile=$tmpnewauthfile;
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod
|
||||
{
|
||||
// Call function to check user/password
|
||||
$function='check_user_password_'.$mode;
|
||||
$login=call_user_func($function, $usertotest, $passwordtotest, $entitytotest);
|
||||
$login=call_user_func($function, $usertotest, $passwordtotest, $entitytotest, $context);
|
||||
if ($login) // Login is successfull
|
||||
{
|
||||
$test=false; // To stop once at first login success
|
||||
@@ -129,10 +130,10 @@ if (! function_exists('dol_loginfunction'))
|
||||
* @param Societe $mysoc Company object
|
||||
* @return void
|
||||
*/
|
||||
function dol_loginfunction($langs,$conf,$mysoc)
|
||||
function dol_loginfunction($langs, $conf, $mysoc)
|
||||
{
|
||||
global $dolibarr_main_demo,$db;
|
||||
global $smartphone,$hookmanager;
|
||||
global $dolibarr_main_demo, $db;
|
||||
global $hookmanager;
|
||||
|
||||
$langs->loadLangs(array("main","other","help","admin"));
|
||||
|
||||
@@ -172,11 +173,11 @@ if (! function_exists('dol_loginfunction'))
|
||||
// Select templates dir
|
||||
if (! empty($conf->modules_parts['tpl'])) // Using this feature slow down application
|
||||
{
|
||||
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl/'));
|
||||
$dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl/'));
|
||||
foreach($dirtpls as $reldir)
|
||||
{
|
||||
$tmp=dol_buildpath($reldir.'login.tpl.php');
|
||||
if (file_exists($tmp)) { $template_dir=preg_replace('/login\.tpl\.php$/','',$tmp); break; }
|
||||
if (file_exists($tmp)) { $template_dir=preg_replace('/login\.tpl\.php$/', '', $tmp); break; }
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -189,37 +190,33 @@ if (! function_exists('dol_loginfunction'))
|
||||
$sessiontimeout='DOLSESSTIMEOUT_'.$prefix;
|
||||
if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, false, true);
|
||||
|
||||
if (GETPOST('urlfrom','alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom','alpha');
|
||||
if (GETPOST('urlfrom', 'alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom', 'alpha');
|
||||
else unset($_SESSION["urlfrom"]);
|
||||
|
||||
if (! GETPOST("username",'alpha')) $focus_element='username';
|
||||
if (! GETPOST("username", 'alpha')) $focus_element='username';
|
||||
else $focus_element='password';
|
||||
|
||||
$demologin='';
|
||||
$demopassword='';
|
||||
if (! empty($dolibarr_main_demo))
|
||||
{
|
||||
$tab=explode(',',$dolibarr_main_demo);
|
||||
$tab=explode(',', $dolibarr_main_demo);
|
||||
$demologin=$tab[0];
|
||||
$demopassword=$tab[1];
|
||||
}
|
||||
|
||||
// Execute hook getLoginPageOptions (for table)
|
||||
$parameters=array('entity' => GETPOST('entity','int'));
|
||||
$reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks.
|
||||
if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) {
|
||||
$morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility
|
||||
} else {
|
||||
$morelogincontent = $hookmanager->resPrint;
|
||||
}
|
||||
$parameters=array('entity' => GETPOST('entity', 'int'));
|
||||
$reshook = $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
|
||||
$morelogincontent = $hookmanager->resPrint;
|
||||
|
||||
// Execute hook getLoginPageExtraOptions (eg for js)
|
||||
$parameters=array('entity' => GETPOST('entity','int'));
|
||||
$reshook = $hookmanager->executeHooks('getLoginPageExtraOptions',$parameters); // Note that $action and $object may have been modified by some hooks.
|
||||
$parameters=array('entity' => GETPOST('entity', 'int'));
|
||||
$reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
|
||||
$moreloginextracontent = $hookmanager->resPrint;
|
||||
|
||||
// Login
|
||||
$login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username","alpha") ? GETPOST("username","alpha") : $demologin));
|
||||
$login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin));
|
||||
$password = $demopassword;
|
||||
|
||||
// Show logo (search in order: small company logo, large company logo, theme logo, common logo)
|
||||
@@ -250,7 +247,7 @@ if (! function_exists('dol_loginfunction'))
|
||||
if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA))
|
||||
{
|
||||
$captcha=1;
|
||||
$captcha_refresh=img_picto($langs->trans("Refresh"),'refresh','id="captcha_refresh_img"');
|
||||
$captcha_refresh=img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"');
|
||||
}
|
||||
|
||||
// Extra link
|
||||
@@ -285,17 +282,20 @@ if (! function_exists('dol_loginfunction'))
|
||||
|
||||
// Set jquery theme
|
||||
$dol_loginmesg = (! empty($_SESSION["dol_loginmesg"])?$_SESSION["dol_loginmesg"]:'');
|
||||
$favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1);
|
||||
|
||||
$favicon = DOL_URL_ROOT.'/theme/common/dolibarr_logo_256x256.png';
|
||||
if (! empty($mysoc->logo_squarred_mini)) $favicon = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini);
|
||||
if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL;
|
||||
|
||||
$jquerytheme = 'base';
|
||||
if (! empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME;
|
||||
|
||||
// Set dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, dol_no_mouse_hover
|
||||
$dol_hide_topmenu=GETPOST('dol_hide_topmenu','int');
|
||||
$dol_hide_leftmenu=GETPOST('dol_hide_leftmenu','int');
|
||||
$dol_optimize_smallscreen=GETPOST('dol_optimize_smallscreen','int');
|
||||
$dol_no_mouse_hover=GETPOST('dol_no_mouse_hover','int');
|
||||
$dol_use_jmobile=GETPOST('dol_use_jmobile','int');
|
||||
$dol_hide_topmenu=GETPOST('dol_hide_topmenu', 'int');
|
||||
$dol_hide_leftmenu=GETPOST('dol_hide_leftmenu', 'int');
|
||||
$dol_optimize_smallscreen=GETPOST('dol_optimize_smallscreen', 'int');
|
||||
$dol_no_mouse_hover=GETPOST('dol_no_mouse_hover', 'int');
|
||||
$dol_use_jmobile=GETPOST('dol_use_jmobile', 'int');
|
||||
|
||||
// Include login page template
|
||||
include $template_dir.'login.tpl.php';
|
||||
@@ -313,7 +313,7 @@ if (! function_exists('dol_loginfunction'))
|
||||
* non defini=>renvoi un salt pour cryptage par defaut
|
||||
* @return string Salt string
|
||||
*/
|
||||
function makesalt($type=CRYPT_SALT_LENGTH)
|
||||
function makesalt($type = CRYPT_SALT_LENGTH)
|
||||
{
|
||||
dol_syslog("makesalt type=".$type);
|
||||
switch($type)
|
||||
@@ -327,7 +327,7 @@ function makesalt($type=CRYPT_SALT_LENGTH)
|
||||
$saltlen=2; $saltprefix=''; $saltsuffix=''; break;
|
||||
}
|
||||
$salt='';
|
||||
while(dol_strlen($salt) < $saltlen) $salt.=chr(mt_rand(64,126));
|
||||
while(dol_strlen($salt) < $saltlen) $salt.=chr(mt_rand(64, 126));
|
||||
|
||||
$result=$saltprefix.$salt.$saltsuffix;
|
||||
dol_syslog("makesalt return=".$result);
|
||||
@@ -340,26 +340,26 @@ function makesalt($type=CRYPT_SALT_LENGTH)
|
||||
* @param int $level Encode level: 0 no encoding, 1 encoding
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function encodedecode_dbpassconf($level=0)
|
||||
function encodedecode_dbpassconf($level = 0)
|
||||
{
|
||||
dol_syslog("encodedecode_dbpassconf level=".$level, LOG_DEBUG);
|
||||
$config = '';
|
||||
$passwd='';
|
||||
$passwd_crypted='';
|
||||
|
||||
if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php','r'))
|
||||
if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php', 'r'))
|
||||
{
|
||||
while(!feof($fp))
|
||||
{
|
||||
$buffer = fgets($fp,4096);
|
||||
$buffer = fgets($fp, 4096);
|
||||
|
||||
$lineofpass=0;
|
||||
|
||||
if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i',$buffer,$reg)) // Old way to save crypted value
|
||||
if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) // Old way to save crypted value
|
||||
{
|
||||
$val = trim($reg[1]); // This also remove CR/LF
|
||||
$val=preg_replace('/^["\']/','',$val);
|
||||
$val=preg_replace('/["\'][\s;]*$/','',$val);
|
||||
$val=preg_replace('/^["\']/', '', $val);
|
||||
$val=preg_replace('/["\'][\s;]*$/', '', $val);
|
||||
if (! empty($val))
|
||||
{
|
||||
$passwd_crypted = $val;
|
||||
@@ -368,14 +368,14 @@ function encodedecode_dbpassconf($level=0)
|
||||
$lineofpass=1;
|
||||
}
|
||||
}
|
||||
elseif (preg_match('/^[^#]*dolibarr_main_db_pass[\s]*=[\s]*(.*)/i',$buffer,$reg))
|
||||
elseif (preg_match('/^[^#]*dolibarr_main_db_pass[\s]*=[\s]*(.*)/i', $buffer, $reg))
|
||||
{
|
||||
$val = trim($reg[1]); // This also remove CR/LF
|
||||
$val=preg_replace('/^["\']/','',$val);
|
||||
$val=preg_replace('/["\'][\s;]*$/','',$val);
|
||||
if (preg_match('/crypted:/i',$buffer))
|
||||
$val=preg_replace('/^["\']/', '', $val);
|
||||
$val=preg_replace('/["\'][\s;]*$/', '', $val);
|
||||
if (preg_match('/crypted:/i', $buffer))
|
||||
{
|
||||
$val = preg_replace('/crypted:/i','',$val);
|
||||
$val = preg_replace('/crypted:/i', '', $val);
|
||||
$passwd_crypted = $val;
|
||||
$val = dol_decode($val);
|
||||
$passwd = $val;
|
||||
@@ -414,7 +414,7 @@ function encodedecode_dbpassconf($level=0)
|
||||
|
||||
// Write new conf file
|
||||
$file=DOL_DOCUMENT_ROOT.'/conf/conf.php';
|
||||
if ($fp = @fopen($file,'w'))
|
||||
if ($fp = @fopen($file, 'w'))
|
||||
{
|
||||
fputs($fp, $config);
|
||||
fflush($fp);
|
||||
@@ -443,18 +443,19 @@ function encodedecode_dbpassconf($level=0)
|
||||
/**
|
||||
* Return a generated password using default module
|
||||
*
|
||||
* @param boolean $generic true=Create generic password (32 chars/numbers), false=Use the configured password generation module
|
||||
* @return string New value for password
|
||||
* @see dol_hash
|
||||
* @param boolean $generic true=Create generic password (32 chars/numbers), false=Use the configured password generation module
|
||||
* @param array $replaceambiguouschars Discard ambigous characters. For example array('I').
|
||||
* @param int $length Length of random string (Used only if $generic is true)
|
||||
* @return string New value for password
|
||||
* @see dol_hash()
|
||||
*/
|
||||
function getRandomPassword($generic=false)
|
||||
function getRandomPassword($generic = false, $replaceambiguouschars = null, $length = 32)
|
||||
{
|
||||
global $db,$conf,$langs,$user;
|
||||
|
||||
$generated_password='';
|
||||
if ($generic)
|
||||
{
|
||||
$length = 32;
|
||||
$lowercase = "qwertyuiopasdfghjklzxcvbnm";
|
||||
$uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP";
|
||||
$numbers = "1234567890";
|
||||
@@ -497,16 +498,31 @@ function getRandomPassword($generic=false)
|
||||
$generated_password=str_shuffle($randomCode);
|
||||
}
|
||||
}
|
||||
else if (! empty($conf->global->USER_PASSWORD_GENERATED))
|
||||
elseif (! empty($conf->global->USER_PASSWORD_GENERATED))
|
||||
{
|
||||
$nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
|
||||
$nomfichier=$nomclass.".class.php";
|
||||
//print DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomclass;
|
||||
require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier;
|
||||
$genhandler=new $nomclass($db,$conf,$langs,$user);
|
||||
$genhandler=new $nomclass($db, $conf, $langs, $user);
|
||||
$generated_password=$genhandler->getNewGeneratedPassword();
|
||||
unset($genhandler);
|
||||
}
|
||||
|
||||
// Do we have to discard some alphabetic characters ?
|
||||
if (is_array($replaceambiguouschars) && count($replaceambiguouschars) > 0)
|
||||
{
|
||||
$numbers = "ABCDEF";
|
||||
$max = strlen($numbers) - 1;
|
||||
if (function_exists('random_int')) // Cryptographic random
|
||||
{
|
||||
$generated_password=str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password);
|
||||
}
|
||||
else
|
||||
{
|
||||
$generated_password=str_replace($replaceambiguouschars, $numbers{mt_rand(0, $max)}, $generated_password);
|
||||
}
|
||||
}
|
||||
|
||||
return $generated_password;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -50,8 +50,8 @@ function shipping_prepare_head($object)
|
||||
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)
|
||||
{
|
||||
// delivery link
|
||||
$object->fetchObjectLinked($object->id,$object->element);
|
||||
if (count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery
|
||||
$object->fetchObjectLinked($object->id, $object->element);
|
||||
if (is_array($object->linkedObjectsIds['delivery']) && count($object->linkedObjectsIds['delivery']) > 0) // If there is a delivery
|
||||
{
|
||||
// Take first one element of array
|
||||
$tmp = reset($object->linkedObjectsIds['delivery']);
|
||||
@@ -71,10 +71,10 @@ function shipping_prepare_head($object)
|
||||
$objectsrc = new Commande($db);
|
||||
$objectsrc->fetch($object->origin_id);
|
||||
}
|
||||
$nbContact = count($objectsrc->liste_contact(-1,'internal')) + count($objectsrc->liste_contact(-1,'external'));
|
||||
$nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans("ContactsAddresses");
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
@@ -82,11 +82,11 @@ function shipping_prepare_head($object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -95,7 +95,7 @@ function shipping_prepare_head($object)
|
||||
if (!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans("Notes");
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
|
||||
@@ -103,9 +103,9 @@ function shipping_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -158,9 +158,9 @@ function delivery_prepare_head($object)
|
||||
$tmpObjectId = $object->id;
|
||||
$object->id = $object->origin_id;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'delivery','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery', 'remove');
|
||||
|
||||
$object->id = $tmpObjectId;
|
||||
return $head;
|
||||
@@ -174,9 +174,9 @@ function delivery_prepare_head($object)
|
||||
* @param string $filter Filter
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function show_list_sending_receive($origin,$origin_id,$filter='')
|
||||
function show_list_sending_receive($origin, $origin_id, $filter = '')
|
||||
{
|
||||
global $db, $conf, $langs, $bc;
|
||||
global $db, $conf, $langs;
|
||||
global $form;
|
||||
|
||||
$product_static=new Product($db);
|
||||
@@ -215,14 +215,14 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
|
||||
if ($filter) print load_fiche_titre($langs->trans("OtherSendingsForSameOrder"));
|
||||
else print load_fiche_titre($langs->trans("SendingsAndReceivingForSameOrder"));
|
||||
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<table class="liste centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
//print '<td align="left">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td align="left">'.$langs->trans("SendingSheet").'</td>';
|
||||
print '<td align="left">'.$langs->trans("Description").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateCreation").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateDeliveryPlanned").'</td>';
|
||||
print '<td align="center">'.$langs->trans("QtyPreparedOrShipped").'</td>';
|
||||
//print '<td class="left">'.$langs->trans("QtyOrdered").'</td>';
|
||||
print '<td>'.$langs->trans("SendingSheet").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td class="center">'.$langs->trans("DateCreation").'</td>';
|
||||
print '<td class="center">'.$langs->trans("DateDeliveryPlanned").'</td>';
|
||||
print '<td class="center">'.$langs->trans("QtyPreparedOrShipped").'</td>';
|
||||
if (! empty($conf->stock->enabled))
|
||||
{
|
||||
print '<td>'.$langs->trans("Warehouse").'</td>';
|
||||
@@ -236,8 +236,8 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
|
||||
if (! empty($conf->livraison_bon->enabled))
|
||||
{
|
||||
print '<td>'.$langs->trans("DeliveryOrder").'</td>';
|
||||
//print '<td align="center">'.$langs->trans("QtyReceived").'</td>';
|
||||
print '<td align="right">'.$langs->trans("DeliveryDate").'</td>';
|
||||
//print '<td class="center">'.$langs->trans("QtyReceived").'</td>';
|
||||
print '<td class="right">'.$langs->trans("DeliveryDate").'</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
@@ -248,8 +248,8 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Sending id
|
||||
print '<td align="left" class="nowrap">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->exp_ref.'<a>';
|
||||
print '<td class="nowrap left">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/expedition/card.php?id='.$objp->expedition_id.'">'.img_object($langs->trans("ShowSending"), 'sending').' '.$objp->exp_ref.'<a>';
|
||||
print '</td>';
|
||||
|
||||
// Description
|
||||
@@ -272,7 +272,7 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
|
||||
if (empty($newlang)) $newlang=$object->thirdparty->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
@@ -293,10 +293,10 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$label;
|
||||
$description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description));
|
||||
print $form->textwithtooltip($text,$description,3,'','',$i);
|
||||
print $form->textwithtooltip($text, $description, 3, '', '', $i);
|
||||
|
||||
// Show range
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
print_date_range($objp->date_start, $objp->date_end);
|
||||
|
||||
// Add description in form
|
||||
if (! empty($conf->global->PRODUIT_DESC_IN_FORM))
|
||||
@@ -309,31 +309,31 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
|
||||
else
|
||||
{
|
||||
print "<td>";
|
||||
if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'), 'service');
|
||||
else $text = img_object($langs->trans('Product'), 'product');
|
||||
|
||||
if (! empty($objp->label)) {
|
||||
$text.= ' <strong>'.$objp->label.'</strong>';
|
||||
print $form->textwithtooltip($text,$objp->description,3,'','',$i);
|
||||
print $form->textwithtooltip($text, $objp->description, 3, '', '', $i);
|
||||
} else {
|
||||
print $text.' '.nl2br($objp->description);
|
||||
}
|
||||
|
||||
// Show range
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
print_date_range($objp->date_start, $objp->date_end);
|
||||
print "</td>\n";
|
||||
}
|
||||
|
||||
//print '<td align="center">'.$objp->qty_asked.'</td>';
|
||||
//print '<td class="center">'.$objp->qty_asked.'</td>';
|
||||
|
||||
// Date creation
|
||||
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_creation),'day').'</td>';
|
||||
print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->date_creation), 'day').'</td>';
|
||||
|
||||
// Date shipping creation
|
||||
print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($objp->date_delivery),'day').'</td>';
|
||||
print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->date_delivery), 'day').'</td>';
|
||||
|
||||
// Qty shipped
|
||||
print '<td align="center">'.$objp->qty_shipped.'</td>';
|
||||
print '<td class="center">'.$objp->qty_shipped.'</td>';
|
||||
|
||||
// Warehouse
|
||||
if (! empty($conf->stock->enabled))
|
||||
@@ -384,7 +384,7 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php';
|
||||
$expedition->id=$objp->sendingid;
|
||||
$expedition->fetchObjectLinked($expedition->id,$expedition->element);
|
||||
$expedition->fetchObjectLinked($expedition->id, $expedition->element);
|
||||
//var_dump($expedition->linkedObjects);
|
||||
|
||||
$receiving='';
|
||||
@@ -403,14 +403,14 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
|
||||
//print '<a href="'.DOL_URL_ROOT.'/livraison/card.php?id='.$livraison_id.'">'.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'<a>';
|
||||
print '</td>';
|
||||
// Qty received
|
||||
//print '<td align="center">';
|
||||
//print '<td class="center">';
|
||||
// TODO No solution for the moment to link a line det of receipt with a line det of shipping,
|
||||
// so no way to know the qty received for this line of shipping.
|
||||
//print $langs->trans("FeatureNotYetAvailable");
|
||||
//print '</td>';
|
||||
// Date shipping real
|
||||
print '<td align="right">';
|
||||
print dol_print_date($receiving->date_delivery,'day');
|
||||
print '<td class="right">';
|
||||
print dol_print_date($receiving->date_delivery, 'day');
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
@@ -435,4 +435,3 @@ function show_list_sending_receive($origin,$origin_id,$filter='')
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -24,19 +24,19 @@
|
||||
* @param string $ref Ref of object
|
||||
* @return string Url string
|
||||
*/
|
||||
function showOnlineSignatureUrl($type,$ref)
|
||||
function showOnlineSignatureUrl($type, $ref)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("payment","paybox"));
|
||||
$langs->loadLangs(array("payment", "paybox"));
|
||||
|
||||
$servicename='Online';
|
||||
$servicename = 'Online';
|
||||
|
||||
$out = img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlineSignature",$servicename).'<br>';
|
||||
$out = img_picto('', 'globe').' '.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'<br>';
|
||||
$url = getOnlineSignatureUrl(0, $type, $ref);
|
||||
$out.= '<input type="text" id="onlinesignatureurl" class="quatrevingtpercent" value="'.$url.'">';
|
||||
$out.= ajax_autoselect("onlinesignatureurl", 0);
|
||||
$out .= '<input type="text" id="onlinesignatureurl" class="quatrevingtpercent" value="'.$url.'">';
|
||||
$out .= ajax_autoselect("onlinesignatureurl", 0);
|
||||
return $out;
|
||||
}
|
||||
|
||||
@@ -49,33 +49,33 @@ function showOnlineSignatureUrl($type,$ref)
|
||||
* @param string $ref Ref of object
|
||||
* @return string Url string
|
||||
*/
|
||||
function getOnlineSignatureUrl($mode, $type, $ref='')
|
||||
function getOnlineSignatureUrl($mode, $type, $ref = '')
|
||||
{
|
||||
global $conf, $db, $langs;
|
||||
|
||||
$ref=str_replace(' ','',$ref);
|
||||
$out='';
|
||||
$ref = str_replace(' ', '', $ref);
|
||||
$out = '';
|
||||
|
||||
if ($type == 'proposal')
|
||||
{
|
||||
$out=DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode?'<font color="#666666">':'');
|
||||
if ($mode == 1) $out.='proposal_ref';
|
||||
if ($mode == 0) $out.=urlencode($ref);
|
||||
$out.=($mode?'</font>':'');
|
||||
if ($mode == 1) $out.='&hashp=<font color="#666666">hash_of_file</font>';
|
||||
$out = DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode ? '<font color="#666666">' : '');
|
||||
if ($mode == 1) $out .= 'proposal_ref';
|
||||
if ($mode == 0) $out .= urlencode($ref);
|
||||
$out .= ($mode ? '</font>' : '');
|
||||
if ($mode == 1) $out .= '&hashp=<font color="#666666">hash_of_file</font>';
|
||||
else
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
$propaltmp=new Propal($db);
|
||||
$propaltmp = new Propal($db);
|
||||
$res = $propaltmp->fetch(0, $ref);
|
||||
if ($res <= 0) return 'FailedToGetProposal';
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($db);
|
||||
$ecmfile = new EcmFiles($db);
|
||||
|
||||
$ecmfile->fetch(0, '', $propaltmp->last_main_doc);
|
||||
|
||||
$hashp=$ecmfile->share;
|
||||
$hashp = $ecmfile->share;
|
||||
if (empty($hashp))
|
||||
{
|
||||
$out = $langs->trans("FeatureOnlineSignDisabled");
|
||||
@@ -83,13 +83,13 @@ function getOnlineSignatureUrl($mode, $type, $ref='')
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.='&hashp='.$hashp;
|
||||
$out .= '&hashp='.$hashp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For multicompany
|
||||
if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities
|
||||
if (!empty($out)) $out .= "&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@
|
||||
*/
|
||||
function stock_prepare_head($object)
|
||||
{
|
||||
global $langs, $conf;
|
||||
global $langs, $conf, $user;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
@@ -39,10 +39,13 @@ function stock_prepare_head($object)
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("StockMovements");
|
||||
$head[$h][2] = 'movements';
|
||||
$h++;
|
||||
if (!empty($user->rights->stock->mouvement->lire))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("StockMovements");
|
||||
$head[$h][2] = 'movements';
|
||||
$h++;
|
||||
}
|
||||
|
||||
/*
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$object->id;
|
||||
@@ -67,15 +70,47 @@ function stock_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'stock');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'stock','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'stock', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array head with list of tabs to view object informations.
|
||||
*
|
||||
* @return array head array with tabs
|
||||
*/
|
||||
function stock_admin_prepare_head()
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/stock.php';
|
||||
$head[$h][1] = $langs->trans("Miscellaneous");
|
||||
$head[$h][2] = 'general';
|
||||
$h++;
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/product/admin/stock_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
$head[$h][2] = 'attributes';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'stock_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -46,10 +46,10 @@ function supplier_proposal_prepare_head($object)
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/contact.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ function supplier_proposal_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_proposal');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal');
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
@@ -67,7 +67,7 @@ function supplier_proposal_prepare_head($object)
|
||||
if(!empty($object->note_public)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
@@ -75,11 +75,11 @@ function supplier_proposal_prepare_head($object)
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->supplier_proposal->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'document';
|
||||
$h++;
|
||||
|
||||
@@ -88,7 +88,7 @@ function supplier_proposal_prepare_head($object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_proposal','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'supplier_proposal', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ function supplier_proposal_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'supplier_proposal_admin');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/supplier_proposal/admin/supplier_proposal_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFields");
|
||||
@@ -126,9 +126,7 @@ function supplier_proposal_admin_prepare_head()
|
||||
$head[$h][2] = 'attributeslines';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'supplier_proposal_admin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'supplier_proposal_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
|
||||
|
||||
61
htdocs/core/lib/takepos.lib.php
Normal file
61
htdocs/core/lib/takepos.lib.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/lib/takepos.lib.php
|
||||
* \brief Library file with function for TakePOS module
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prepare array with list of tabs
|
||||
*
|
||||
* @return array Array of tabs
|
||||
*/
|
||||
function takepos_prepare_head()
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/takepos/admin/setup.php';
|
||||
$head[$h][1] = $langs->trans("Parameters");
|
||||
$head[$h][2] = 'setup';
|
||||
$h++;
|
||||
|
||||
if ($conf->global->TAKEPOS_CUSTOM_RECEIPT)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/takepos/admin/receipt.php';
|
||||
$head[$h][1] = $langs->trans("Receipt");
|
||||
$head[$h][2] = 'receipt';
|
||||
$h++;
|
||||
}
|
||||
|
||||
$numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS);
|
||||
for ($i = 1; $i <= $numterminals; $i++)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/takepos/admin/terminal.php?terminal='.$i;
|
||||
$head[$h][1] = $langs->trans("Terminal"). " ".$i;
|
||||
$head[$h][2] = 'terminal'.$i;
|
||||
$h++;
|
||||
}
|
||||
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'takepos');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -50,16 +50,16 @@ function tax_prepare_head(ChargeSociales $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'tax');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'tax');
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/sociales/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
@@ -68,7 +68,7 @@ function tax_prepare_head(ChargeSociales $object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'tax','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'tax', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -86,9 +86,9 @@ function tax_prepare_head(ChargeSociales $object)
|
||||
* @param string $direction 'sell' or 'buy'
|
||||
* @param int $m Month
|
||||
* @param int $q Quarter
|
||||
* @return array Array with details of VATs (per third parties), -1 if no accountancy module, -2 if not yet developped, -3 if error
|
||||
* @return array|int Array with details of VATs (per third parties), -1 if no accountancy module, -2 if not yet developped, -3 if error
|
||||
*/
|
||||
function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m=0, $q=0)
|
||||
function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m = 0, $q = 0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@@ -109,9 +109,9 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
$total_tva='total_tva';
|
||||
$paymenttable='paiement';
|
||||
$paymentfacturetable='paiement_facture';
|
||||
$invoicefieldref='facnumber';
|
||||
$invoicefieldref='ref';
|
||||
}
|
||||
if ($direction == 'buy')
|
||||
elseif ($direction == 'buy')
|
||||
{
|
||||
$invoicetable='facture_fourn';
|
||||
$invoicedettable='facture_fourn_det';
|
||||
@@ -124,7 +124,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
$invoicefieldref='ref';
|
||||
}
|
||||
|
||||
if ( strpos( $type, 'localtax' ) === 0 ) {
|
||||
if (strpos($type, 'localtax') === 0) {
|
||||
$f_rate = $type . '_tx';
|
||||
} else {
|
||||
$f_rate = 'tva_tx';
|
||||
@@ -152,7 +152,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ;
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " WHERE f.entity IN (".getEntity($invoicetable).")";
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
@@ -160,13 +160,13 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
$sql.= " AND s.rowid = f.fk_soc";
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
elseif ($y)
|
||||
{
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
@@ -191,7 +191,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " WHERE f.entity IN (".getEntity($invoicetable).")";
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
@@ -201,13 +201,13 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
$sql.= " AND pa.rowid = pf.".$fk_payment;
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
elseif ($y)
|
||||
{
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
|
||||
@@ -300,7 +300,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ;
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " WHERE f.entity IN (".getEntity($invoicetable).")";
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
@@ -308,13 +308,13 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
$sql.= " AND s.rowid = f.fk_soc";
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
elseif ($y)
|
||||
{
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
@@ -339,7 +339,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " WHERE f.entity IN (".getEntity($invoicetable).")";
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
@@ -349,13 +349,13 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
$sql.= " AND pa.rowid = pf.".$fk_payment;
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
elseif ($y)
|
||||
{
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
|
||||
@@ -367,7 +367,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
|
||||
if (! $sql)
|
||||
{
|
||||
dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR);
|
||||
dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR);
|
||||
return -1; // -1 = Not accountancy module enabled
|
||||
}
|
||||
if ($sql == 'TODO') return -2; // -2 = Feature not yet available
|
||||
@@ -453,13 +453,13 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
$sql.= " AND e.fk_statut in (6)";
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
|
||||
$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
elseif ($y)
|
||||
{
|
||||
$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
|
||||
$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
@@ -470,7 +470,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
|
||||
if (! $sql)
|
||||
{
|
||||
dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR);
|
||||
dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR);
|
||||
return -1; // -1 = Not accountancy module enabled
|
||||
}
|
||||
if ($sql == 'TODO') return -2; // -2 = Feature not yet available
|
||||
@@ -554,9 +554,9 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
||||
* @param int $modetax Not used
|
||||
* @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices)
|
||||
* @param int $m Month
|
||||
* @return array Array with details of VATs (per rate), -1 if no accountancy module, -2 if not yet developped, -3 if error
|
||||
* @return array|int Array with details of VATs (per rate), -1 if no accountancy module, -2 if not yet developped, -3 if error
|
||||
*/
|
||||
function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0)
|
||||
function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m = 0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@@ -578,7 +578,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$total_tva='total_tva';
|
||||
$paymenttable='paiement';
|
||||
$paymentfacturetable='paiement_facture';
|
||||
$invoicefieldref='facnumber';
|
||||
$invoicefieldref='ref';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -593,7 +593,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$invoicefieldref='ref';
|
||||
}
|
||||
|
||||
if ( strpos( $type, 'localtax' ) === 0 ) {
|
||||
if ( strpos($type, 'localtax') === 0 ) {
|
||||
$f_rate = $type . '_tx';
|
||||
} else {
|
||||
$f_rate = 'tva_tx';
|
||||
@@ -621,7 +621,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ;
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " WHERE f.entity IN (".getEntity($invoicetable).")";
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
@@ -629,13 +629,13 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$sql.= " AND s.rowid = f.fk_soc";
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
elseif ($y)
|
||||
{
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
@@ -660,7 +660,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " WHERE f.entity IN (".getEntity($invoicetable).")";
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
@@ -670,13 +670,13 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$sql.= " AND pa.rowid = pf.".$fk_payment;
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
elseif ($y)
|
||||
{
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
|
||||
@@ -769,7 +769,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ;
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " WHERE f.entity IN (".getEntity($invoicetable).")";
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
@@ -777,13 +777,13 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$sql.= " AND s.rowid = f.fk_soc";
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, $m, false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
elseif ($y)
|
||||
{
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
|
||||
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
|
||||
@@ -808,7 +808,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
|
||||
$sql.= " WHERE f.entity = " . $conf->entity;
|
||||
$sql.= " WHERE f.entity IN (".getEntity($invoicetable).")";
|
||||
$sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
|
||||
else $sql.= " AND f.type IN (0,1,2,3,5)";
|
||||
@@ -818,13 +818,13 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$sql.= " AND pa.rowid = pf.".$fk_payment;
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
elseif ($y)
|
||||
{
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
$sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
|
||||
$sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
|
||||
@@ -836,7 +836,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
|
||||
if (! $sql)
|
||||
{
|
||||
dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR);
|
||||
dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR);
|
||||
return -1; // -1 = Not accountancy module enabled
|
||||
}
|
||||
if ($sql == 'TODO') return -2; // -2 = Feature not yet available
|
||||
@@ -922,13 +922,13 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
$sql.= " AND e.fk_statut in (6)";
|
||||
if ($y && $m)
|
||||
{
|
||||
$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
|
||||
$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
|
||||
$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
|
||||
$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, $m, false))."'";
|
||||
}
|
||||
else if ($y)
|
||||
elseif ($y)
|
||||
{
|
||||
$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'";
|
||||
$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'";
|
||||
$sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
|
||||
$sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
|
||||
}
|
||||
if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")";
|
||||
if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
@@ -939,7 +939,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
|
||||
if (! $sql)
|
||||
{
|
||||
dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR);
|
||||
dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR);
|
||||
return -1; // -1 = Not accountancy module enabled
|
||||
}
|
||||
if ($sql == 'TODO') return -2; // -2 = Feature not yet available
|
||||
@@ -1008,4 +1008,3 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2018 Jean-François FERRY <hello@librethic.io>
|
||||
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
|
||||
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* 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
|
||||
@@ -13,7 +14,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -40,11 +41,17 @@ function ticketAdminPrepareHead()
|
||||
$head[$h][1] = $langs->trans("TicketSettings");
|
||||
$head[$h][2] = 'settings';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/ticket_extrafields.php';
|
||||
$head[$h][1] = $langs->trans("ExtraFieldsTicket");
|
||||
$head[$h][2] = 'attributes';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/ticket_public.php';
|
||||
$head[$h][1] = $langs->trans("PublicInterface");
|
||||
$head[$h][2] = 'public';
|
||||
$h++;
|
||||
|
||||
// Show more tabs from modules
|
||||
// Entries must be declared in modules descriptor with line
|
||||
//$this->tabs = array(
|
||||
@@ -53,7 +60,7 @@ function ticketAdminPrepareHead()
|
||||
//$this->tabs = array(
|
||||
// 'entity:-tabname:Title:@ticket:/ticket/mypage.php?id=__ID__'
|
||||
//); // to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticketadmin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'ticketadmin');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -70,18 +77,17 @@ function ticket_prepare_head($object)
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id=' . $object->track_id;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticket/card.php?action=view&track_id='.$object->track_id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'tabTicket';
|
||||
$h++;
|
||||
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid))
|
||||
{
|
||||
$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external'));
|
||||
$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id;
|
||||
$head[$h][1] = $langs->trans('ContactsAddresses');
|
||||
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
|
||||
if ($nbContact > 0) $head[$h][1].= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
|
||||
$head[$h][2] = 'contact';
|
||||
$h++;
|
||||
}
|
||||
@@ -90,12 +96,12 @@ function ticket_prepare_head($object)
|
||||
|
||||
// Attached files
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
$upload_dir = $conf->ticket->dir_output . "/" . $object->track_id;
|
||||
$upload_dir = $conf->ticket->dir_output . "/" . $object->ref;
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files'));
|
||||
$head[$h][0] = dol_buildpath('/ticket/document.php', 1) . '?track_id=' . $object->track_id;
|
||||
$head[$h][0] = dol_buildpath('/ticket/document.php', 1) . '?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if ($nbFiles > 0) {
|
||||
$head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
|
||||
$head[$h][1] .= '<span class="badge marginleftonlyshort">' . $nbFiles . '</span>';
|
||||
}
|
||||
|
||||
$head[$h][2] = 'tabTicketDocument';
|
||||
@@ -103,30 +109,84 @@ function ticket_prepare_head($object)
|
||||
|
||||
|
||||
// History
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticket/history.php?track_id=' . $object->track_id;
|
||||
$ticketViewType = "messaging";
|
||||
if (empty($_SESSION['ticket-view-type'])) {
|
||||
$_SESSION['ticket-view-type'] = $ticketViewType;
|
||||
}
|
||||
else {
|
||||
$ticketViewType = $_SESSION['ticket-view-type'];
|
||||
}
|
||||
|
||||
if ($ticketViewType == "messaging") {
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticket/messaging.php?track_id='.$object->track_id;
|
||||
}
|
||||
else {
|
||||
// $ticketViewType == "list"
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id;
|
||||
}
|
||||
$head[$h][1] = $langs->trans('Events');
|
||||
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
|
||||
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
|
||||
{
|
||||
$head[$h][1].= '/';
|
||||
$head[$h][1].= $langs->trans("Agenda");
|
||||
$head[$h][1] .= '/';
|
||||
$head[$h][1] .= $langs->trans("Agenda");
|
||||
}
|
||||
$head[$h][2] = 'tabTicketLogs';
|
||||
$h++;
|
||||
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket', 'remove');
|
||||
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random id
|
||||
* Return string with full Url. The file qualified is the one defined by relative path in $object->last_main_doc
|
||||
*
|
||||
* @param string $car Char to generate key
|
||||
* @return void
|
||||
* @param Object $object Object
|
||||
* @return string Url string
|
||||
*/
|
||||
function generate_random_id($car=16)
|
||||
function showDirectPublicLink($object)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
$email = CMailFile::getValidAddress($object->origin_email, 2);
|
||||
$url = '';
|
||||
if ($email)
|
||||
{
|
||||
$url = dol_buildpath('/public/ticket/view.php', 3).'?track_id='.$object->track_id.'&email='.$email;
|
||||
}
|
||||
|
||||
$out = '';
|
||||
if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
|
||||
{
|
||||
$out .= '<span class="opacitymedium">'.$langs->trans("PublicInterfaceNotEnabled").'</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= img_picto('', 'object_globe.png').' '.$langs->trans("TicketPublicAccess").':<br>';
|
||||
if ($url)
|
||||
{
|
||||
$out .= '<input type="text" id="directpubliclink" class="quatrevingtpercent" value="'.$url.'">';
|
||||
$out .= ajax_autoselect("directpubliclink", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= '<span class="opacitymedium">'.$langs->trans("TicketNotCreatedFromPublicInterface").'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random id
|
||||
*
|
||||
* @param int $car Length of string to generate key
|
||||
* @return string
|
||||
*/
|
||||
function generate_random_id($car = 16)
|
||||
{
|
||||
$string = "";
|
||||
$chaine = "abcdefghijklmnopqrstuvwxyz123456789";
|
||||
@@ -153,25 +213,700 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $
|
||||
global $user, $conf, $langs, $mysoc;
|
||||
|
||||
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
|
||||
print '<body id="mainbody" class="publicnewticketform" style="margin-top: 10px;">';
|
||||
|
||||
if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) {
|
||||
// Print logo
|
||||
$urllogo = DOL_URL_ROOT . '/theme/login_logo.png';
|
||||
print '<body id="mainbody" class="publicnewticketform">';
|
||||
|
||||
if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
|
||||
$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small);
|
||||
} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
|
||||
$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo);
|
||||
$width = 128;
|
||||
} elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) {
|
||||
$urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png';
|
||||
}
|
||||
print '<center>';
|
||||
print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>';
|
||||
print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>';
|
||||
if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || ! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) {
|
||||
print '<center>';
|
||||
// Print logo
|
||||
if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO))
|
||||
{
|
||||
$urllogo = DOL_URL_ROOT . '/theme/login_logo.png';
|
||||
|
||||
if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
|
||||
$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small);
|
||||
} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
|
||||
$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo);
|
||||
$width = 128;
|
||||
} elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) {
|
||||
$urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png';
|
||||
}
|
||||
print '<a href="' . ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE : dol_buildpath('/public/ticket/index.php', 1)) . '"><img alt="Logo" id="logosubscribe" title="" src="' . $urllogo . '" style="max-width: 440px" /></a><br>';
|
||||
}
|
||||
if (! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC))
|
||||
{
|
||||
print '<strong>' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '</strong>';
|
||||
}
|
||||
print '</center><br>';
|
||||
}
|
||||
|
||||
print '<div style="margin-left: 50px; margin-right: 50px;">';
|
||||
print '<div class="ticketlargemargin">';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show html area with actions for ticket messaging.
|
||||
* Note: Global parameter $param must be defined.
|
||||
*
|
||||
* @param Conf $conf Object conf
|
||||
* @param Translate $langs Object langs
|
||||
* @param DoliDB $db Object db
|
||||
* @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket|... to list events linked to an object
|
||||
* @param Contact $objcon Filter on object contact to filter events on a contact
|
||||
* @param int $noprint Return string but does not output it
|
||||
* @param string $actioncode Filter on actioncode
|
||||
* @param string $donetodo Filter on event 'done' or 'todo' or ''=nofilter (all).
|
||||
* @param array $filters Filter on other fields
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @return string|void Return html part or void if noprint is 1
|
||||
*/
|
||||
function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC')
|
||||
{
|
||||
global $user, $conf;
|
||||
global $form;
|
||||
|
||||
global $param, $massactionbutton;
|
||||
|
||||
dol_include_once('/comm/action/class/actioncomm.class.php');
|
||||
|
||||
// Check parameters
|
||||
if (!is_object($filterobj) && !is_object($objcon)) dol_print_error('', 'BadParameter');
|
||||
|
||||
$out = '';
|
||||
$histo = array();
|
||||
$numaction = 0;
|
||||
$now = dol_now('tzuser');
|
||||
|
||||
// Open DSI -- Fix order by -- Begin
|
||||
$sortfield_list = explode(',', $sortfield);
|
||||
$sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent');
|
||||
$sortfield_new_list = array();
|
||||
foreach ($sortfield_list as $sortfield_value) {
|
||||
$sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
|
||||
}
|
||||
$sortfield_new = implode(',', $sortfield_new_list);
|
||||
|
||||
if (!empty($conf->agenda->enabled))
|
||||
{
|
||||
// Recherche histo sur actioncomm
|
||||
if (is_object($objcon) && $objcon->id > 0) {
|
||||
$sql = "SELECT DISTINCT a.id, a.label as label,";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT a.id, a.label as label,";
|
||||
}
|
||||
$sql .= " a.datep as dp,";
|
||||
$sql .= " a.note as message,";
|
||||
$sql .= " a.datep2 as dp2,";
|
||||
$sql .= " a.percent as percent, 'action' as type,";
|
||||
$sql .= " a.fk_element, a.elementtype,";
|
||||
$sql .= " a.fk_contact,";
|
||||
$sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,";
|
||||
$sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
|
||||
if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= ", sp.lastname, sp.firstname";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", m.lastname, m.firstname";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", o.ref";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", o.ref";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", o.ref";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", o.ref";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", o.ref";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id";
|
||||
|
||||
$force_filter_contact = false;
|
||||
if (is_object($objcon) && $objcon->id > 0) {
|
||||
$force_filter_contact = true;
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm";
|
||||
$sql .= " AND r.element_type = '".$db->escape($objcon->table_element)."' AND r.fk_element = ".$objcon->id;
|
||||
}
|
||||
|
||||
if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Dolresource') {
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_resources as er";
|
||||
$sql .= " ON er.resource_type = 'dolresource'";
|
||||
$sql .= " AND er.element_id = a.id";
|
||||
$sql .= " AND er.resource_id = ".$filterobj->id;
|
||||
}
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql .= ", ".MAIN_DB_PREFIX."adherent as m";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as o";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql .= ", ".MAIN_DB_PREFIX."product as o";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql .= ", ".MAIN_DB_PREFIX."ticket as o";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') $sql .= ", ".MAIN_DB_PREFIX."bom_bom as o";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') $sql .= ", ".MAIN_DB_PREFIX."contrat as o";
|
||||
|
||||
$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
|
||||
if ($force_filter_contact === false) {
|
||||
if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql .= " AND a.fk_soc = ".$filterobj->id;
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Project' && $filterobj->id) $sql .= " AND a.fk_project = ".$filterobj->id;
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent')
|
||||
{
|
||||
$sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
|
||||
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
|
||||
}
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur')
|
||||
{
|
||||
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
|
||||
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
|
||||
}
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Product')
|
||||
{
|
||||
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'";
|
||||
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
|
||||
}
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket')
|
||||
{
|
||||
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
|
||||
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
|
||||
}
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'BOM')
|
||||
{
|
||||
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
|
||||
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
|
||||
}
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat')
|
||||
{
|
||||
$sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
|
||||
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
|
||||
}
|
||||
}
|
||||
|
||||
// Condition on actioncode
|
||||
if (!empty($actioncode))
|
||||
{
|
||||
if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
{
|
||||
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'";
|
||||
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'";
|
||||
else
|
||||
{
|
||||
if ($actioncode == 'AC_OTH') $sql .= " AND c.type != 'systemauto'";
|
||||
elseif ($actioncode == 'AC_OTH_AUTO') $sql .= " AND c.type = 'systemauto'";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($actioncode == 'AC_NON_AUTO') $sql .= " AND c.type != 'systemauto'";
|
||||
elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND c.type = 'systemauto'";
|
||||
else $sql .= " AND c.code = '".$db->escape($actioncode)."'";
|
||||
}
|
||||
}
|
||||
if ($donetodo == 'todo') $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
|
||||
elseif ($donetodo == 'done') $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))";
|
||||
if (is_array($filters) && $filters['search_agenda_label']) $sql .= natural_search('a.label', $filters['search_agenda_label']);
|
||||
}
|
||||
|
||||
// Add also event from emailings. TODO This should be replaced by an automatic event ? May be it's too much for very large emailing.
|
||||
if (!empty($conf->mailing->enabled) && !empty($objcon->email)
|
||||
&& (empty($actioncode) || $actioncode == 'AC_OTH_AUTO' || $actioncode == 'AC_EMAILING'))
|
||||
{
|
||||
$langs->load("mails");
|
||||
|
||||
$sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type";
|
||||
$sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id";
|
||||
$sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
|
||||
$sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action
|
||||
if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql2 .= ", '' as lastname, '' as firstname";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql2 .= ", '' as ref";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql2 .= ", '' as ref";
|
||||
elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql2 .= ", '' as ref";
|
||||
$sql2 .= " FROM ".MAIN_DB_PREFIX."mailing as m, ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql2 .= " WHERE mc.email = '".$db->escape($objcon->email)."'"; // Search is done on email.
|
||||
$sql2 .= " AND mc.statut = 1";
|
||||
$sql2 .= " AND u.rowid = m.fk_user_valid";
|
||||
$sql2 .= " AND mc.fk_mailing=m.rowid";
|
||||
}
|
||||
|
||||
if (!empty($sql) && !empty($sql2)) {
|
||||
$sql = $sql." UNION ".$sql2;
|
||||
} elseif (empty($sql) && !empty($sql2)) {
|
||||
$sql = $sql2;
|
||||
}
|
||||
|
||||
//TODO Add limit in nb of results
|
||||
$sql .= $db->order($sortfield_new, $sortorder);
|
||||
dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
if ($obj->type == 'action') {
|
||||
$contactaction = new ActionComm($db);
|
||||
$contactaction->id = $obj->id;
|
||||
$result = $contactaction->fetchResources();
|
||||
if ($result < 0) {
|
||||
dol_print_error($db);
|
||||
setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors');
|
||||
}
|
||||
|
||||
//if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
|
||||
//elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))";
|
||||
$tododone = '';
|
||||
if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo';
|
||||
|
||||
$histo[$numaction] = array(
|
||||
'type'=>$obj->type,
|
||||
'tododone'=>$tododone,
|
||||
'id'=>$obj->id,
|
||||
'datestart'=>$db->jdate($obj->dp),
|
||||
'dateend'=>$db->jdate($obj->dp2),
|
||||
'note'=>$obj->label,
|
||||
'message'=>$obj->message,
|
||||
'percent'=>$obj->percent,
|
||||
|
||||
'userid'=>$obj->user_id,
|
||||
'login'=>$obj->user_login,
|
||||
'userfirstname'=>$obj->user_firstname,
|
||||
'userlastname'=>$obj->user_lastname,
|
||||
'userphoto'=>$obj->user_photo,
|
||||
|
||||
'contact_id'=>$obj->fk_contact,
|
||||
'socpeopleassigned' => $contactaction->socpeopleassigned,
|
||||
'lastname'=>$obj->lastname,
|
||||
'firstname'=>$obj->firstname,
|
||||
'fk_element'=>$obj->fk_element,
|
||||
'elementtype'=>$obj->elementtype,
|
||||
// Type of event
|
||||
'acode'=>$obj->acode,
|
||||
'alabel'=>$obj->alabel,
|
||||
'libelle'=>$obj->alabel, // deprecated
|
||||
'apicto'=>$obj->apicto
|
||||
);
|
||||
} else {
|
||||
$histo[$numaction] = array(
|
||||
'type'=>$obj->type,
|
||||
'tododone'=>'done',
|
||||
'id'=>$obj->id,
|
||||
'datestart'=>$db->jdate($obj->dp),
|
||||
'dateend'=>$db->jdate($obj->dp2),
|
||||
'note'=>$obj->label,
|
||||
'message'=>$obj->message,
|
||||
'percent'=>$obj->percent,
|
||||
'acode'=>$obj->acode,
|
||||
|
||||
'userid'=>$obj->user_id,
|
||||
'login'=>$obj->user_login,
|
||||
'userfirstname'=>$obj->user_firstname,
|
||||
'userlastname'=>$obj->user_lastname,
|
||||
'userphoto'=>$obj->user_photo
|
||||
);
|
||||
}
|
||||
|
||||
$numaction++;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email)))
|
||||
{
|
||||
$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
|
||||
$formactions = new FormActions($db);
|
||||
|
||||
$actionstatic = new ActionComm($db);
|
||||
$userstatic = new User($db);
|
||||
$contactstatic = new Contact($db);
|
||||
$userGetNomUrlCache = array();
|
||||
|
||||
$out .= '<div class="filters-container" >';
|
||||
$out .= '<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
if ($objcon && get_class($objcon) == 'Contact' &&
|
||||
(is_null($filterobj) || get_class($filterobj) == 'Societe'))
|
||||
{
|
||||
$out .= '<input type="hidden" name="id" value="'.$objcon->id.'" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= '<input type="hidden" name="id" value="'.$filterobj->id.'" />';
|
||||
}
|
||||
if ($filterobj && get_class($filterobj) == 'Societe') $out .= '<input type="hidden" name="socid" value="'.$filterobj->id.'" />';
|
||||
|
||||
$out .= "\n";
|
||||
|
||||
$out .= '<div class="div-table-responsive-no-min">';
|
||||
$out .= '<table class="noborder borderbottom centpercent">';
|
||||
|
||||
$out .= '<tr class="liste_titre">';
|
||||
|
||||
//$out.='<td class="liste_titre">';
|
||||
$out .= getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', '', $param, '', $sortfield, $sortorder, '')."\n";
|
||||
//$out.='</td>';
|
||||
|
||||
$out .= '<th class="liste_titre"><strong>'.$langs->trans("Search").' : </strong></th>';
|
||||
if ($donetodo)
|
||||
{
|
||||
$out .= '<th class="liste_titre"></th>';
|
||||
}
|
||||
$out .= '<th class="liste_titre">'.$langs->trans("Type").' ';
|
||||
$out .= $formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1, 0, 0, 1);
|
||||
$out .= '</th>';
|
||||
$out .= '<th class="liste_titre maxwidth100onsmartphone">';
|
||||
$out .= $langs->trans("Label").' ';
|
||||
$out .= '<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters['search_agenda_label'].'">';
|
||||
$out .= '</th>';
|
||||
|
||||
$out .= '<th class="liste_titre width50 middle">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
|
||||
$out .= $searchpicto;
|
||||
$out .= '</th>';
|
||||
$out .= '</tr>';
|
||||
|
||||
|
||||
$out .= '</table>';
|
||||
|
||||
$out .= '</form>';
|
||||
$out .= '</div>';
|
||||
|
||||
$out .= "\n";
|
||||
|
||||
$out .= '<ul class="timeline">';
|
||||
|
||||
if ($donetodo)
|
||||
{
|
||||
$tmp = '';
|
||||
if (get_class($filterobj) == 'Societe') $tmp .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?socid='.$filterobj->id.'&status=done">';
|
||||
$tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : '');
|
||||
$tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : '');
|
||||
$tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : '');
|
||||
//$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort");
|
||||
if (get_class($filterobj) == 'Societe') $tmp .= '</a>';
|
||||
$out .= getTitleFieldOfList($tmp);
|
||||
}
|
||||
|
||||
|
||||
//require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
|
||||
//$caction=new CActionComm($db);
|
||||
//$arraylist=$caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0), '', 1);
|
||||
|
||||
$actualCycleDate = false;
|
||||
|
||||
foreach ($histo as $key=>$value)
|
||||
{
|
||||
$actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo
|
||||
|
||||
$actionstatic->type_picto = $histo[$key]['apicto'];
|
||||
$actionstatic->type_code = $histo[$key]['acode'];
|
||||
|
||||
$url = DOL_URL_ROOT.'/comm/action/card.php?id='.$histo[$key]['id'];
|
||||
|
||||
$tmpa = dol_getdate($histo[$key]['datestart'], false);
|
||||
if ($actualCycleDate !== $tmpa['year'].'-'.$tmpa['yday']) {
|
||||
$actualCycleDate = $tmpa['year'].'-'.$tmpa['yday'];
|
||||
$out .= '<!-- timeline time label -->';
|
||||
$out .= '<li class="time-label">';
|
||||
$out .= '<span class="timeline-badge-date">';
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'daytext', 'tzserver', $langs);
|
||||
$out .= '</span>';
|
||||
$out .= '</li>';
|
||||
$out .= '<!-- /.timeline-label -->';
|
||||
}
|
||||
|
||||
|
||||
$out .= '<!-- timeline item -->'."\n";
|
||||
$out .= '<li class="timeline-code-'.strtolower($actionstatic->code).'">';
|
||||
|
||||
|
||||
$out .= '<!-- timeline icon -->'."\n";
|
||||
$iconClass = 'fa fa-comments';
|
||||
$img_picto = '';
|
||||
$colorClass = '';
|
||||
$pictoTitle = '';
|
||||
|
||||
if ($histo[$key]['percent'] == -1) {
|
||||
$colorClass = 'timeline-icon-not-applicble';
|
||||
$pictoTitle = $langs->trans('StatusNotApplicable');
|
||||
}
|
||||
elseif ($histo[$key]['percent'] == 0) {
|
||||
$colorClass = 'timeline-icon-todo';
|
||||
$pictoTitle = $langs->trans('StatusActionToDo').' (0%)';
|
||||
}
|
||||
elseif ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100) {
|
||||
$colorClass = 'timeline-icon-in-progress';
|
||||
$pictoTitle = $langs->trans('StatusActionInProcess').' ('.$histo[$key]['percent'].'%)';
|
||||
}
|
||||
elseif ($histo[$key]['percent'] >= 100) {
|
||||
$colorClass = 'timeline-icon-done';
|
||||
$pictoTitle = $langs->trans('StatusActionDone').' (100%)';
|
||||
}
|
||||
|
||||
|
||||
if ($actionstatic->code == 'AC_TICKET_CREATE') {
|
||||
$iconClass = 'fa fa-ticket';
|
||||
}
|
||||
elseif ($actionstatic->code == 'AC_TICKET_MODIFY') {
|
||||
$iconClass = 'fa fa-pencil';
|
||||
}
|
||||
elseif ($actionstatic->code == 'TICKET_MSG') {
|
||||
$iconClass = 'fa fa-comments';
|
||||
}
|
||||
elseif ($actionstatic->code == 'TICKET_MSG_PRIVATE') {
|
||||
$iconClass = 'fa fa-mask';
|
||||
}
|
||||
elseif (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
{
|
||||
if ($actionstatic->type_picto) $img_picto = img_picto('', $actionstatic->type_picto);
|
||||
else {
|
||||
if ($actionstatic->type_code == 'AC_RDV') $iconClass = 'fa fa-handshake';
|
||||
elseif ($actionstatic->type_code == 'AC_TEL') $iconClass = 'fa fa-phone';
|
||||
elseif ($actionstatic->type_code == 'AC_FAX') $iconClass = 'fa fa-fax';
|
||||
elseif ($actionstatic->type_code == 'AC_EMAIL') $iconClass = 'fa fa-envelope';
|
||||
elseif ($actionstatic->type_code == 'AC_INT') $iconClass = 'fa fa-shipping-fast';
|
||||
elseif ($actionstatic->type_code == 'AC_OTH_AUTO') $iconClass = 'fa fa-robot';
|
||||
elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) $iconClass = 'fa fa-robot';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$out .= '<i class="'.$iconClass.' '.$colorClass.'" title="'.$pictoTitle.'">'.$img_picto.'</i>'."\n";
|
||||
|
||||
$out .= '<div class="timeline-item">'."\n";
|
||||
|
||||
$out .= '<span class="timeline-header-action">';
|
||||
|
||||
if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
|
||||
$out .= '<a class="timeline-btn" href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' ';
|
||||
$out .= $histo[$key]['id'];
|
||||
$out .= '</a> ';
|
||||
} else {
|
||||
$out .= $actionstatic->getNomUrl(1, -1).' ';
|
||||
}
|
||||
|
||||
//if ($user->rights->agenda->allactions->read || $actionstatic->authorid == $user->id)
|
||||
//{
|
||||
// $out.='<a href="'.$url.'" class="timeline-btn" title="'.$langs->trans('Show').'" ><i class="fa fa-calendar" ></i>'.$langs->trans('Show').'</a>';
|
||||
//}
|
||||
|
||||
|
||||
if ($user->rights->agenda->allactions->create ||
|
||||
(($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->rights->agenda->myactions->create))
|
||||
{
|
||||
$out.='<a class="timeline-btn" href="' . DOL_MAIN_URL_ROOT. '/comm/action/card.php?action=edit&id='.$actionstatic->id.'"><i class="fa fa-pencil" title="'.$langs->trans("Modify").'" ></i></a>';
|
||||
}
|
||||
|
||||
|
||||
$out.='</span>';
|
||||
// Date
|
||||
$out.='<span class="time"><i class="fa fa-clock-o"></i> ';
|
||||
$out.=dol_print_date($histo[$key]['datestart'], 'dayhour');
|
||||
if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart'])
|
||||
{
|
||||
$tmpa=dol_getdate($histo[$key]['datestart'], true);
|
||||
$tmpb=dol_getdate($histo[$key]['dateend'], true);
|
||||
if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out.='-'.dol_print_date($histo[$key]['dateend'], 'hour');
|
||||
else $out.='-'.dol_print_date($histo[$key]['dateend'], 'dayhour');
|
||||
}
|
||||
$late=0;
|
||||
if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1;
|
||||
if ($histo[$key]['percent'] == 0 && ! $histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1;
|
||||
if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late=1;
|
||||
if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && ! $histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1;
|
||||
if ($late) $out.=img_warning($langs->trans("Late")).' ';
|
||||
$out.="</span>\n";
|
||||
|
||||
// Ref
|
||||
$out.='<h3 class="timeline-header">';
|
||||
|
||||
// Author of event
|
||||
$out.='<span class="messaging-author">';
|
||||
if ($histo[$key]['userid'] > 0)
|
||||
{
|
||||
if(!isset($userGetNomUrlCache[$histo[$key]['userid']])){ // is in cache ?
|
||||
$userstatic->fetch($histo[$key]['userid']);
|
||||
$userGetNomUrlCache[$histo[$key]['userid']] = $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
|
||||
}
|
||||
$out.= $userGetNomUrlCache[$histo[$key]['userid']];
|
||||
}
|
||||
$out.='</span>';
|
||||
|
||||
// Title
|
||||
$out .= ' <span class="messaging-title">';
|
||||
|
||||
if($actionstatic->code == 'TICKET_MSG') {
|
||||
$out .= $langs->trans('TicketNewMessage');
|
||||
}
|
||||
elseif($actionstatic->code == 'TICKET_MSG_PRIVATE') {
|
||||
$out .= $langs->trans('TicketNewMessage').' <em>('.$langs->trans('Private').')</em>';
|
||||
}else{
|
||||
if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') {
|
||||
$transcode = $langs->trans("Action" . $histo[$key]['acode']);
|
||||
$libelle = ($transcode != "Action" . $histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']);
|
||||
$libelle = $histo[$key]['note'];
|
||||
$actionstatic->id = $histo[$key]['id'];
|
||||
$out .= dol_trunc($libelle, 120);
|
||||
}
|
||||
if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
|
||||
$out .= '<a href="' . DOL_URL_ROOT . '/comm/mailing/card.php?id=' . $histo[$key]['id'] . '">' . img_object($langs->trans("ShowEMailing"), "email") . ' ';
|
||||
$transcode = $langs->trans("Action" . $histo[$key]['acode']);
|
||||
$libelle = ($transcode != "Action" . $histo[$key]['acode'] ? $transcode : 'Send mass mailing');
|
||||
$out .= dol_trunc($libelle, 120);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$out .= '</span>';
|
||||
|
||||
$out .= '</h3>';
|
||||
|
||||
if (!empty($histo[$key]['message'])
|
||||
&& $actionstatic->code != 'AC_TICKET_CREATE'
|
||||
&& $actionstatic->code != 'AC_TICKET_MODIFY'
|
||||
)
|
||||
{
|
||||
$out .= '<div class="timeline-body">';
|
||||
$out .= $histo[$key]['message'];
|
||||
$out .= '</div>';
|
||||
}
|
||||
|
||||
|
||||
// Timeline footer
|
||||
$footer = '';
|
||||
|
||||
// Contact for this action
|
||||
if (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) {
|
||||
$contactList = '';
|
||||
foreach ($histo[$key]['socpeopleassigned'] as $cid => $Tab) {
|
||||
$contact = new Contact($db);
|
||||
$result = $contact->fetch($cid);
|
||||
|
||||
if ($result < 0)
|
||||
dol_print_error($db, $contact->error);
|
||||
|
||||
if ($result > 0) {
|
||||
$contactList .= !empty($contactList) ? ', ' : '';
|
||||
$contactList .= $contact->getNomUrl(1);
|
||||
if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') {
|
||||
if (!empty($contact->phone_pro))
|
||||
$contactList .= '('.dol_print_phone($contact->phone_pro).')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$footer .= $langs->trans('ActionOnContact').' : '.$contactList;
|
||||
}
|
||||
elseif (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0)
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
$result = $contact->fetch($histo[$key]['contact_id']);
|
||||
|
||||
if ($result < 0)
|
||||
dol_print_error($db, $contact->error);
|
||||
|
||||
if ($result > 0) {
|
||||
$footer .= $contact->getNomUrl(1);
|
||||
if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') {
|
||||
if (! empty($contact->phone_pro))
|
||||
$footer .= '(' . dol_print_phone($contact->phone_pro) . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$documents = getTicketActionCommEcmList($actionstatic) ;
|
||||
if(!empty($documents))
|
||||
{
|
||||
$footer.= '<div class="timeline-documents-container">';
|
||||
foreach ($documents as $doc)
|
||||
{
|
||||
$footer.= '<span id="document_'.$doc->id.'" class="timeline-documents" ';
|
||||
$footer.= ' data-id="'.$doc->id.'" ';
|
||||
$footer.= ' data-path="'.$doc->filepath.'"';
|
||||
$footer.= ' data-filename="'.dol_escape_htmltag($doc->filename).'" ';
|
||||
$footer.= '>';
|
||||
|
||||
$filePath = DOL_DATA_ROOT . '/'. $doc->filepath . '/'. $doc->filename;
|
||||
$mime = dol_mimetype($filePath);
|
||||
$file = $actionstatic->id.'/'.$doc->filename;
|
||||
$thumb = $actionstatic->id.'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename, '.')).'_mini'.substr($doc->filename, strrpos($doc->filename, '.'));
|
||||
$doclink = dol_buildpath('document.php', 1).'?modulepart=actions&attachment=0&file='.urlencode($file).'&entity='.$conf->entity;
|
||||
$viewlink = dol_buildpath('viewimage.php', 1).'?modulepart=actions&file='.urlencode($thumb).'&entity='.$conf->entity;
|
||||
|
||||
$mimeAttr = ' mime="'.$mime.'" ';
|
||||
$class = '';
|
||||
if(in_array($mime, array('image/png', 'image/jpeg', 'application/pdf'))){
|
||||
$class.= ' documentpreview';
|
||||
}
|
||||
|
||||
$footer.= '<a href="'.$doclink.'" class="btn-link '.$class.'" target="_blank" '.$mimeAttr.' >';
|
||||
$footer.= img_mime($filePath).' '.$doc->filename;
|
||||
$footer.= '</a>';
|
||||
|
||||
$footer.= '</span>';
|
||||
}
|
||||
$footer.= '</div>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(!empty($footer)){
|
||||
$out.='<div class="timeline-footer">'.$footer.'</div>';
|
||||
}
|
||||
|
||||
|
||||
$out.='</div>'."\n"; // end timeline-item
|
||||
|
||||
$out.='</li>';
|
||||
$out.='<!-- END timeline item -->';
|
||||
|
||||
$i++;
|
||||
}
|
||||
$out.="</ul>\n";
|
||||
}
|
||||
|
||||
|
||||
if ($noprint) return $out;
|
||||
else print $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getTicketActionCommEcmList
|
||||
*
|
||||
* @param ActionComm $object Object ActionComm
|
||||
* @return array Array of documents in index table
|
||||
*/
|
||||
function getTicketActionCommEcmList($object)
|
||||
{
|
||||
global $conf, $db;
|
||||
|
||||
$documents = array();
|
||||
|
||||
$sql = 'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id, ecm.filepath, ecm.filename';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'ecm_files ecm';
|
||||
$sql.= ' WHERE ecm.filepath = \'agenda/'.$object->id.'\'';
|
||||
//$sql.= ' ecm.src_object_type = \''.$object->element.'\' AND ecm.src_object_id = '.$object->id; // Actually upload file doesn't add type
|
||||
$sql.= ' ORDER BY ecm.position ASC';
|
||||
|
||||
$resql= $db->query($sql);
|
||||
if ($resql) {
|
||||
if ($db->num_rows($resql)) {
|
||||
while ($obj = $db->fetch_object($resql)) {
|
||||
$documents[$obj->id] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $documents;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@
|
||||
* @param int $silent Do not output indent and picto, returns only value
|
||||
* @return integer[] array(0 or 1 if at least one of this level after, 0 or 1 if at least one of higher level after, nbofdirinsub, nbofdocinsub)
|
||||
*/
|
||||
function tree_showpad(&$fulltree,$key,$silent=0)
|
||||
function tree_showpad(&$fulltree, $key, $silent = 0)
|
||||
{
|
||||
$pos=1;
|
||||
|
||||
@@ -77,13 +77,13 @@ function tree_showpad(&$fulltree,$key,$silent=0)
|
||||
{
|
||||
if ($atleastoneofthislevelafter)
|
||||
{
|
||||
if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branch.gif');
|
||||
else print img_picto_common('','treemenu/line.gif');
|
||||
if ($fulltree[$key]['level'] == $pos) print img_picto_common('', 'treemenu/branch.gif');
|
||||
else print img_picto_common('', 'treemenu/line.gif');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($fulltree[$key]['level'] == $pos) print img_picto_common('','treemenu/branchbottom.gif');
|
||||
else print img_picto_common('','treemenu/linebottom.gif');
|
||||
if ($fulltree[$key]['level'] == $pos) print img_picto_common('', 'treemenu/branchbottom.gif');
|
||||
else print img_picto_common('', 'treemenu/linebottom.gif');
|
||||
}
|
||||
}
|
||||
$pos++;
|
||||
@@ -113,9 +113,9 @@ function tree_showpad(&$fulltree,$key,$silent=0)
|
||||
* @param int $showfk 1=show fk_links to parent into label (used by menu editor only)
|
||||
* @return void
|
||||
*/
|
||||
function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0)
|
||||
function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoresetalreadyloaded = 0, $showfk = 0)
|
||||
{
|
||||
global $tree_recur_alreadyadded;
|
||||
global $tree_recur_alreadyadded, $menu_handler_to_search;
|
||||
|
||||
if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array();
|
||||
|
||||
@@ -171,7 +171,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
|
||||
print '<strong> ';
|
||||
print $tab[$x]['title'];
|
||||
print ' (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $tab[$x]['buttons'];
|
||||
print '</td></tr></table>';
|
||||
}
|
||||
@@ -203,11 +203,11 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
|
||||
if ($showfk)
|
||||
{
|
||||
print '<table class="nobordernopadding centpercent"><tr><td>';
|
||||
print '<strong> <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$menu['rowid'].'">';
|
||||
print '<strong> <a href="edit.php?menu_handler='.$menu_handler_to_search.'&action=edit&menuId='.$tab[$x]['rowid'].'">';
|
||||
print $tab[$x]['title'];
|
||||
print '</a></strong>';
|
||||
print ' (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')';
|
||||
print '</td><td align="right">';
|
||||
print '</td><td class="right">';
|
||||
print $tab[$x]['buttons'];
|
||||
print '</td></tr></table>';
|
||||
}
|
||||
@@ -227,4 +227,3 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
|
||||
|
||||
if ($rang == 0) print '</ul>';
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ function trip_prepare_head(Deplacement $object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'trip');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'trip');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
@@ -55,7 +55,7 @@ function trip_prepare_head(Deplacement $object)
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'trip','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'trip', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2010-2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -15,8 +15,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ function user_prepare_head($object)
|
||||
|
||||
$langs->load("users");
|
||||
|
||||
$canreadperms=true;
|
||||
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
|
||||
$canreadperms = true;
|
||||
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))
|
||||
{
|
||||
$canreadperms=($user->admin || ($user->id != $object->id && $user->rights->user->user_advance->readperms) || ($user->id == $object->id && $user->rights->user->self_advance->readperms));
|
||||
$canreadperms = ($user->admin || ($user->id != $object->id && $user->rights->user->user_advance->readperms) || ($user->id == $object->id && $user->rights->user->self_advance->readperms));
|
||||
}
|
||||
|
||||
$h = 0;
|
||||
@@ -51,8 +51,8 @@ function user_prepare_head($object)
|
||||
$head[$h][2] = 'user';
|
||||
$h++;
|
||||
|
||||
if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE))
|
||||
&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
|
||||
if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_SYNCHRO_ACTIVE))
|
||||
&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin)))
|
||||
{
|
||||
$langs->load("ldap");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/ldap.php?id='.$object->id;
|
||||
@@ -64,7 +64,7 @@ function user_prepare_head($object)
|
||||
if ($canreadperms)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Rights"). ' <span class="badge">'.($object->nb_rights).'</span>';
|
||||
$head[$h][1] = $langs->trans("Rights").'<span class="badge marginleftonlyshort">'.($object->nb_rights).'</span>';
|
||||
$head[$h][2] = 'rights';
|
||||
$h++;
|
||||
}
|
||||
@@ -74,32 +74,32 @@ function user_prepare_head($object)
|
||||
$head[$h][2] = 'guisetup';
|
||||
$h++;
|
||||
|
||||
if (! empty($conf->agenda->enabled))
|
||||
if (!empty($conf->agenda->enabled))
|
||||
{
|
||||
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
|
||||
$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
|
||||
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5;
|
||||
$MAXAGENDA = $conf->global->AGENDA_EXT_NB;
|
||||
|
||||
$i=1;
|
||||
$i = 1;
|
||||
$nbagenda = 0;
|
||||
while ($i <= $MAXAGENDA)
|
||||
{
|
||||
$key=$i;
|
||||
$name='AGENDA_EXT_NAME_'.$object->id.'_'.$key;
|
||||
$src='AGENDA_EXT_SRC_'.$object->id.'_'.$key;
|
||||
$offsettz='AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key;
|
||||
$color='AGENDA_EXT_COLOR_'.$object->id.'_'.$key;
|
||||
$key = $i;
|
||||
$name = 'AGENDA_EXT_NAME_'.$object->id.'_'.$key;
|
||||
$src = 'AGENDA_EXT_SRC_'.$object->id.'_'.$key;
|
||||
$offsettz = 'AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key;
|
||||
$color = 'AGENDA_EXT_COLOR_'.$object->id.'_'.$key;
|
||||
$i++;
|
||||
|
||||
if (! empty($object->conf->$name)) $nbagenda++;
|
||||
if (!empty($object->conf->$name)) $nbagenda++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("ExtSites").($nbagenda ? ' <span class="badge">'.$nbagenda.'</span>' : '');
|
||||
$head[$h][1] = $langs->trans("ExtSites").($nbagenda ? '<span class="badge marginleftonlyshort">'.$nbagenda.'</span>' : '');
|
||||
$head[$h][2] = 'extsites';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (! empty($conf->clicktodial->enabled))
|
||||
if (!empty($conf->clicktodial->enabled))
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("ClickToDial");
|
||||
@@ -108,13 +108,13 @@ function user_prepare_head($object)
|
||||
}
|
||||
|
||||
// Notifications
|
||||
if ($user->societe_id == 0 && ! empty($conf->notification->enabled))
|
||||
if ($user->socid == 0 && !empty($conf->notification->enabled))
|
||||
{
|
||||
$nbNote = 0;
|
||||
$sql = "SELECT COUNT(n.rowid) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n";
|
||||
$sql.= " WHERE fk_user = ".$object->id;
|
||||
$resql=$db->query($sql);
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n";
|
||||
$sql .= " WHERE fk_user = ".$object->id;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
@@ -122,7 +122,7 @@ function user_prepare_head($object)
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$nbNote=$obj->nb;
|
||||
$nbNote = $obj->nb;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ function user_prepare_head($object)
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/notify/card.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Notifications");
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'notify';
|
||||
$h++;
|
||||
}
|
||||
@@ -141,12 +141,12 @@ function user_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'user');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'user');
|
||||
|
||||
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|
||||
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))
|
||||
|| (! empty($conf->expensereport->enabled) && ! empty($user->rights->expensereport->lire) && $user->id == $object->id)
|
||||
|| (! empty($conf->holiday->enabled) && ! empty($user->rights->holiday->read) && $user->id == $object->id )
|
||||
if ((!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
|
||||
|| (!empty($conf->hrm->enabled) && !empty($user->rights->hrm->employee->read))
|
||||
|| (!empty($conf->expensereport->enabled) && !empty($user->rights->expensereport->lire) && ($user->id == $object->id || $user->rights->expensereport->readall))
|
||||
|| (!empty($conf->holiday->enabled) && !empty($user->rights->holiday->read) && ($user->id == $object->id || $user->rights->holiday->read_all))
|
||||
)
|
||||
{
|
||||
// Bank
|
||||
@@ -157,26 +157,26 @@ function user_prepare_head($object)
|
||||
}
|
||||
|
||||
// Such info on users is visible only by internal user
|
||||
if (empty($user->societe_id))
|
||||
if (empty($user->socid))
|
||||
{
|
||||
// Notes
|
||||
$nbNote = 0;
|
||||
if(!empty($object->note)) $nbNote++;
|
||||
if (!empty($object->note)) $nbNote++;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Note");
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
|
||||
// Attached files
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->user->dir_output . "/" . $object->id;
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$upload_dir = $conf->user->dir_output."/".$object->id;
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks = Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/document.php?userid='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
|
||||
$head[$h][2] = 'document';
|
||||
$h++;
|
||||
|
||||
@@ -186,7 +186,7 @@ function user_prepare_head($object)
|
||||
$h++;
|
||||
}
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'user','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'user', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -194,17 +194,17 @@ function user_prepare_head($object)
|
||||
/**
|
||||
* Prepare array with list of tabs
|
||||
*
|
||||
* @param Group $object Object group
|
||||
* @return array Array of tabs
|
||||
* @param UserGroup $object Object group
|
||||
* @return array Array of tabs
|
||||
*/
|
||||
function group_prepare_head($object)
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
|
||||
$canreadperms=true;
|
||||
if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS))
|
||||
$canreadperms = true;
|
||||
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS))
|
||||
{
|
||||
$canreadperms=($user->admin || $user->rights->user->group_advance->readperms);
|
||||
$canreadperms = ($user->admin || $user->rights->user->group_advance->readperms);
|
||||
}
|
||||
|
||||
$h = 0;
|
||||
@@ -215,8 +215,8 @@ function group_prepare_head($object)
|
||||
$head[$h][2] = 'group';
|
||||
$h++;
|
||||
|
||||
if ((! empty($conf->ldap->enabled) && ! empty($conf->global->LDAP_SYNCHRO_ACTIVE))
|
||||
&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || ! empty($user->admin)))
|
||||
if ((!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_SYNCHRO_ACTIVE))
|
||||
&& (empty($conf->global->MAIN_DISABLE_LDAP_TAB) || !empty($user->admin)))
|
||||
{
|
||||
$langs->load("ldap");
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/group/ldap.php?id='.$object->id;
|
||||
@@ -228,7 +228,7 @@ function group_prepare_head($object)
|
||||
if ($canreadperms)
|
||||
{
|
||||
$head[$h][0] = DOL_URL_ROOT.'/user/group/perms.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("GroupRights"). ' <span class="badge">'.($object->nb_rights).'</span>';
|
||||
$head[$h][1] = $langs->trans("GroupRights").'<span class="badge marginleftonlyshort">'.($object->nb_rights).'</span>';
|
||||
$head[$h][2] = 'rights';
|
||||
$h++;
|
||||
}
|
||||
@@ -237,9 +237,9 @@ function group_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'group');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'group');
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'group','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'group', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -254,7 +254,8 @@ function user_admin_prepare_head()
|
||||
global $langs, $conf, $user;
|
||||
|
||||
$langs->load("users");
|
||||
$h=0;
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/user.php';
|
||||
$head[$h][1] = $langs->trans("Parameters");
|
||||
@@ -280,9 +281,9 @@ function user_admin_prepare_head()
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'useradmin');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'useradmin');
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,'useradmin','remove');
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'useradmin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@@ -295,43 +296,42 @@ function user_admin_prepare_head()
|
||||
* @param boolean $foruserprofile Show for user profile view
|
||||
* @return void
|
||||
*/
|
||||
function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
function showSkins($fuser, $edit = 0, $foruserprofile = false)
|
||||
{
|
||||
global $conf,$langs,$db,$form;
|
||||
global $bc;
|
||||
global $conf, $langs, $db, $form;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
|
||||
$formother = new FormOther($db);
|
||||
|
||||
$dirthemes=array('/theme');
|
||||
if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application
|
||||
$dirthemes = array('/theme');
|
||||
if (!empty($conf->modules_parts['theme'])) // Using this feature slow down application
|
||||
{
|
||||
foreach($conf->modules_parts['theme'] as $reldir)
|
||||
foreach ($conf->modules_parts['theme'] as $reldir)
|
||||
{
|
||||
$dirthemes=array_merge($dirthemes,(array) ($reldir.'theme'));
|
||||
$dirthemes = array_merge($dirthemes, (array) ($reldir.'theme'));
|
||||
}
|
||||
}
|
||||
$dirthemes=array_unique($dirthemes);
|
||||
$dirthemes = array_unique($dirthemes);
|
||||
// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
|
||||
|
||||
$selected_theme='';
|
||||
if (empty($foruserprofile)) $selected_theme=$conf->global->MAIN_THEME;
|
||||
else $selected_theme=((is_object($fuser) && ! empty($fuser->conf->MAIN_THEME))?$fuser->conf->MAIN_THEME:'');
|
||||
$selected_theme = '';
|
||||
if (empty($foruserprofile)) $selected_theme = $conf->global->MAIN_THEME;
|
||||
else $selected_theme = ((is_object($fuser) && !empty($fuser->conf->MAIN_THEME)) ? $fuser->conf->MAIN_THEME : '');
|
||||
|
||||
$hoverdisabled='';
|
||||
if (empty($foruserprofile)) $hoverdisabled=(isset($conf->global->THEME_ELDY_USE_HOVER) && $conf->global->THEME_ELDY_USE_HOVER == '0');
|
||||
else $hoverdisabled=(is_object($fuser)?(empty($fuser->conf->THEME_ELDY_USE_HOVER) || $fuser->conf->THEME_ELDY_USE_HOVER == '0'):'');
|
||||
$hoverdisabled = '';
|
||||
if (empty($foruserprofile)) $hoverdisabled = (isset($conf->global->THEME_ELDY_USE_HOVER) && $conf->global->THEME_ELDY_USE_HOVER == '0');
|
||||
else $hoverdisabled = (is_object($fuser) ? (empty($fuser->conf->THEME_ELDY_USE_HOVER) || $fuser->conf->THEME_ELDY_USE_HOVER == '0') : '');
|
||||
|
||||
$checkeddisabled='';
|
||||
if (empty($foruserprofile)) $checkeddisabled=(isset($conf->global->THEME_ELDY_USE_CHECKED) && $conf->global->THEME_ELDY_USE_CHECKED == '0');
|
||||
else $checkeddisabled=(is_object($fuser)?(empty($fuser->conf->THEME_ELDY_USE_CHECKED) || $fuser->conf->THEME_ELDY_USE_CHECKED == '0'):'');
|
||||
$checkeddisabled = '';
|
||||
if (empty($foruserprofile)) $checkeddisabled = (isset($conf->global->THEME_ELDY_USE_CHECKED) && $conf->global->THEME_ELDY_USE_CHECKED == '0');
|
||||
else $checkeddisabled = (is_object($fuser) ? (empty($fuser->conf->THEME_ELDY_USE_CHECKED) || $fuser->conf->THEME_ELDY_USE_CHECKED == '0') : '');
|
||||
|
||||
$colspan=2;
|
||||
if ($foruserprofile) $colspan=4;
|
||||
$colspan = 2;
|
||||
if ($foruserprofile) $colspan = 4;
|
||||
|
||||
$thumbsbyrow=6;
|
||||
print '<table class="noborder" width="100%">';
|
||||
$thumbsbyrow = 6;
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
// Title
|
||||
if ($foruserprofile)
|
||||
@@ -343,74 +343,70 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("DefaultSkin").'</td>';
|
||||
print '<td>'.$conf->global->MAIN_THEME.'</td>';
|
||||
print '<td align="left" class="nowrap" width="20%"><input id="check_MAIN_THEME" name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
print '<td class="nowrap left" width="20%"><input id="check_MAIN_THEME" name="check_MAIN_THEME"'.($edit ? '' : ' disabled').' type="checkbox" '.($selected_theme ? " checked" : "").'> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("DefaultSkin").'</th>';
|
||||
print '<th align="right">';
|
||||
$url='https://www.dolistore.com/lang-en/4-skins';
|
||||
if (preg_match('/fr/i',$langs->defaultlang)) $url='https://www.dolistore.com/fr/4-themes';
|
||||
//if (preg_match('/es/i',$langs->defaultlang)) $url='http://www.dolistore.com/lang-es/4-themes';
|
||||
$dirthemestring = '';
|
||||
foreach ($dirthemes as $dirtheme)
|
||||
{
|
||||
$dirthemestring .= '"'.$dirtheme.'" ';
|
||||
}
|
||||
|
||||
print '<tr class="liste_titre"><th class="titlefield">';
|
||||
print $form->textwithpicto($langs->trans("DefaultSkin"), $langs->trans("ThemeDir").' : '.$dirthemestring);
|
||||
print '</th>';
|
||||
print '<th class="right">';
|
||||
$url = 'https://www.dolistore.com/4-skins';
|
||||
print '<a href="'.$url.'" target="_blank">';
|
||||
print $langs->trans('DownloadMoreSkins');
|
||||
print '</a>';
|
||||
print '</th></tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("ThemeDir").'</td>';
|
||||
print '<td>';
|
||||
foreach($dirthemes as $dirtheme)
|
||||
{
|
||||
echo '"'.$dirtheme.'" ';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '<tr><td colspan="'.$colspan.'">';
|
||||
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td><div align="center">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
|
||||
|
||||
$i=0;
|
||||
foreach($dirthemes as $dir)
|
||||
$i = 0;
|
||||
foreach ($dirthemes as $dir)
|
||||
{
|
||||
//print $dirroot.$dir;exit;
|
||||
$dirtheme=dol_buildpath($dir,0); // This include loop on $conf->file->dol_document_root
|
||||
$urltheme=dol_buildpath($dir,1);
|
||||
$dirtheme = dol_buildpath($dir, 0); // This include loop on $conf->file->dol_document_root
|
||||
$urltheme = dol_buildpath($dir, 1);
|
||||
|
||||
if (is_dir($dirtheme))
|
||||
{
|
||||
$handle=opendir($dirtheme);
|
||||
$handle = opendir($dirtheme);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($subdir = readdir($handle))!==false)
|
||||
while (($subdir = readdir($handle)) !== false)
|
||||
{
|
||||
if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
|
||||
&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
|
||||
&& substr($subdir, 0, 3) <> 'CVS' && !preg_match('/common|phones/i', $subdir))
|
||||
{
|
||||
// Disable not stable themes (dir ends with _exp or _dev)
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i',$subdir)) continue;
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i',$subdir)) continue;
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue;
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i', $subdir)) continue;
|
||||
|
||||
print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
|
||||
$file=$dirtheme."/".$subdir."/thumb.png";
|
||||
$url=$urltheme."/".$subdir."/thumb.png";
|
||||
if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST('optioncss','alpha',1)?'&optioncss='.GETPOST('optioncss','alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
|
||||
if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
|
||||
else $title=$langs->trans("ShowPreview");
|
||||
print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
|
||||
$file = $dirtheme."/".$subdir."/thumb.png";
|
||||
$url = $urltheme."/".$subdir."/thumb.png";
|
||||
if (!file_exists($file)) $url = DOL_URL_ROOT.'/public/theme/common/nophoto.png';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].($edit ? '?action=edit&theme=' : '?theme=').$subdir.(GETPOST('optioncss', 'alpha', 1) ? '&optioncss='.GETPOST('optioncss', 'alpha', 1) : '').($fuser ? '&id='.$fuser->id : '').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
|
||||
if ($subdir == $conf->global->MAIN_THEME) $title = $langs->trans("ThemeCurrentlyActive");
|
||||
else $title = $langs->trans("ShowPreview");
|
||||
print '<img class="img-skinthumb shadow" src="'.$url.'" alt="'.$title.'" title="'.$title.'" style="border: none; margin-bottom: 5px;">';
|
||||
print '</a><br>';
|
||||
if ($subdir == $selected_theme)
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
|
||||
print '<input '.($edit ? '' : 'disabled').' type="radio" class="themethumbs" style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
|
||||
print '<input '.($edit ? '' : 'disabled').' type="radio" class="themethumbs" style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
@@ -425,6 +421,47 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// Set variables of theme
|
||||
$colorbackhmenu1 = '';
|
||||
$colorbackvmenu1 = '';
|
||||
$colortexttitlenotab = '';
|
||||
$colorbacktitle1 = '';
|
||||
$colortexttitle = '';
|
||||
$colorbacklineimpair1 = '';
|
||||
$colorbacklinepair1 = '';
|
||||
$colortextlink = '';
|
||||
$colorbacklinepairhover = '';
|
||||
$colorbacklinepairhover = '';
|
||||
$colorbacklinepairchecked = '';
|
||||
if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php')) {
|
||||
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
|
||||
}
|
||||
|
||||
// Show logo
|
||||
if ($foruserprofile)
|
||||
{
|
||||
// Nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show logo
|
||||
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableShowLogo").'</td><td>';
|
||||
if ($edit)
|
||||
{
|
||||
print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print yn($conf->global->MAIN_SHOW_LOGO);
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
/*
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("EnableShowLogo").'</td><td>' . yn($conf->global->MAIN_SHOW_LOGO) . '</td>';
|
||||
print "</tr>";*/
|
||||
}
|
||||
|
||||
|
||||
// TopMenuDisableImages
|
||||
if ($foruserprofile)
|
||||
{
|
||||
@@ -432,7 +469,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("TopMenuDisableImages").'</td>';
|
||||
print '<td>'.($conf->global->THEME_TOPMENU_DISABLE_IMAGE?$conf->global->THEME_TOPMENU_DISABLE_IMAGE:$langs->trans("Default")).'</td>';
|
||||
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_THEME_TOPMENU_DISABLE_IMAGE" id="check_THEME_TOPMENU_DISABLE_IMAGE" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TEXTLINK)?" checked":"");
|
||||
print '<td class="left" class="nowrap" width="20%"><input name="check_THEME_TOPMENU_DISABLE_IMAGE" id="check_THEME_TOPMENU_DISABLE_IMAGE" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TEXTLINK)?" checked":"");
|
||||
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
|
||||
print '> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
print '<td>';
|
||||
@@ -451,10 +488,10 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
}
|
||||
else
|
||||
{
|
||||
$default=$langs->trans('No');
|
||||
$default = $langs->trans('No');
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("TopMenuDisableImages").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
print '<td colspan="'.($colspan - 1).'">';
|
||||
if ($edit)
|
||||
{
|
||||
print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1);
|
||||
@@ -467,6 +504,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Background color THEME_ELDY_BACKBODY
|
||||
@@ -476,7 +514,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
|
||||
print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).'</td>';
|
||||
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_THEME_ELDY_TOPMENU_BACK1" id="check_THEME_ELDY_TOPMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
|
||||
print '<td class="nowrap left" width="20%"><input name="check_THEME_ELDY_TOPMENU_BACK1" id="check_THEME_ELDY_TOPMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
|
||||
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
|
||||
print '> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
print '<td>';
|
||||
@@ -497,15 +535,15 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("BackgroundColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
print '<td colspan="'.($colspan - 1).'">';
|
||||
//var_dump($conf->global->THEME_ELDY_BACKBODY);
|
||||
if ($edit)
|
||||
{
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY,array()),''),'THEME_ELDY_BACKBODY','formcolor',1).' ';
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY, array()), ''), 'THEME_ELDY_BACKBODY', 'formcolor', 1).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY,array()),'');
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKBODY, array()), '');
|
||||
if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
else print $langs->trans("Default");
|
||||
}
|
||||
@@ -513,6 +551,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// TopMenuBackgroundColor
|
||||
@@ -522,7 +561,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
|
||||
print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TOPMENU_BACK1:$langs->trans("Default")).'</td>';
|
||||
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_THEME_ELDY_TOPMENU_BACK1" id="check_THEME_ELDY_TOPMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
|
||||
print '<td class="nowrap left" width="20%"><input name="check_THEME_ELDY_TOPMENU_BACK1" id="check_THEME_ELDY_TOPMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
|
||||
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
|
||||
print '> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
print '<td>';
|
||||
@@ -541,19 +580,18 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
}
|
||||
else
|
||||
{
|
||||
$default='5a6482';
|
||||
if ($conf->theme == 'md') $default='5a3278';
|
||||
$default=(empty($colorbackhmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackhmenu1)));
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
if ($edit)
|
||||
{
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''),'THEME_ELDY_TOPMENU_BACK1','formcolor',1).' ';
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1, array()), ''), 'THEME_ELDY_TOPMENU_BACK1', 'formcolor', 1).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),'');
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1, array()), '');
|
||||
if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
else print $langs->trans("Default");
|
||||
}
|
||||
@@ -561,6 +599,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// LeftMenuBackgroundColor
|
||||
@@ -570,7 +609,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
|
||||
print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_VERMENU_BACK1:$langs->trans("Default")).'</td>';
|
||||
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_THEME_ELDY_VERMENU_BACK1" id="check_THEME_ELDY_VERMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
|
||||
print '<td class="nowrap left" width="20%"><input name="check_THEME_ELDY_VERMENU_BACK1" id="check_THEME_ELDY_VERMENU_BACK1" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TOPMENU_BACK1)?" checked":"");
|
||||
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
|
||||
print '> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
print '<td>';
|
||||
@@ -589,19 +628,18 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
}
|
||||
else
|
||||
{
|
||||
$default='f0f0f0';
|
||||
if ($conf->theme == 'md') $default='ffffff';
|
||||
$default=(empty($colorbackvmenu1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbackvmenu1)));
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("LeftMenuBackgroundColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
if ($edit)
|
||||
{
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1,array()),''),'THEME_ELDY_VERMENU_BACK1','formcolor',1).' ';
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1, array()), ''), 'THEME_ELDY_VERMENU_BACK1', 'formcolor', 1).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1,array()),'');
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_VERMENU_BACK1, array()), '');
|
||||
if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
else print $langs->trans("Default");
|
||||
}
|
||||
@@ -609,28 +647,29 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// TextTitleColor for title of Pages
|
||||
if ($foruserprofile)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$default=(empty($colortexttitlenotab) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitlenotab)));
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("TextTitleColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
print '<td colspan="'.($colspan - 1).'">';
|
||||
if ($edit)
|
||||
{
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLENOTAB,array()),''),'THEME_ELDY_TEXTTITLENOTAB','formcolor',1).' ';
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLENOTAB, array()), ''), 'THEME_ELDY_TEXTTITLENOTAB', 'formcolor', 1).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLENOTAB, $langs->trans("Default"));
|
||||
}
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #643c14">643c14</span></strong>) ';
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #'.$default.'">'.$default.'</span></strong>) ';
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
@@ -641,23 +680,23 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
// BackgroundTableTitleColor
|
||||
if ($foruserprofile)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$default=(empty($colorbacktitle1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacktitle1)));
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("BackgroundTableTitleColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
print '<td colspan="'.($colspan - 1).'">';
|
||||
if ($edit)
|
||||
{
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKTITLE1,array()),''),'THEME_ELDY_BACKTITLE1','formcolor',1).' ';
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BACKTITLE1, array()), ''), 'THEME_ELDY_BACKTITLE1', 'formcolor', 1).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $formother->showColor($conf->global->THEME_ELDY_BACKTITLE1, $langs->trans("Default"));
|
||||
}
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong>f0f0f0</strong>) '; // $colorbacktitle1 in CSS
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong>'.$default.'</strong>) '; // $colorbacktitle1 in CSS
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
@@ -668,23 +707,23 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
// TextTitleColor
|
||||
if ($foruserprofile)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$default=(empty($colortexttitle) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortexttitle)));
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("BackgroundTableTitleTextColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
print '<td colspan="'.($colspan - 1).'">';
|
||||
if ($edit)
|
||||
{
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLE,array()),''),'THEME_ELDY_TEXTTITLE','formcolor',1).' ';
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTTITLE, array()), ''), 'THEME_ELDY_TEXTTITLE', 'formcolor', 1).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLE, $langs->trans("Default"));
|
||||
}
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #000000">000000</span></strong>) ';
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #'.$default.'">'.$default.'</span></strong>) ';
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
@@ -695,23 +734,21 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
// BackgroundTableLineOddColor
|
||||
if ($foruserprofile)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$default='ffffff';
|
||||
if ($conf->theme == 'md') $default='ffffff';
|
||||
$default=(empty($colorbacklineimpair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklineimpair1)));
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("BackgroundTableLineOddColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
if ($edit)
|
||||
{
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1,array()),''),'THEME_ELDY_LINEIMPAIR1','formcolor',1).' ';
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), ''), 'THEME_ELDY_LINEIMPAIR1', 'formcolor', 1).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1,array()),'');
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEIMPAIR1, array()), '');
|
||||
if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
else print $langs->trans("Default");
|
||||
}
|
||||
@@ -719,28 +756,27 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// BackgroundTableLineEvenColor
|
||||
if ($foruserprofile)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$default='f8f8f8';
|
||||
if ($conf->theme == 'md') $default='f8f8f8';
|
||||
$default=(empty($colorbacklinepair1) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepair1)));
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("BackgroundTableLineEvenColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
if ($edit)
|
||||
{
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1,array()),''),'THEME_ELDY_LINEPAIR1','formcolor',1).' ';
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), ''), 'THEME_ELDY_LINEPAIR1', 'formcolor', 1).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1,array()),'');
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_LINEPAIR1, array()), '');
|
||||
if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
else print $langs->trans("Default");
|
||||
}
|
||||
@@ -748,6 +784,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Text LinkColor
|
||||
@@ -757,7 +794,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
|
||||
print '<td>'.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_TEXTLINK:$langs->trans("Default")).'</td>';
|
||||
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_THEME_ELDY_TEXTLINK" id="check_THEME_ELDY_TEXTLINK" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TEXTLINK)?" checked":"");
|
||||
print '<td class="nowrap left" width="20%"><input name="check_THEME_ELDY_TEXTLINK" id="check_THEME_ELDY_TEXTLINK" type="checkbox" '.(! empty($object->conf->THEME_ELDY_TEXTLINK)?" checked":"");
|
||||
print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo
|
||||
print '> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
print '<td>';
|
||||
@@ -776,16 +813,18 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
}
|
||||
else
|
||||
{
|
||||
$default=(empty($colortextlink) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colortextlink)));
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("LinkColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
print '<td colspan="'.($colspan - 1).'">';
|
||||
if ($edit)
|
||||
{
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),''),'THEME_ELDY_TEXTLINK','formcolor',1).' ';
|
||||
print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK, array()), ''), 'THEME_ELDY_TEXTLINK', 'formcolor', 1).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),'');
|
||||
$color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK, array()), '');
|
||||
if ($color) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
else
|
||||
{
|
||||
@@ -794,10 +833,11 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print $langs->trans("Default");
|
||||
}
|
||||
}
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #000078">000078</span></strong>) ';
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong><span style="color: #'.$default.'">'.$default.'</span></strong>) ';
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Use Hover
|
||||
@@ -806,38 +846,40 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
/* Must first change option to choose color of highlight instead of yes or no.
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("HighlightLinesOnMouseHover").'</td>';
|
||||
print '<td><input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER" disabled="disabled" type="checkbox" '.($conf->global->THEME_ELDY_USE_HOVER?" checked":"").'></td>';
|
||||
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
print '<td><input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled="disabled"').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
|
||||
print '<td><input name="check_THEME_ELDY_USE_HOVER" disabled="disabled" type="checkbox" '.($conf->global->THEME_ELDY_USE_HOVER?" checked":"").'></td>';
|
||||
print '<td class="nowrap left" width="20%"><input name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
print '<td><input name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled="disabled"').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
|
||||
print ' ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
*/
|
||||
}
|
||||
else {
|
||||
$default=(empty($colorbacklinepairhover) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairhover)));
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("HighlightLinesColor").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
//print '<input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
|
||||
//print '<input name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
|
||||
//print ' ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
|
||||
if ($edit)
|
||||
{
|
||||
if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
|
||||
else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
|
||||
print $formother->selectColor($color,'THEME_ELDY_USE_HOVER','formcolor',1).' ';
|
||||
if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color=colorArrayToHex(colorStringToArray($colorbacklinepairhover));
|
||||
else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), '');
|
||||
print $formother->selectColor($color, 'THEME_ELDY_USE_HOVER', 'formcolor', 1).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
|
||||
else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),'');
|
||||
if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color=colorArrayToHex(colorStringToArray($colorbacklinepairhover));
|
||||
else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER, array()), '');
|
||||
if ($color)
|
||||
{
|
||||
if ($color != 'edf4fb') print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
if ($color != colorArrayToHex(colorStringToArray($colorbacklinepairhover))) print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
else print $langs->trans("Default");
|
||||
}
|
||||
else print $langs->trans("None");
|
||||
else print $langs->trans("Default");
|
||||
}
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong>edf4fb</strong>) ';
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
@@ -849,9 +891,9 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
/* Must first change option to choose color of highlight instead of yes or no.
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("HighlightLinesOnMouseHover").'</td>';
|
||||
print '<td><input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER" disabled="disabled" type="checkbox" '.($conf->global->THEME_ELDY_USE_HOVER?" checked":"").'></td>';
|
||||
print '<td align="left" class="nowrap" width="20%"><input '.$bc[$var].' name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
print '<td><input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled="disabled"').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
|
||||
print '<td><input name="check_THEME_ELDY_USE_HOVER" disabled="disabled" type="checkbox" '.($conf->global->THEME_ELDY_USE_HOVER?" checked":"").'></td>';
|
||||
print '<td class="nowrap left" width="20%"><input name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
|
||||
print '<td><input name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled="disabled"').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
|
||||
print ' ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@@ -859,34 +901,127 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
}
|
||||
else
|
||||
{
|
||||
$default=(empty($colorbacklinepairchecked) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairchecked)));
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("HighlightLinesChecked").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
//print '<input '.$bc[$var].' name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
|
||||
print '<td colspan="'.($colspan - 1).'">';
|
||||
//print '<input name="check_THEME_ELDY_USE_HOVER"'.($edit?'':' disabled').' type="checkbox" '.($hoverdisabled?"":" checked").'>';
|
||||
//print ' ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
|
||||
if ($edit)
|
||||
{
|
||||
if ($conf->global->THEME_ELDY_USE_CHECKED == '1') $color='ffefbb';
|
||||
else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_CHECKED,array()),'');
|
||||
print $formother->selectColor($color,'THEME_ELDY_USE_CHECKED','formcolor',1).' ';
|
||||
if ($conf->global->THEME_ELDY_USE_CHECKED == '1') $color = 'e6edf0';
|
||||
else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_CHECKED, array()), '');
|
||||
print $formother->selectColor($color, 'THEME_ELDY_USE_CHECKED', 'formcolor', 1).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($conf->global->THEME_ELDY_USE_CHECKED == '1') $color='ffefbb';
|
||||
else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_CHECKED,array()),'');
|
||||
if ($conf->global->THEME_ELDY_USE_CHECKED == '1') $color = 'e6edf0';
|
||||
else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_CHECKED, array()), '');
|
||||
if ($color)
|
||||
{
|
||||
if ($color != 'ffefbb') print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
if ($color != 'e6edf0') print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
|
||||
else print $langs->trans("Default");
|
||||
}
|
||||
else print $langs->trans("None");
|
||||
else print $langs->trans("Default");
|
||||
}
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong>ffefbb</strong>) ';
|
||||
print ' <span class="nowraponall">('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
|
||||
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Use MAIN_OPTIMIZEFORTEXTBROWSER
|
||||
if ($foruserprofile)
|
||||
{
|
||||
//$default=yn($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER);
|
||||
$default = $langs->trans('No');
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("MAIN_OPTIMIZEFORTEXTBROWSER").'</td>';
|
||||
print '<td colspan="'.($colspan - 1).'">';
|
||||
if ($edit)
|
||||
{
|
||||
print $form->selectyesno('MAIN_OPTIMIZEFORTEXTBROWSER', $fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
|
||||
{
|
||||
print yn($fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER);
|
||||
}
|
||||
else
|
||||
{
|
||||
print yn(1);
|
||||
if (empty($fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER)) print ' ('.$langs->trans("ForcedByGlobalSetup").')';
|
||||
}
|
||||
}
|
||||
print ' ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
|
||||
print $form->textwithpicto('', $langs->trans("MAIN_OPTIMIZEFORTEXTBROWSERDesc"));
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
/*var_dump($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER);
|
||||
$default=$langs->trans('No');
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("MAIN_OPTIMIZEFORTEXTBROWSER").'</td>';
|
||||
print '<td colspan="'.($colspan-1).'">';
|
||||
if ($edit)
|
||||
{
|
||||
print $form->selectyesno('MAIN_OPTIMIZEFORTEXTBROWSER', $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print yn($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER);
|
||||
}
|
||||
print ' ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
|
||||
print $form->textwithpicto('', $langs->trans("MAIN_OPTIMIZEFORTEXTBROWSERDesc"));
|
||||
print '</span>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
// Use MAIN_OPTIMIZEFORTEXTBROWSER
|
||||
if ($foruserprofile)
|
||||
{
|
||||
//$default=yn($conf->global->MAIN_OPTIMIZEFORCOLORBLIND);
|
||||
$default = $langs->trans('No');
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("MAIN_OPTIMIZEFORCOLORBLIND").'</td>';
|
||||
print '<td colspan="'.($colspan - 1).'">';
|
||||
|
||||
$colorBlindOptions = array(
|
||||
0 => $langs->trans('No'),
|
||||
'flashy' => $langs->trans('Flashy'),
|
||||
'protanopia' => $langs->trans('Protanopia'),
|
||||
'deuteranopes' => $langs->trans('Deuteranopes'),
|
||||
'tritanopes' => $langs->trans('Tritanopes'),
|
||||
);
|
||||
|
||||
if ($edit)
|
||||
{
|
||||
print $form->selectArray('MAIN_OPTIMIZEFORCOLORBLIND', $colorBlindOptions, $fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!empty($fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND) && isset($colorBlindOptions[$fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND])) {
|
||||
print $colorBlindOptions[$fuser->conf->MAIN_OPTIMIZEFORCOLORBLIND];
|
||||
}
|
||||
else {
|
||||
print yn(0);
|
||||
}
|
||||
}
|
||||
print ' ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
|
||||
print $form->textwithpicto('', $langs->trans("MAIN_OPTIMIZEFORCOLORBLINDDesc"));
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
/* Copyright (C) 2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -13,7 +13,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -45,16 +45,16 @@ function vat_prepare_head($object)
|
||||
// Entries must be declared in modules descriptor with line
|
||||
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $tab,'vat');
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $tab, 'vat');
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$tab][0] = DOL_URL_ROOT.'/compta/tva/document.php?id='.$object->id;
|
||||
$head[$tab][1] = $langs->trans("Documents");
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
|
||||
if (($nbFiles+$nbLinks) > 0) $head[$tab][1].= '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>';
|
||||
$head[$tab][2] = 'documents';
|
||||
$tab++;
|
||||
|
||||
@@ -63,7 +63,7 @@ function vat_prepare_head($object)
|
||||
$head[$tab][2] = 'info';
|
||||
$tab++;
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$tab,'vat','remove');
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $tab, 'vat', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
495
htdocs/core/lib/website2.lib.php
Normal file
495
htdocs/core/lib/website2.lib.php
Normal file
@@ -0,0 +1,495 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/lib/website2.lib.php
|
||||
* \ingroup website
|
||||
* \brief Library for website module (rare functions not required for execution of website)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filemaster Full path of filename master.inc.php for website to generate
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveMasterFile($filemaster)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// Now generate the master.inc.php page
|
||||
dol_syslog("We regenerate the master file");
|
||||
dol_delete_file($filemaster);
|
||||
|
||||
$mastercontent = '<?php'."\n";
|
||||
$mastercontent .= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
|
||||
$mastercontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
|
||||
$mastercontent .= '?>'."\n";
|
||||
$result = file_put_contents($filemaster, $mastercontent);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filealias Full path of filename to generate
|
||||
* @param Website $object Object website
|
||||
* @param WebsitePage $objectpage Object websitepage
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSavePageAlias($filealias, $object, $objectpage)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
|
||||
dol_syslog("dolSavePageAlias We regenerate the alias page filealias=".$filealias);
|
||||
|
||||
$aliascontent = '<?php'."\n";
|
||||
$aliascontent .= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
|
||||
$aliascontent .= 'global $dolibarr_main_data_root;'."\n";
|
||||
$aliascontent .= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
|
||||
$aliascontent .= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
|
||||
$aliascontent .= '?>'."\n";
|
||||
$result = file_put_contents($filealias, $aliascontent);
|
||||
if (!empty($conf->global->MAIN_UMASK)) {
|
||||
@chmod($filealias, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
|
||||
return ($result ?true:false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filetpl Full path of filename to generate
|
||||
* @param Website $object Object website
|
||||
* @param WebsitePage $objectpage Object websitepage
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
|
||||
{
|
||||
global $conf, $db;
|
||||
|
||||
// Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
|
||||
dol_syslog("We regenerate the tpl page filetpl=".$filetpl);
|
||||
|
||||
dol_delete_file($filetpl);
|
||||
|
||||
$shortlangcode = '';
|
||||
if ($objectpage->lang) $shortlangcode = preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en
|
||||
|
||||
$tplcontent = '';
|
||||
$tplcontent .= "<?php // BEGIN PHP\n";
|
||||
$tplcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
|
||||
$tplcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n";
|
||||
$tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
|
||||
$tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
|
||||
$tplcontent .= "ob_start();\n";
|
||||
$tplcontent .= "// END PHP ?>\n";
|
||||
if (!empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5))
|
||||
{
|
||||
$tplcontent .= "<!DOCTYPE html>\n";
|
||||
}
|
||||
$tplcontent .= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"' : '').'>'."\n";
|
||||
$tplcontent .= '<head>'."\n";
|
||||
$tplcontent .= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
|
||||
$tplcontent .= '<meta charset="utf-8">'."\n";
|
||||
$tplcontent .= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
|
||||
$tplcontent .= '<meta name="robots" content="index, follow" />'."\n";
|
||||
$tplcontent .= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
|
||||
$tplcontent .= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
|
||||
$tplcontent .= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
|
||||
$tplcontent .= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
|
||||
$tplcontent .= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
|
||||
$tplcontent .= '<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).'" />'."\n";
|
||||
// Add translation reference (main language)
|
||||
if ($object->isMultiLang()) {
|
||||
// Add myself
|
||||
$tplcontent .= '<link rel="alternate" hreflang="'.$shortlangcode.'" href="'.($object->fk_default_home == $objectpage->id ? '/' : '/'.$objectpage->pageurl.'.php').'" />'."\n";
|
||||
// Add page "translation of"
|
||||
$translationof = $objectpage->fk_page;
|
||||
if ($translationof) {
|
||||
$tmppage = new WebsitePage($db);
|
||||
$tmppage->fetch($translationof);
|
||||
if ($tmppage->id > 0) {
|
||||
$tmpshortlangcode = '';
|
||||
if ($tmppage->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $tmppage->lang); // en_US or en-US -> en
|
||||
if ($tmpshortlangcode != $shortlangcode) {
|
||||
$tplcontent .= '<link rel="alternate" hreflang="'.$tmpshortlangcode.'" href="'.($object->fk_default_home == $tmppage->id ? '/' : '/'.$tmppage->pageurl.'.php').'" />'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add "has translation pages"
|
||||
$sql = 'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.'website_page where fk_page IN ('.$objectpage->id.($translationof ? ", ".$translationof : "").")";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_rows = $db->num_rows($resql);
|
||||
if ($num_rows > 0)
|
||||
{
|
||||
while ($obj = $db->fetch_object($resql))
|
||||
{
|
||||
$tmpshortlangcode = '';
|
||||
if ($obj->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $obj->lang); // en_US or en-US -> en
|
||||
if ($tmpshortlangcode != $shortlangcode) {
|
||||
$tplcontent .= '<link rel="alternate" hreflang="'.$tmpshortlangcode.'" href="'.($object->fk_default_home == $obj->id ? '/' : '/'.$obj->pageurl.'.php').'" />'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
}
|
||||
// Add canonical reference
|
||||
$tplcontent .= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n";
|
||||
// Add manifest.json on homepage
|
||||
$tplcontent .= '<?php if ($website->use_manifest) { print \'<link rel="manifest" href="/manifest.json.php" />\'."\n"; } ?>'."\n";
|
||||
$tplcontent .= '<!-- Include link to CSS file -->'."\n";
|
||||
$tplcontent .= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" type="text/css" />'."\n";
|
||||
$tplcontent .= '<!-- Include HTML header from common file -->'."\n";
|
||||
$tplcontent .= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
|
||||
$tplcontent .= '<!-- Include HTML header from page header block -->'."\n";
|
||||
$tplcontent .= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
|
||||
$tplcontent .= '</head>'."\n";
|
||||
|
||||
$tplcontent .= '<!-- File generated by Dolibarr website module editor -->'."\n";
|
||||
$tplcontent .= '<body id="bodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n";
|
||||
$tplcontent .= $objectpage->content."\n";
|
||||
$tplcontent .= '</body>'."\n";
|
||||
$tplcontent .= '</html>'."\n";
|
||||
|
||||
$tplcontent .= '<?php // BEGIN PHP'."\n";
|
||||
$tplcontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "html", '.$objectpage->id.');'."\n";
|
||||
$tplcontent .= "// END PHP ?>"."\n";
|
||||
|
||||
//var_dump($filetpl);exit;
|
||||
$result = file_put_contents($filetpl, $tplcontent);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save content of the index.php and wrapper.php page
|
||||
*
|
||||
* @param string $pathofwebsite Path of website root
|
||||
* @param string $fileindex Full path of file index.php
|
||||
* @param string $filetpl File tpl to index.php page redirect to
|
||||
* @param string $filewrapper Full path of file wrapper.php
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$result1 = false;
|
||||
$result2 = false;
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
|
||||
dol_delete_file($fileindex);
|
||||
$indexcontent = '<?php'."\n";
|
||||
$indexcontent .= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
|
||||
$indexcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
|
||||
$indexcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
|
||||
$indexcontent .= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
|
||||
$indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
|
||||
$indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
|
||||
$indexcontent .= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
|
||||
$indexcontent .= "}\n";
|
||||
$indexcontent .= "include_once './".basename($filetpl)."'\n";
|
||||
$indexcontent .= '// END PHP ?>'."\n";
|
||||
$result1 = file_put_contents($fileindex, $indexcontent);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
dol_delete_file($filewrapper);
|
||||
|
||||
$wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
|
||||
|
||||
$result2 = file_put_contents($filewrapper, $wrappercontent);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return ($result1 && $result2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filehtmlheader Full path of filename to generate
|
||||
* @param string $htmlheadercontent Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save html header into ".$filehtmlheader);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filehtmlheader, $htmlheadercontent);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filecss Full path of filename to generate
|
||||
* @param string $csscontent Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveCssFile($filecss, $csscontent)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save css file into ".$filecss);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filecss, $csscontent);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filejs Full path of filename to generate
|
||||
* @param string $jscontent Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveJsFile($filejs, $jscontent)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save js file into ".$filejs);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filejs, $jscontent);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filejs, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filerobot Full path of filename to generate
|
||||
* @param string $robotcontent Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveRobotFile($filerobot, $robotcontent)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save robot file into ".$filerobot);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filerobot, $robotcontent);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filehtaccess Full path of filename to generate
|
||||
* @param string $htaccess Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveHtaccessFile($filehtaccess, $htaccess)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save htaccess file into ".$filehtaccess);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filehtaccess, $htaccess);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $file Full path of filename to generate
|
||||
* @param string $content Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveManifestJson($file, $content)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save manifest.js.php file into ".$file);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($file, $content);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $file Full path of filename to generate
|
||||
* @param string $content Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveReadme($file, $content)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save README.md file into ".$file);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($file, $content);
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show list of themes. Show all thumbs of themes/skins
|
||||
*
|
||||
* @param Website $website Object website to load the tempalte into
|
||||
* @return void
|
||||
*/
|
||||
function showWebsiteTemplates(Website $website)
|
||||
{
|
||||
global $conf, $langs, $db, $form;
|
||||
global $bc;
|
||||
|
||||
$dirthemes = array('/doctemplates/websites');
|
||||
if (!empty($conf->modules_parts['websitetemplates'])) // Using this feature slow down application
|
||||
{
|
||||
foreach ($conf->modules_parts['websitetemplates'] as $reldir)
|
||||
{
|
||||
$dirthemes = array_merge($dirthemes, (array) ($reldir.'doctemplates/websites'));
|
||||
}
|
||||
}
|
||||
$dirthemes = array_unique($dirthemes);
|
||||
// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
|
||||
|
||||
$colspan = 2;
|
||||
|
||||
$thumbsbyrow = 6;
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
// Title
|
||||
print '<tr class="liste_titre"><th class="titlefield"></th>';
|
||||
print '<th class="right">';
|
||||
$url = 'https://www.dolistore.com/43-web-site-templates';
|
||||
print '<a href="'.$url.'" target="_blank">';
|
||||
print $langs->trans('DownloadMoreSkins');
|
||||
print '</a>';
|
||||
print '</th></tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("ThemeDir").'</td>';
|
||||
print '<td>';
|
||||
foreach ($dirthemes as $dirtheme)
|
||||
{
|
||||
echo '"'.$dirtheme.'" ';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td colspan="'.$colspan.'">';
|
||||
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
|
||||
|
||||
$i = 0;
|
||||
foreach ($dirthemes as $dir)
|
||||
{
|
||||
//print $dirroot.$dir;exit;
|
||||
$dirtheme = DOL_DATA_ROOT.$dir; // This include loop on $conf->file->dol_document_root
|
||||
if (is_dir($dirtheme))
|
||||
{
|
||||
$handle = opendir($dirtheme);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($subdir = readdir($handle)) !== false)
|
||||
{
|
||||
if (is_file($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
|
||||
&& substr($subdir, 0, 3) <> 'CVS' && preg_match('/\.zip$/i', $subdir))
|
||||
{
|
||||
$subdirwithoutzip = preg_replace('/\.zip$/i', '', $subdir);
|
||||
|
||||
// Disable not stable themes (dir ends with _exp or _dev)
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 2 && preg_match('/_dev$/i', $subdir)) continue;
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/_exp$/i', $subdir)) continue;
|
||||
|
||||
print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
|
||||
|
||||
$file = $dirtheme."/".$subdirwithoutzip.".jpg";
|
||||
$url = DOL_URL_ROOT.'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.".jpg";
|
||||
|
||||
if (!file_exists($file)) $url = DOL_URL_ROOT.'/public/theme/common/nophoto.png';
|
||||
|
||||
$originalfile = basename($file);
|
||||
$entity = $conf->entity;
|
||||
$modulepart = 'doctemplateswebsite';
|
||||
$cache = '';
|
||||
$title = $file;
|
||||
|
||||
$ret = '';
|
||||
$urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 1, '&entity='.$entity);
|
||||
if (!empty($urladvanced)) $ret .= '<a class="'.$urladvanced['css'].'" target="'.$urladvanced['target'].'" mime="'.$urladvanced['mime'].'" href="'.$urladvanced['url'].'">';
|
||||
else $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
|
||||
print $ret;
|
||||
print '<img class="img-skinthumb shadow" src="'.$url.'" border="0" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
|
||||
print '</a>';
|
||||
|
||||
print '<br>';
|
||||
print $subdir.' ('.dol_print_size(dol_filesize($dirtheme."/".$subdir), 1, 1).')';
|
||||
print '<br><a href="'.$_SERVER["PHP_SELF"].'?action=importsiteconfirm&website='.$website->ref.'&templateuserfile='.$subdir.'" class="button">'.$langs->trans("Load").'</a>';
|
||||
print '</div>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</div></td></tr></table>';
|
||||
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
@@ -12,8 +12,8 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@
|
||||
* @param string $errorlabel Error string label
|
||||
* @return User Return user object identified by login/pass/entity into authentication array
|
||||
*/
|
||||
function check_authentication($authentication,&$error,&$errorcode,&$errorlabel)
|
||||
function check_authentication($authentication, &$error, &$errorcode, &$errorlabel)
|
||||
{
|
||||
global $db,$conf,$langs;
|
||||
global $dolibarr_main_authentication,$dolibarr_auto_user;
|
||||
@@ -53,13 +53,13 @@ function check_authentication($authentication,&$error,&$errorcode,&$errorlabel)
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result=$fuser->fetch('',$authentication['login'],'',0);
|
||||
$result=$fuser->fetch('', $authentication['login'], '', 0);
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
$errorcode='ERROR_FETCH_USER'; $errorlabel='A technical error occurred during fetch of user';
|
||||
}
|
||||
else if ($result == 0)
|
||||
elseif ($result == 0)
|
||||
{
|
||||
$error++;
|
||||
$errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password';
|
||||
@@ -81,10 +81,10 @@ function check_authentication($authentication,&$error,&$errorcode,&$errorlabel)
|
||||
// Authentication mode: forceuser
|
||||
if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) $dolibarr_auto_user='auto';
|
||||
// Set authmode
|
||||
$authmode=explode(',',$dolibarr_main_authentication);
|
||||
$authmode=explode(',', $dolibarr_main_authentication);
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
$login = checkLoginPassEntity($authentication['login'],$authentication['password'],$authentication['entity'],$authmode);
|
||||
$login = checkLoginPassEntity($authentication['login'], $authentication['password'], $authentication['entity'], $authmode, 'ws');
|
||||
if (empty($login))
|
||||
{
|
||||
$error++;
|
||||
@@ -95,4 +95,3 @@ function check_authentication($authentication,&$error,&$errorcode,&$errorlabel)
|
||||
|
||||
return $fuser;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
@@ -25,497 +25,573 @@
|
||||
* Build a file from an array of events
|
||||
* All input params and data must be encoded in $conf->charset_output
|
||||
*
|
||||
* @param string $format 'vcal' or 'ical'
|
||||
* @param string $title Title of export
|
||||
* @param string $desc Description of export
|
||||
* @param array $events_array Array of events ('eid','startdate','duration','enddate','title','summary','category','email','url','desc','author')
|
||||
* @param string $outputfile Output file
|
||||
* @return int <0 if ko, Nb of events in file if ok
|
||||
* @param string $format "vcal" or "ical"
|
||||
* @param string $title Title of export
|
||||
* @param string $desc Description of export
|
||||
* @param array $events_array Array of events ("uid","startdate","duration","enddate","title","summary","category","email","url","desc","author")
|
||||
* @param string $outputfile Output file
|
||||
* @return int < 0 if ko, Nb of events in file if ok
|
||||
*/
|
||||
function build_calfile($format,$title,$desc,$events_array,$outputfile)
|
||||
function build_calfile($format, $title, $desc, $events_array, $outputfile)
|
||||
{
|
||||
global $conf,$langs;
|
||||
global $conf, $langs;
|
||||
|
||||
dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format);
|
||||
dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format);
|
||||
|
||||
if (empty($outputfile)) return -1;
|
||||
if (empty($outputfile))
|
||||
{
|
||||
// -1 = error
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Note: A cal file is an UTF8 encoded file
|
||||
$calfileh=fopen($outputfile,'w');
|
||||
if ($calfileh)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
$now=dol_now();
|
||||
$calfileh = fopen($outputfile, "w");
|
||||
|
||||
$encoding='';
|
||||
if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:';
|
||||
if ($calfileh)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
|
||||
|
||||
// Print header
|
||||
fwrite($calfileh,"BEGIN:VCALENDAR\n");
|
||||
fwrite($calfileh,"VERSION:2.0\n");
|
||||
fwrite($calfileh,"METHOD:PUBLISH\n");
|
||||
//fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."//EN\n");
|
||||
fwrite($calfileh,"PRODID:-//DOLIBARR ".DOL_VERSION."\n");
|
||||
fwrite($calfileh,"CALSCALE:GREGORIAN\n");
|
||||
fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n");
|
||||
fwrite($calfileh,"X-WR-CALDESC:".$encoding.format_cal($format,$desc)."\n");
|
||||
//fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n");
|
||||
if (! empty($conf->global->MAIN_AGENDA_EXPORT_CACHE)
|
||||
&& $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60){
|
||||
$hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour');
|
||||
$mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min');
|
||||
$ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec');
|
||||
fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
|
||||
$now = dol_now();
|
||||
$encoding = "";
|
||||
|
||||
if ($format === "vcal")
|
||||
{
|
||||
$encoding = "ENCODING=QUOTED-PRINTABLE:";
|
||||
}
|
||||
|
||||
foreach ($events_array as $key => $event)
|
||||
{
|
||||
$eventqualified=true;
|
||||
if ($eventqualified)
|
||||
{
|
||||
// See http://fr.wikipedia.org/wiki/ICalendar for format
|
||||
// See http://www.ietf.org/rfc/rfc2445.txt for RFC
|
||||
$uid = $event['uid'];
|
||||
$type = $event['type'];
|
||||
$startdate = $event['startdate'];
|
||||
$duration = $event['duration'];
|
||||
$enddate = $event['enddate'];
|
||||
$summary = $event['summary'];
|
||||
$category = $event['category'];
|
||||
$priority = $event['priority'];
|
||||
$fulldayevent = $event['fulldayevent'];
|
||||
$location = $event['location'];
|
||||
$email = $event['email'];
|
||||
$url = $event['url'];
|
||||
$transparency = $event['transparency']; // OPAQUE (busy) or TRANSPARENT (not busy)
|
||||
$description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
|
||||
$description=dol_string_nohtmltag($description,0); // Remove html tags
|
||||
$created = $event['created'];
|
||||
$modified = $event['modified'];
|
||||
// Print header
|
||||
fwrite($calfileh, "BEGIN:VCALENDAR\n");
|
||||
|
||||
// Uncomment for tests
|
||||
//$summary="Resume";
|
||||
//$description="Description";
|
||||
//$description="MemberValidatedInDolibarr gd gdf gd gdff\nNom: tgdf g dfgdf gfd r ter\nType: gdfgfdf dfg fd gfd gd gdf gdf gfd gdfg dfg ddf\nAuteur: AD01fg dgdgdfg df gdf gd";
|
||||
// version is always "2.0"
|
||||
fwrite($calfileh, "VERSION:2.0\n");
|
||||
|
||||
// Format
|
||||
$summary=format_cal($format,$summary);
|
||||
$description=format_cal($format,$description);
|
||||
$category=format_cal($format,$category);
|
||||
$location=format_cal($format,$location);
|
||||
fwrite($calfileh, "METHOD:PUBLISH\n");
|
||||
fwrite($calfileh, "PRODID:-//DOLIBARR ".DOL_VERSION."\n");
|
||||
fwrite($calfileh, "CALSCALE:GREGORIAN\n");
|
||||
fwrite($calfileh, "X-WR-CALNAME:".$encoding.format_cal($format, $title)."\n");
|
||||
fwrite($calfileh, "X-WR-CALDESC:".$encoding.format_cal($format, $desc)."\n");
|
||||
//fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n");
|
||||
|
||||
// Output the vCard/iCal VEVENT object
|
||||
/*
|
||||
Example from Google ical export for a 1 hour event:
|
||||
BEGIN:VEVENT
|
||||
DTSTART:20101103T120000Z
|
||||
DTEND:20101103T130000Z
|
||||
DTSTAMP:20101121T144902Z
|
||||
UID:4eilllcsq8r1p87ncg7vc8dbpk@google.com
|
||||
CREATED:20101121T144657Z
|
||||
DESCRIPTION:
|
||||
LAST-MODIFIED:20101121T144707Z
|
||||
LOCATION:
|
||||
SEQUENCE:0
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:Tâche 1 heure
|
||||
TRANSP:OPAQUE
|
||||
END:VEVENT
|
||||
if (! empty($conf->global->MAIN_AGENDA_EXPORT_CACHE) && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60)
|
||||
{
|
||||
$hh = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, "hour");
|
||||
$mm = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, "min");
|
||||
$ss = convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE, "sec");
|
||||
|
||||
Example from Google ical export for a 1 day event:
|
||||
BEGIN:VEVENT
|
||||
DTSTART;VALUE=DATE:20101102
|
||||
DTEND;VALUE=DATE:20101103
|
||||
DTSTAMP:20101121T144902Z
|
||||
UID:d09t43kcf1qgapu9efsmmo1m6k@google.com
|
||||
CREATED:20101121T144607Z
|
||||
DESCRIPTION:
|
||||
LAST-MODIFIED:20101121T144607Z
|
||||
LOCATION:
|
||||
SEQUENCE:0
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:Tâche 1 jour
|
||||
TRANSP:TRANSPARENT
|
||||
END:VEVENT
|
||||
*/
|
||||
if ($type == 'event')
|
||||
{
|
||||
fwrite($calfileh,"BEGIN:VEVENT\n");
|
||||
fwrite($calfileh,"UID:".$uid."\n");
|
||||
if (! empty($email))
|
||||
{
|
||||
fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
|
||||
fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
|
||||
}
|
||||
if (! empty($url))
|
||||
{
|
||||
fwrite($calfileh,"URL:".$url."\n");
|
||||
};
|
||||
fwrite($calfileh, "X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
|
||||
}
|
||||
|
||||
if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
|
||||
if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
|
||||
fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
|
||||
fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
|
||||
foreach ($events_array as $key => $event)
|
||||
{
|
||||
// See http://fr.wikipedia.org/wiki/ICalendar for format
|
||||
// See http://www.ietf.org/rfc/rfc2445.txt for RFC
|
||||
|
||||
/* Other keys:
|
||||
// Status values for a "VEVENT"
|
||||
statvalue = "TENTATIVE" ;Indicates event is
|
||||
;tentative.
|
||||
/ "CONFIRMED" ;Indicates event is
|
||||
;definite.
|
||||
/ "CANCELLED" ;Indicates event was
|
||||
// Status values for "VTODO".
|
||||
statvalue =/ "NEEDS-ACTION" ;Indicates to-do needs action.
|
||||
/ "COMPLETED" ;Indicates to-do completed.
|
||||
/ "IN-PROCESS" ;Indicates to-do in process of
|
||||
/ "CANCELLED" ;Indicates to-do was cancelled.
|
||||
// Status values for "VJOURNAL".
|
||||
statvalue =/ "DRAFT" ;Indicates journal is draft.
|
||||
/ "FINAL" ;Indicates journal is final.
|
||||
/ "CANCELLED" ;Indicates journal is removed.
|
||||
*/
|
||||
//fwrite($calfileh,"CLASS:PUBLIC\n"); // PUBLIC, PRIVATE, CONFIDENTIAL
|
||||
//fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n");
|
||||
//ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:eldy10@gmail.com
|
||||
// TODO: avoid use extra event array, use objects direct thahtwas created before
|
||||
|
||||
if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n");
|
||||
if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n");
|
||||
if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n");
|
||||
$uid = $event["uid"];
|
||||
$type = $event["type"];
|
||||
$startdate = $event["startdate"];
|
||||
$duration = $event["duration"];
|
||||
$enddate = $event["enddate"];
|
||||
$summary = $event["summary"];
|
||||
$category = $event["category"];
|
||||
$priority = $event["priority"];
|
||||
$fulldayevent = $event["fulldayevent"];
|
||||
$location = $event["location"];
|
||||
$email = $event["email"];
|
||||
$url = $event["url"];
|
||||
$transparency = $event["transparency"];
|
||||
$description = dol_string_nohtmltag(preg_replace("/<br[\s\/]?>/i", "\n", $event["desc"]), 0);
|
||||
$created = $event["created"];
|
||||
$modified = $event["modified"];
|
||||
$assignedUsers = $event["assignedUsers"];
|
||||
|
||||
// Date must be GMT dates
|
||||
// Current date
|
||||
fwrite($calfileh,"DTSTAMP:".dol_print_date($now,'dayhourxcard',true)."\n");
|
||||
// Start date
|
||||
$prefix='';
|
||||
$startdatef = dol_print_date($startdate,'dayhourxcard',true);
|
||||
if ($fulldayevent)
|
||||
{
|
||||
$prefix=';VALUE=DATE';
|
||||
$startdatef = dol_print_date($startdate,'dayxcard',false); // Local time
|
||||
}
|
||||
fwrite($calfileh,"DTSTART".$prefix.":".$startdatef."\n");
|
||||
// End date
|
||||
if ($fulldayevent)
|
||||
{
|
||||
if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($enddate)) $enddate=$startdate+$duration;
|
||||
}
|
||||
$prefix='';
|
||||
$enddatef = dol_print_date($enddate,'dayhourxcard',true);
|
||||
if ($fulldayevent)
|
||||
{
|
||||
$prefix=';VALUE=DATE';
|
||||
$enddatef = dol_print_date($enddate+1,'dayxcard',false);
|
||||
//$enddatef .= dol_print_date($enddate+1,'dayhourxcard',false); // Local time
|
||||
}
|
||||
fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n");
|
||||
fwrite($calfileh,'STATUS:CONFIRMED'."\n");
|
||||
if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n");
|
||||
if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n");
|
||||
fwrite($calfileh,"END:VEVENT\n");
|
||||
}
|
||||
// Format
|
||||
$summary = format_cal($format, $summary);
|
||||
$description = format_cal($format, $description);
|
||||
$category = format_cal($format, $category);
|
||||
$location = format_cal($format, $location);
|
||||
|
||||
// Output the vCard/iCal VTODO object
|
||||
// ...
|
||||
//PERCENT-COMPLETE:39
|
||||
// Output the vCard/iCal VEVENT object
|
||||
/*
|
||||
Example from Google ical export for a 1 hour event:
|
||||
BEGIN:VEVENT
|
||||
DTSTART:20101103T120000Z
|
||||
DTEND:20101103T130000Z
|
||||
DTSTAMP:20101121T144902Z
|
||||
UID:4eilllcsq8r1p87ncg7vc8dbpk@google.com
|
||||
CREATED:20101121T144657Z
|
||||
DESCRIPTION:
|
||||
LAST-MODIFIED:20101121T144707Z
|
||||
LOCATION:
|
||||
SEQUENCE:0
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:Tâche 1 heure
|
||||
TRANSP:OPAQUE
|
||||
END:VEVENT
|
||||
|
||||
// Output the vCard/iCal VJOURNAL object
|
||||
if ($type == 'journal')
|
||||
{
|
||||
fwrite($calfileh,"BEGIN:VJOURNAL\n");
|
||||
fwrite($calfileh,"UID:".$uid."\n");
|
||||
if (! empty($email))
|
||||
{
|
||||
fwrite($calfileh,"ORGANIZER:MAILTO:".$email."\n");
|
||||
fwrite($calfileh,"CONTACT:MAILTO:".$email."\n");
|
||||
}
|
||||
if (! empty($url))
|
||||
{
|
||||
fwrite($calfileh,"URL:".$url."\n");
|
||||
};
|
||||
Example from Google ical export for a 1 day event:
|
||||
BEGIN:VEVENT
|
||||
DTSTART;VALUE=DATE:20101102
|
||||
DTEND;VALUE=DATE:20101103
|
||||
DTSTAMP:20101121T144902Z
|
||||
UID:d09t43kcf1qgapu9efsmmo1m6k@google.com
|
||||
CREATED:20101121T144607Z
|
||||
DESCRIPTION:
|
||||
LAST-MODIFIED:20101121T144607Z
|
||||
LOCATION:
|
||||
SEQUENCE:0
|
||||
STATUS:CONFIRMED
|
||||
SUMMARY:Tâche 1 jour
|
||||
TRANSP:TRANSPARENT
|
||||
END:VEVENT
|
||||
*/
|
||||
|
||||
if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n");
|
||||
if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n");
|
||||
fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n");
|
||||
fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n");
|
||||
fwrite($calfileh,'STATUS:CONFIRMED'."\n");
|
||||
fwrite($calfileh,"CATEGORIES:".$category."\n");
|
||||
fwrite($calfileh,"LOCATION:".$location."\n");
|
||||
fwrite($calfileh,"TRANSP:OPAQUE\n");
|
||||
fwrite($calfileh,"CLASS:CONFIDENTIAL\n");
|
||||
fwrite($calfileh,"DTSTAMP:".dol_print_date($startdatef,'dayhourxcard',true)."\n");
|
||||
if ($type === "event")
|
||||
{
|
||||
fwrite($calfileh, "BEGIN:VEVENT\n");
|
||||
fwrite($calfileh, "UID:".$uid."\n");
|
||||
|
||||
fwrite($calfileh,"END:VJOURNAL\n");
|
||||
}
|
||||
if (! empty($email))
|
||||
{
|
||||
fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n");
|
||||
fwrite($calfileh, "CONTACT:MAILTO:".$email."\n");
|
||||
}
|
||||
|
||||
if (! empty($url))
|
||||
{
|
||||
fwrite($calfileh, "URL:".$url."\n");
|
||||
}
|
||||
|
||||
// Put other info in comment
|
||||
/*
|
||||
$comment=array();
|
||||
$comment ['eid'] = $eid;
|
||||
$comment ['url'] = $linktoevent;
|
||||
$comment ['date'] = dol_mktime($evttime,"Ymd");
|
||||
$comment ['duration'] = $duration;
|
||||
$comment ['startdate'] = $startdate;
|
||||
$comment ['enddate'] = $enddate;
|
||||
fwrite($calfileh,"COMMENT:" . serialize ($comment) . "\n");
|
||||
*/
|
||||
}
|
||||
}
|
||||
if (is_array($assignedUsers))
|
||||
{
|
||||
foreach($assignedUsers as $assignedUser)
|
||||
{
|
||||
if($assignedUser->email === $email)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Footer
|
||||
fwrite($calfileh,"END:VCALENDAR");
|
||||
fwrite($calfileh, "ATTENDEE;RSVP=TRUE:mailto:".$assignedUser->email."\n");
|
||||
}
|
||||
}
|
||||
|
||||
fclose($calfileh);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing");
|
||||
return -2;
|
||||
}
|
||||
if ($created)
|
||||
{
|
||||
fwrite($calfileh, "CREATED:".dol_print_date($created, "dayhourxcard", true)."\n");
|
||||
}
|
||||
|
||||
if ($modified)
|
||||
{
|
||||
fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, "dayhourxcard", true)."\n");
|
||||
}
|
||||
|
||||
fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n");
|
||||
fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n");
|
||||
|
||||
if (! empty($location))
|
||||
{
|
||||
fwrite($calfileh, "LOCATION:".$encoding.$location."\n");
|
||||
}
|
||||
|
||||
if ($fulldayevent)
|
||||
{
|
||||
fwrite($calfileh, "X-FUNAMBOL-ALLDAY:1\n");
|
||||
}
|
||||
|
||||
// see https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxcical/0f262da6-c5fd-459e-9f18-145eba86b5d2
|
||||
if ($fulldayevent)
|
||||
{
|
||||
fwrite($calfileh, "X-MICROSOFT-CDO-ALLDAYEVENT:TRUE\n");
|
||||
}
|
||||
|
||||
// Date must be GMT dates
|
||||
// Current date
|
||||
fwrite($calfileh, "DTSTAMP:".dol_print_date($now, "dayhourxcard", true)."\n");
|
||||
|
||||
// Start date
|
||||
$prefix = "";
|
||||
$startdatef = dol_print_date($startdate, "dayhourxcard", true);
|
||||
|
||||
if ($fulldayevent)
|
||||
{
|
||||
// Local time
|
||||
$prefix = ";VALUE=DATE";
|
||||
$startdatef = dol_print_date($startdate, "dayxcard", false);
|
||||
}
|
||||
|
||||
fwrite($calfileh, "DTSTART".$prefix.":".$startdatef."\n");
|
||||
|
||||
// End date
|
||||
if ($fulldayevent)
|
||||
{
|
||||
if (empty($enddate))
|
||||
{
|
||||
$enddate = dol_time_plus_duree($startdate, 1, "d");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($enddate))
|
||||
{
|
||||
$enddate = $startdate+$duration;
|
||||
}
|
||||
}
|
||||
|
||||
$prefix = "";
|
||||
$enddatef = dol_print_date($enddate, "dayhourxcard", true);
|
||||
|
||||
if ($fulldayevent)
|
||||
{
|
||||
$prefix = ";VALUE=DATE";
|
||||
$enddatef = dol_print_date($enddate+1, "dayxcard", false);
|
||||
|
||||
// Local time
|
||||
//$enddatef .= dol_print_date($enddate+1,"dayhourxcard",false);
|
||||
}
|
||||
|
||||
fwrite($calfileh, "DTEND".$prefix.":".$enddatef."\n");
|
||||
fwrite($calfileh, "STATUS:CONFIRMED"."\n");
|
||||
|
||||
if (! empty($transparency))
|
||||
{
|
||||
fwrite($calfileh, "TRANSP:".$transparency."\n");
|
||||
}
|
||||
|
||||
if (! empty($category))
|
||||
{
|
||||
fwrite($calfileh, "CATEGORIES:".$encoding.$category."\n");
|
||||
}
|
||||
|
||||
fwrite($calfileh, "END:VEVENT\n");
|
||||
}
|
||||
|
||||
// Output the vCard/iCal VJOURNAL object
|
||||
if ($type === "journal")
|
||||
{
|
||||
fwrite($calfileh, "BEGIN:VJOURNAL\n");
|
||||
fwrite($calfileh, "UID:".$uid."\n");
|
||||
|
||||
if (! empty($email))
|
||||
{
|
||||
fwrite($calfileh, "ORGANIZER:MAILTO:".$email."\n");
|
||||
fwrite($calfileh, "CONTACT:MAILTO:".$email."\n");
|
||||
}
|
||||
|
||||
if (! empty($url))
|
||||
{
|
||||
fwrite($calfileh, "URL:".$url."\n");
|
||||
}
|
||||
|
||||
if ($created)
|
||||
{
|
||||
fwrite($calfileh, "CREATED:".dol_print_date($created, "dayhourxcard", true)."\n");
|
||||
}
|
||||
|
||||
if ($modified)
|
||||
{
|
||||
fwrite($calfileh, "LAST-MODIFIED:".dol_print_date($modified, "dayhourxcard", true)."\n");
|
||||
}
|
||||
|
||||
fwrite($calfileh, "SUMMARY:".$encoding.$summary."\n");
|
||||
fwrite($calfileh, "DESCRIPTION:".$encoding.$description."\n");
|
||||
fwrite($calfileh, "STATUS:CONFIRMED"."\n");
|
||||
fwrite($calfileh, "CATEGORIES:".$category."\n");
|
||||
fwrite($calfileh, "LOCATION:".$location."\n");
|
||||
fwrite($calfileh, "TRANSP:OPAQUE\n");
|
||||
fwrite($calfileh, "CLASS:CONFIDENTIAL\n");
|
||||
fwrite($calfileh, "DTSTAMP:".dol_print_date($startdatef, "dayhourxcard", true)."\n");
|
||||
|
||||
fwrite($calfileh, "END:VJOURNAL\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Footer
|
||||
fwrite($calfileh, "END:VCALENDAR");
|
||||
|
||||
fclose($calfileh);
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
{
|
||||
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a file from an array of events.
|
||||
* Build a file from an array of events.
|
||||
* All input data must be encoded in $conf->charset_output
|
||||
*
|
||||
* @param string $format 'rss'
|
||||
* @param string $title Title of export
|
||||
* @param string $desc Description of export
|
||||
* @param array $events_array Array of events ('uid','startdate','summary','url','desc','author','category')
|
||||
* @param string $outputfile Output file
|
||||
* @param string $filter Filter
|
||||
* @return int <0 if ko, Nb of events in file if ok
|
||||
* @param string $format "rss"
|
||||
* @param string $title Title of export
|
||||
* @param string $desc Description of export
|
||||
* @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category")
|
||||
* @param string $outputfile Output file
|
||||
* @param string $filter (optional) Filter
|
||||
* @return int < 0 if ko, Nb of events in file if ok
|
||||
*/
|
||||
function build_rssfile($format,$title,$desc,$events_array,$outputfile,$filter='')
|
||||
function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = "")
|
||||
{
|
||||
global $user,$conf,$langs;
|
||||
global $dolibarr_main_url_root;
|
||||
global $user, $conf, $langs;
|
||||
global $dolibarr_main_url_root;
|
||||
|
||||
dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format);
|
||||
dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format);
|
||||
|
||||
if (empty($outputfile)) return -1;
|
||||
if (empty($outputfile))
|
||||
{
|
||||
// -1 = error
|
||||
return -1;
|
||||
}
|
||||
|
||||
$fichier=fopen($outputfile,'w');
|
||||
if ($fichier)
|
||||
{
|
||||
$date=date("r");
|
||||
$fichier = fopen($outputfile, "w");
|
||||
|
||||
// Print header
|
||||
$form='<?xml version="1.0" encoding="'.$langs->charset_output.'"?>';
|
||||
fwrite($fichier, $form);
|
||||
fwrite($fichier, "\n");
|
||||
$form='<rss version="2.0">';
|
||||
fwrite($fichier, $form);
|
||||
fwrite($fichier, "\n");
|
||||
if ($fichier)
|
||||
{
|
||||
$date = date("r");
|
||||
|
||||
$form="<channel>\n<title>".$title."</title>\n";
|
||||
fwrite($fichier, $form);
|
||||
// Print header
|
||||
fwrite($fichier, '<?xml version="1.0" encoding="".$langs->charset_output.""?>');
|
||||
fwrite($fichier, "\n");
|
||||
|
||||
$form='<description><![CDATA['.$desc.'.]]></description>'."\n".
|
||||
// '<language>fr</language>'."\n".
|
||||
'<copyright>Dolibarr</copyright>'."\n".
|
||||
'<lastBuildDate>'.$date.'</lastBuildDate>'."\n".
|
||||
'<generator>Dolibarr</generator>'."\n";
|
||||
fwrite($fichier, '<rss version="2.0">');
|
||||
fwrite($fichier, "\n");
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
$url=$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
|
||||
$form.='<link><![CDATA['.$url.']]></link>'."\n";
|
||||
fwrite($fichier, "<channel>\n<title>".$title."</title>\n");
|
||||
|
||||
//print $form;
|
||||
fwrite($fichier, $form);
|
||||
$form = "<description><![CDATA[".$desc.".]]></description>"."\n".
|
||||
// "<language>fr</language>"."\n".
|
||||
"<copyright>Dolibarr</copyright>"."\n".
|
||||
"<lastBuildDate>".$date."</lastBuildDate>"."\n".
|
||||
"<generator>Dolibarr</generator>"."\n";
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot = preg_replace("/".preg_quote(DOL_URL_ROOT, "/")."$/i", "", trim($dolibarr_main_url_root));
|
||||
|
||||
foreach ($events_array as $key => $event)
|
||||
{
|
||||
$eventqualified=true;
|
||||
if ($filter)
|
||||
{
|
||||
// TODO Add a filter
|
||||
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
$eventqualified=false;
|
||||
}
|
||||
$url=$urlwithroot."/public/agenda/agendaexport.php?format=rss&exportkey=".urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY);
|
||||
|
||||
if ($eventqualified)
|
||||
{
|
||||
$uid = $event['uid'];
|
||||
$startdate = $event['startdate'];
|
||||
$summary = $event['summary'];
|
||||
$url = $event['url'];
|
||||
$author = $event['author'];
|
||||
$category = $event['category'];
|
||||
/* No place inside a RSS
|
||||
$priority = $event['priority'];
|
||||
$fulldayevent = $event['fulldayevent'];
|
||||
$location = $event['location'];
|
||||
$email = $event['email'];
|
||||
fwrite($fichier, "<link><![CDATA[".$url."]]></link>"."\n");
|
||||
|
||||
foreach ($events_array as $key => $event)
|
||||
{
|
||||
$eventqualified = true;
|
||||
|
||||
if ($filter)
|
||||
{
|
||||
// TODO Add a filter
|
||||
|
||||
$eventqualified=false;
|
||||
}
|
||||
|
||||
if ($eventqualified)
|
||||
{
|
||||
$uid = $event["uid"];
|
||||
$startdate = $event["startdate"];
|
||||
$summary = $event["summary"];
|
||||
$url = $event["url"];
|
||||
$author = $event["author"];
|
||||
$category = $event["category"];
|
||||
|
||||
/* No place inside a RSS
|
||||
$priority = $event["priority"];
|
||||
$fulldayevent = $event["fulldayevent"];
|
||||
$location = $event["location"];
|
||||
$email = $event["email"];
|
||||
*/
|
||||
$description=preg_replace('/<br[\s\/]?>/i',"\n",$event['desc']);
|
||||
$description=dol_string_nohtmltag($description,0); // Remove html tags
|
||||
|
||||
fwrite($fichier, "<item>\n");
|
||||
fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n");
|
||||
fwrite($fichier, "<link><![CDATA[".$url."]]></link>\n");
|
||||
fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n");
|
||||
fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n");
|
||||
fwrite($fichier, "<description><![CDATA[");
|
||||
if ($description) fwrite($fichier, $description);
|
||||
//else fwrite($fichier, 'NoDesc');
|
||||
fwrite($fichier, "]]></description>\n");
|
||||
fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n");
|
||||
fwrite($fichier, "<guid isPermaLink=\"true\"><![CDATA[".$uid."]]></guid>\n");
|
||||
fwrite($fichier, "<source><![CDATA[Dolibarr]]></source>\n");
|
||||
fwrite($fichier, "</item>\n");
|
||||
}
|
||||
}
|
||||
$description = dol_string_nohtmltag(preg_replace("/<br[\s\/]?>/i", "\n", $event["desc"]), 0);
|
||||
|
||||
fwrite($fichier, '</channel>');
|
||||
fwrite($fichier, "\n");
|
||||
fwrite($fichier, '</rss>');
|
||||
fwrite($fichier, "<item>\n");
|
||||
fwrite($fichier, "<title><![CDATA[".$summary."]]></title>\n");
|
||||
fwrite($fichier, "<link><![CDATA[".$url."]]></link>\n");
|
||||
fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n");
|
||||
fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n");
|
||||
fwrite($fichier, "<description><![CDATA[");
|
||||
|
||||
fclose($fichier);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
if ($description)
|
||||
fwrite($fichier, $description);
|
||||
// else
|
||||
// fwrite($fichier, "NoDesc");
|
||||
|
||||
fwrite($fichier, "]]></description>\n");
|
||||
fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n");
|
||||
fwrite($fichier, "<guid isPermaLink=\"true\"><![CDATA[".$uid."]]></guid>\n");
|
||||
fwrite($fichier, "<source><![CDATA[Dolibarr]]></source>\n");
|
||||
fwrite($fichier, "</item>\n");
|
||||
}
|
||||
}
|
||||
|
||||
fwrite($fichier, "</channel>");
|
||||
fwrite($fichier, "\n");
|
||||
fwrite($fichier, "</rss>");
|
||||
|
||||
fclose($fichier);
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
{
|
||||
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode for cal export
|
||||
* Encode for cal export
|
||||
*
|
||||
* @param string $format vcal or ical
|
||||
* @param string $string string to encode
|
||||
* @return string string encoded
|
||||
* @param string $format "vcal" or "ical"
|
||||
* @param string $string String to encode
|
||||
* @return string String encoded
|
||||
*/
|
||||
function format_cal($format,$string)
|
||||
function format_cal($format, $string)
|
||||
{
|
||||
global $conf;
|
||||
global $conf;
|
||||
|
||||
$newstring=$string;
|
||||
$newstring = $string;
|
||||
|
||||
if ($format == 'vcal')
|
||||
{
|
||||
$newstring=quotedPrintEncode($newstring);
|
||||
}
|
||||
if ($format == 'ical')
|
||||
{
|
||||
// Replace new lines chars by '\n'
|
||||
$newstring=preg_replace('/'."\r\n".'/i',"\n",$newstring);
|
||||
$newstring=preg_replace('/'."\n\r".'/i',"\n",$newstring);
|
||||
$newstring=preg_replace('/'."\n".'/i','\n',$newstring);
|
||||
// Must not exceed 75 char. Cut with "\r\n"+Space
|
||||
$newstring=calEncode($newstring);
|
||||
}
|
||||
if ($format === "vcal")
|
||||
{
|
||||
$newstring = quotedPrintEncode($newstring);
|
||||
}
|
||||
|
||||
return $newstring;
|
||||
if ($format === "ical")
|
||||
{
|
||||
// Replace new lines chars by "\n"
|
||||
$newstring = preg_replace("/"."\r\n"."/i", "\\n", $newstring);
|
||||
$newstring = preg_replace("/"."\n\r"."/i", "\\n", $newstring);
|
||||
$newstring = preg_replace("/"."\n"."/i", "\\n", $newstring);
|
||||
|
||||
// Must not exceed 75 char. Cut with "\r\n"+Space
|
||||
$newstring = calEncode($newstring);
|
||||
}
|
||||
|
||||
return $newstring;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cut string after 75 chars. Add CRLF+Space.
|
||||
* line must be encoded in UTF-8
|
||||
* Cut string after 75 chars. Add CRLF+Space.
|
||||
* line must be encoded in UTF-8
|
||||
*
|
||||
* @param string $line String to convert
|
||||
* @return string String converted
|
||||
* @param string $line String to convert
|
||||
* @return string String converted
|
||||
*/
|
||||
function calEncode($line)
|
||||
{
|
||||
$out = '';
|
||||
$out = "";
|
||||
$newpara = "";
|
||||
|
||||
$newpara = '';
|
||||
// If mb_ functions exists, it"s better to use them
|
||||
if (function_exists("mb_strlen"))
|
||||
{
|
||||
$strlength = mb_strlen($line, "UTF-8");
|
||||
|
||||
// If mb_ functions exists, it's better to use them
|
||||
if (function_exists('mb_strlen'))
|
||||
{
|
||||
$strlength=mb_strlen($line, 'UTF-8');
|
||||
for ($j = 0; $j <= ($strlength - 1); $j++)
|
||||
{
|
||||
$char = mb_substr($line, $j, 1, 'UTF-8'); // Take char at position $j
|
||||
for ($j = 0; $j < $strlength; $j++)
|
||||
{
|
||||
// Take char at position $j
|
||||
$char = mb_substr($line, $j, 1, "UTF-8");
|
||||
|
||||
if ((mb_strlen($newpara, 'UTF-8') + mb_strlen($char, 'UTF-8')) >= 75)
|
||||
{
|
||||
$out .= $newpara . "\r\n "; // CRLF + Space for cal
|
||||
$newpara = '';
|
||||
}
|
||||
$newpara .= $char;
|
||||
}
|
||||
$out .= $newpara;
|
||||
}
|
||||
else
|
||||
{
|
||||
$strlength=dol_strlen($line);
|
||||
for ($j = 0; $j <= ($strlength - 1); $j++)
|
||||
{
|
||||
$char = substr($line, $j, 1); // Take char at position $j
|
||||
if ((mb_strlen($newpara, "UTF-8") + mb_strlen($char, "UTF-8")) >= 75)
|
||||
{
|
||||
// CRLF + Space for cal
|
||||
$out .= $newpara . "\r\n ";
|
||||
|
||||
if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 )
|
||||
{
|
||||
$out .= $newpara . "\r\n "; // CRLF + Space for cal
|
||||
$newpara = '';
|
||||
}
|
||||
$newpara .= $char;
|
||||
}
|
||||
$out .= $newpara;
|
||||
}
|
||||
$newpara = "";
|
||||
}
|
||||
|
||||
return trim($out);
|
||||
$newpara .= $char;
|
||||
}
|
||||
|
||||
$out .= $newpara;
|
||||
}
|
||||
else
|
||||
{
|
||||
$strlength = dol_strlen($line);
|
||||
|
||||
for ($j = 0; $j < $strlength; $j++)
|
||||
{
|
||||
// Take char at position $j
|
||||
$char = substr($line, $j, 1);
|
||||
|
||||
if ((dol_strlen($newpara) + dol_strlen($char)) >= 75 )
|
||||
{
|
||||
// CRLF + Space for cal
|
||||
$out .= $newpara . "\r\n ";
|
||||
|
||||
$newpara = "";
|
||||
}
|
||||
|
||||
$newpara .= $char;
|
||||
}
|
||||
|
||||
$out .= $newpara;
|
||||
}
|
||||
|
||||
return trim($out);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode into vcal format
|
||||
* Encode into vcal format
|
||||
*
|
||||
* @param string $str String to convert
|
||||
* @param int $forcal 1=For cal
|
||||
* @return string String converted
|
||||
* @param string $str String to convert
|
||||
* @param int $forcal (optional) 1 = For cal
|
||||
* @return string String converted
|
||||
*/
|
||||
function quotedPrintEncode($str,$forcal=0)
|
||||
function quotedPrintEncode($str, $forcal = 0)
|
||||
{
|
||||
$lines = preg_split("/\r\n/", $str);
|
||||
$out = '';
|
||||
$lines = preg_split("/\r\n/", $str);
|
||||
$out = "";
|
||||
|
||||
foreach ($lines as $line)
|
||||
{
|
||||
$newpara = '';
|
||||
foreach ($lines as $line)
|
||||
{
|
||||
$newpara = "";
|
||||
|
||||
$strlength=strlen($line); // Do not use dol_strlen here, we need number of bytes
|
||||
for ($j = 0; $j <= ($strlength - 1); $j++)
|
||||
{
|
||||
$char = substr($line, $j, 1);
|
||||
$ascii = ord($char);
|
||||
// Do not use dol_strlen here, we need number of bytes
|
||||
$strlength = strlen($line);
|
||||
|
||||
if ( $ascii < 32 || $ascii == 61 || $ascii > 126 )
|
||||
$char = '=' . strtoupper(sprintf("%02X", $ascii));
|
||||
for ($j = 0; $j < $strlength; $j++)
|
||||
{
|
||||
$char = substr($line, $j, 1);
|
||||
$ascii = ord($char);
|
||||
|
||||
if ((strlen($newpara) + strlen($char)) >= 76 ) // Do not use dol_strlen here, we need number of bytes
|
||||
{
|
||||
$out .= $newpara . '=' . "\r\n"; // CRLF
|
||||
if ($forcal) $out .= " "; // + Space for cal
|
||||
$newpara = '';
|
||||
}
|
||||
$newpara .= $char;
|
||||
}
|
||||
$out .= $newpara;
|
||||
}
|
||||
return trim($out);
|
||||
if ( $ascii < 32 || $ascii === 61 || $ascii > 126 )
|
||||
{
|
||||
$char = "=" . strtoupper(sprintf("%02X", $ascii));
|
||||
}
|
||||
|
||||
// Do not use dol_strlen here, we need number of bytes
|
||||
if ((strlen($newpara) + strlen($char)) >= 76 )
|
||||
{
|
||||
// New line with carray-return (CR) and line-feed (LF)
|
||||
$out .= $newpara . "=" . "\r\n";
|
||||
|
||||
// extra space for cal
|
||||
if ($forcal)
|
||||
$out .= " ";
|
||||
|
||||
$newpara = "";
|
||||
}
|
||||
|
||||
$newpara .= $char;
|
||||
}
|
||||
|
||||
$out .= $newpara;
|
||||
}
|
||||
return trim($out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode vcal format
|
||||
* Decode vcal format
|
||||
*
|
||||
* @param string $str String to convert
|
||||
* @return string String converted
|
||||
* @param string $str String to convert
|
||||
* @return string String converted
|
||||
*/
|
||||
function quotedPrintDecode($str)
|
||||
{
|
||||
$out = preg_replace('/=\r?\n/', '', $str);
|
||||
$out = quoted_printable_decode($out); // Available with PHP 4+
|
||||
return trim($out);
|
||||
return trim(quoted_printable_decode(preg_replace("/=\r?\n/", "", $str)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user