Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2017-10-07 11:09:31 +00:00
parent 41716281ed
commit 328d39bc71
42 changed files with 29872 additions and 29872 deletions

File diff suppressed because it is too large Load Diff

View File

@ -128,8 +128,8 @@ complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$elementList = array();
// Must match ids defined into eldy.lib.php
$sourceList = array(
// Must match ids defined into eldy.lib.php
$sourceList = array(
'1' => $langs->trans('AccountingJournalType1'),
'2' => $langs->trans('AccountingJournalType2'),
'3' => $langs->trans('AccountingJournalType3'),
@ -144,214 +144,214 @@ $elementList = array();
if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x'))
{
$search_country_id = '';
$search_country_id = '';
}
// Actions add or modify an entry into a dictionary
if (GETPOST('actionadd') || GETPOST('actionmodify'))
{
$listfield=explode(',', str_replace(' ', '',$tabfield[$id]));
$listfieldinsert=explode(',',$tabfieldinsert[$id]);
$listfieldmodify=explode(',',$tabfieldinsert[$id]);
$listfieldvalue=explode(',',$tabfieldvalue[$id]);
$listfield=explode(',', str_replace(' ', '',$tabfield[$id]));
$listfieldinsert=explode(',',$tabfieldinsert[$id]);
$listfieldmodify=explode(',',$tabfieldinsert[$id]);
$listfieldvalue=explode(',',$tabfieldvalue[$id]);
// Check that all fields are filled
$ok=1;
foreach ($listfield as $f => $value)
{
// Check that all fields are filled
$ok=1;
foreach ($listfield as $f => $value)
{
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey='Label';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
if ($fieldnamekey == 'nature') $fieldnamekey = 'Nature';
}
// Other checks
if (isset($_POST["code"]))
{
if ($_POST["code"]=='0')
{
$ok=0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
}
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
}
// Other checks
if (isset($_POST["code"]))
{
if ($_POST["code"]=='0')
{
$ok=0;
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
}
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
{
$ok = 0;
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
}*/
}
}
// Clean some parameters
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null
// Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd'))
{
if ($tabrowid[$id])
{
// Recupere id libre pour insertion
$newid=0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$newid=($obj->newid + 1);
// Si verif ok et action add, on ajoute la ligne
if ($ok && GETPOST('actionadd'))
{
if ($tabrowid[$id])
{
// Recupere id libre pour insertion
$newid=0;
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
$result = $db->query($sql);
if ($result)
{
$obj = $db->fetch_object($result);
$newid=($obj->newid + 1);
} else {
dol_print_error($db);
}
}
} else {
dol_print_error($db);
}
}
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
$sql.= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id];
$sql.=",active)";
$sql.= " VALUES(";
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
$sql.= $tabrowid[$id].",";
$sql.= $tabfieldinsert[$id];
$sql.=",active)";
$sql.= " VALUES(";
// List of values
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
$sql.= $newid.",";
$i=0;
foreach ($listfieldinsert as $f => $value)
{
if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.=",1)";
// List of values
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldinsert))
$sql.= $newid.",";
$i=0;
foreach ($listfieldinsert as $f => $value)
{
if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.=",1)";
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);
if ($result) // Add is ok
{
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
}
else
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
}
else {
dol_print_error($db);
}
}
}
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);
if ($result) // Add is ok
{
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST=array('id'=>$id); // Clean $_POST array, we keep only
}
else
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
}
else {
dol_print_error($db);
}
}
}
// Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify'))
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
// Si verif ok et action modify, on modifie la ligne
if ($ok && GETPOST('actionmodify'))
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify))
{
$sql.= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field)
{
if ($field == 'price' || preg_match('/^amount/i',$field) || $field == 'taux') {
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
}
else if ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
// Modify entry
$sql = "UPDATE ".$tabname[$id]." SET ";
// Modifie valeur des champs
if ($tabrowid[$id] && ! in_array($tabrowid[$id],$listfieldmodify))
{
$sql.= $tabrowid[$id]."=";
$sql.= "'".$db->escape($rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field)
{
if ($field == 'price' || preg_match('/^amount/i',$field) || $field == 'taux') {
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
}
else if ($field == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity;
}
if ($i) $sql.=",";
$sql.= $field."=";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++;
}
$sql.= " WHERE ".$rowidcol." = '".$rowid."'";
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);
if (! $resql)
{
setEventMessages($db->error(), null, 'errors');
}
}
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
dol_syslog("actionmodify", LOG_DEBUG);
//print $sql;
$resql = $db->query($sql);
if (! $resql)
{
setEventMessages($db->error(), null, 'errors');
}
}
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
}
if (GETPOST('actioncancel'))
{
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
}
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
if (! $result)
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
}
else
{
dol_print_error($db);
}
}
dol_syslog("delete", LOG_DEBUG);
$result = $db->query($sql);
if (! $result)
{
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
{
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
}
else
{
dol_print_error($db);
}
}
}
// activate
if ($action == $acts[0])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
}
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
}
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
}
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$code."'";
}
$result = $db->query($sql);
if (!$result)
{
dol_print_error($db);
}
$result = $db->query($sql);
if (!$result)
{
dol_print_error($db);
}
}
// disable
if ($action == $acts[1])
{
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
else { $rowidcol="rowid"; }
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
}
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
}
if ($rowid) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
}
elseif ($code) {
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$code."'";
}
$result = $db->query($sql);
if (!$result)
{
dol_print_error($db);
}
$result = $db->query($sql);
if (!$result)
{
dol_print_error($db);
}
}
@ -368,8 +368,8 @@ $titre=$langs->trans("DictionarySetup");
$linkback='';
if ($id)
{
$titre.=' - '.$langs->trans($tablib[$id]);
$titlepicto='title_accountancy';
$titre.=' - '.$langs->trans($tablib[$id]);
$titlepicto='title_accountancy';
}
print load_fiche_titre($titre,$linkback,$titlepicto);
@ -378,7 +378,7 @@ print load_fiche_titre($titre,$linkback,$titlepicto);
// Confirmation de la suppression de la ligne
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
}
//var_dump($elementList);
@ -387,315 +387,315 @@ if ($action == 'delete')
*/
if ($id)
{
// Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id];
// Complete requete recherche valeurs avec critere de tri
$sql=$tabsql[$id];
if ($search_country_id > 0)
{
if (preg_match('/ WHERE /',$sql)) $sql.= " AND ";
else $sql.=" WHERE ";
$sql.= " c.rowid = ".$search_country_id;
}
if ($search_country_id > 0)
{
if (preg_match('/ WHERE /',$sql)) $sql.= " AND ";
else $sql.=" WHERE ";
$sql.= " c.rowid = ".$search_country_id;
}
if ($sortfield)
{
// If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield='country_code';
$sql.= " ORDER BY ".$sortfield;
if ($sortorder)
{
$sql.=" ".strtoupper($sortorder);
}
$sql.=", ";
// Clear the required sort criteria for the tabsqlsort to be able to force it with selected value
$tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]);
$tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]);
}
else {
$sql.=" ORDER BY ";
}
$sql.=$tabsqlsort[$id];
$sql.=$db->plimit($listlimit+1,$offset);
//print $sql;
if ($sortfield)
{
// If sort order is "country", we use country_code instead
if ($sortfield == 'country') $sortfield='country_code';
$sql.= " ORDER BY ".$sortfield;
if ($sortorder)
{
$sql.=" ".strtoupper($sortorder);
}
$sql.=", ";
// Clear the required sort criteria for the tabsqlsort to be able to force it with selected value
$tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]);
$tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]);
}
else {
$sql.=" ORDER BY ";
}
$sql.=$tabsqlsort[$id];
$sql.=$db->plimit($listlimit+1,$offset);
//print $sql;
$fieldlist=explode(',',$tabfield[$id]);
$fieldlist=explode(',',$tabfield[$id]);
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
print '<div class="div-table-responsive">';
print '<table class="noborder" width="100%">';
print '<div class="div-table-responsive">';
print '<table class="noborder" width="100%">';
// Form to add a new line
if ($tabname[$id])
{
$alabelisused=0;
$var=false;
// Form to add a new line
if ($tabname[$id])
{
$alabelisused=0;
$var=false;
$fieldlist=explode(',',$tabfield[$id]);
$fieldlist=explode(',',$tabfield[$id]);
// Line for title
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
$align="left";
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
{
$valuetoshow=$langs->trans("Label");
}
if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); }
// Line for title
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$valuetoshow=ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
$align="left";
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label')
{
$valuetoshow=$langs->trans("Label");
}
if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); }
if ($valuetoshow != '')
{
print '<td align="'.$align.'">';
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1,$valuetoshow).'</a>';
else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
else print $valuetoshow;
print '</td>';
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
}
if ($valuetoshow != '')
{
print '<td align="'.$align.'">';
if (! empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i',$tabhelp[$id][$value])) print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1,$valuetoshow).'</a>';
else if (! empty($tabhelp[$id][$value])) print $form->textwithpicto($valuetoshow,$tabhelp[$id][$value]);
else print $valuetoshow;
print '</td>';
}
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
}
print '<td>';
print '<input type="hidden" name="id" value="'.$id.'">';
print '</td>';
print '<td style="min-width: 26px;"></td>';
print '<td style="min-width: 26px;"></td>';
print '<td style="min-width: 26px;"></td>';
print '</tr>';
print '<td>';
print '<input type="hidden" name="id" value="'.$id.'">';
print '</td>';
print '<td style="min-width: 26px;"></td>';
print '<td style="min-width: 26px;"></td>';
print '<td style="min-width: 26px;"></td>';
print '</tr>';
// Line to enter new values
print '<tr class="oddeven nodrag nodrap nohover">';
// Line to enter new values
print '<tr class="oddeven nodrag nodrap nohover">';
$obj = new stdClass();
// If data was already input, we define them in obj to populate input fields.
if (GETPOST('actionadd'))
{
foreach ($fieldlist as $key=>$val)
{
if (GETPOST($val) != '')
$obj->$val=GETPOST($val);
}
}
$obj = new stdClass();
// If data was already input, we define them in obj to populate input fields.
if (GETPOST('actionadd'))
{
foreach ($fieldlist as $key=>$val)
{
if (GETPOST($val) != '')
$obj->$val=GETPOST($val);
}
}
$tmpaction = 'create';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$tmpaction = 'create';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
if (empty($reshook))
{
fieldListJournal($fieldlist,$obj,$tabname[$id],'add');
}
if (empty($reshook))
{
fieldListJournal($fieldlist,$obj,$tabname[$id],'add');
}
print '<td colspan="4" align="right">';
print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
print '</td>';
print "</tr>";
print '<td colspan="4" align="right">';
print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
print '</td>';
print "</tr>";
print '<tr><td colspan="7">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
}
print '<tr><td colspan="7">&nbsp;</td></tr>'; // Keep &nbsp; to have a line with enough height
}
// List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$var=true;
// List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
$var=true;
$param = '&id='.$id;
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
$paramwithsearch = $param;
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha');
$param = '&id='.$id;
if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id;
$paramwithsearch = $param;
if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder;
if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield;
if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha');
// There is several pages
if ($num > $listlimit)
{
print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
print '</td></tr>';
}
// There is several pages
if ($num > $listlimit)
{
print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">';
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page+1).'</span></li>');
print '</td></tr>';
}
// Title line with search boxes
print '<tr class="liste_titre_filter liste_titre_add">';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre" align="center">';
if ($filterfound)
{
$searchpicto=$form->showFilterAndCheckAddButtons(0);
print $searchpicto;
}
print '</td>';
print '</tr>';
// Title line with search boxes
print '<tr class="liste_titre_filter liste_titre_add">';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre" align="center">';
if ($filterfound)
{
$searchpicto=$form->showFilterAndCheckAddButtons(0);
print $searchpicto;
}
print '</td>';
print '</tr>';
// Title of lines
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$showfield=1; // By defaut
$align="left";
$sortable=1;
$valuetoshow='';
/*
// Title of lines
print '<tr class="liste_titre">';
foreach ($fieldlist as $field => $value)
{
// Determine le nom du champ par rapport aux noms possibles
// dans les dictionnaires de donnees
$showfield=1; // By defaut
$align="left";
$sortable=1;
$valuetoshow='';
/*
$tmparray=getLabelOfField($fieldlist[$field]);
$showfield=$tmp['showfield'];
$valuetoshow=$tmp['valuetoshow'];
$align=$tmp['align'];
$sortable=$tmp['sortable'];
*/
$valuetoshow=ucfirst($fieldlist[$field]); // By defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); }
$valuetoshow=ucfirst($fieldlist[$field]); // By defaut
$valuetoshow=$langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); }
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); }
if ($fieldlist[$field]=='nature') { $valuetoshow=$langs->trans("Nature"); }
// Affiche nom du champ
if ($showfield)
{
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
}
}
// Affiche nom du champ
if ($showfield)
{
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
}
}
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList('');
print getTitleFieldOfList('');
print getTitleFieldOfList('');
print '</tr>';
print getTitleFieldOfList('');
print getTitleFieldOfList('');
print getTitleFieldOfList('');
print '</tr>';
if ($num)
{
// Lines with values
while ($i < $num)
{
$obj = $db->fetch_object($resql);
//print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
{
$tmpaction='edit';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
if ($num)
{
// Lines with values
while ($i < $num)
{
$obj = $db->fetch_object($resql);
//print_r($obj);
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
if ($action == 'edit' && ($rowid == (! empty($obj->rowid)?$obj->rowid:$obj->code)))
{
$tmpaction='edit';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
// Show fields
if (empty($reshook)) fieldListJournal($fieldlist,$obj,$tabname[$id],'edit');
// Show fields
if (empty($reshook)) fieldListJournal($fieldlist,$obj,$tabname[$id],'edit');
print '<td align="center" colspan="4">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
print '</td>';
}
else
{
$tmpaction = 'view';
$parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('viewDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
print '<td align="center" colspan="4">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
print '<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'">';
print '<div name="'.(! empty($obj->rowid)?$obj->rowid:$obj->code).'"></div>';
print '</td>';
}
else
{
$tmpaction = 'view';
$parameters=array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('viewDictionaryFieldlist',$parameters,$obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
$error=$hookmanager->error; $errors=$hookmanager->errors;
if (empty($reshook))
{
foreach ($fieldlist as $field => $value)
{
if (empty($reshook))
{
foreach ($fieldlist as $field => $value)
{
$showfield=1;
$align="left";
$valuetoshow=$obj->{$fieldlist[$field]};
if ($valuetoshow=='all') {
$valuetoshow=$langs->trans('All');
}
else if ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
$langs->load("accountancy");
$key=$langs->trans("AccountingJournalType".strtoupper($obj->nature));
$valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($obj->nature)?$key:$obj->{$fieldlist[$field]});
}
$showfield=1;
$align="left";
$valuetoshow=$obj->{$fieldlist[$field]};
if ($valuetoshow=='all') {
$valuetoshow=$langs->trans('All');
}
else if ($fieldlist[$field]=='nature' && $tabname[$id]==MAIN_DB_PREFIX.'accounting_journal') {
$langs->load("accountancy");
$key=$langs->trans("AccountingJournalType".strtoupper($obj->nature));
$valuetoshow=($obj->nature && $key != "AccountingJournalType".strtoupper($obj->nature)?$key:$obj->{$fieldlist[$field]});
}
$class='tddict';
$class='tddict';
// Show value for field
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td align="'.$align.'" class="'.$class.'">'.$valuetoshow.'</td>';
}
}
}
}
// Can an entry be erased or disabled ?
$iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default
if (isset($obj->code) && $id != 10)
{
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) { $iserasable = 0; $canbedisabled = 0; }
else if ($obj->code == 'RECEP') { $iserasable = 0; $canbedisabled = 0; }
else if ($obj->code == 'EF0') { $iserasable = 0; $canbedisabled = 0; }
}
// Can an entry be erased or disabled ?
$iserasable=1;$canbedisabled=1;$canbemodified=1; // true by default
if (isset($obj->code) && $id != 10)
{
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) { $iserasable = 0; $canbedisabled = 0; }
else if ($obj->code == 'RECEP') { $iserasable = 0; $canbedisabled = 0; }
else if ($obj->code == 'EF0') { $iserasable = 0; $canbedisabled = 0; }
}
$canbemodified=$iserasable;
$canbemodified=$iserasable;
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
if ($param) $url .= '&'.$param;
$url.='&';
$url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'');
if ($param) $url .= '&'.$param;
$url.='&';
// Active
print '<td align="center" class="nowrap">';
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
else
{
if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive");
else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
else if (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption");
else print $langs->trans("AlwaysActive");
}
print "</td>";
// Active
print '<td align="center" class="nowrap">';
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
else
{
if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO'))) print $langs->trans("AlwaysActive");
else if (isset($obj->type) && in_array($obj->type, array('systemauto')) && empty($obj->active)) print $langs->trans("Deprecated");
else if (isset($obj->type) && in_array($obj->type, array('system')) && ! empty($obj->active) && $obj->code != 'AC_OTH') print $langs->trans("UsedOnlyWithTypeOption");
else print $langs->trans("AlwaysActive");
}
print "</td>";
// Modify link
if ($canbemodified) print '<td align="center"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>';
else print '<td>&nbsp;</td>';
// Modify link
if ($canbemodified) print '<td align="center"><a class="reposition" href="'.$url.'action=edit">'.img_edit().'</a></td>';
else print '<td>&nbsp;</td>';
// Delete link
if ($iserasable)
{
print '<td align="center">';
if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>';
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
print '</td>';
}
else print '<td>&nbsp;</td>';
// Delete link
if ($iserasable)
{
print '<td align="center">';
if ($user->admin) print '<a href="'.$url.'action=delete">'.img_delete().'</a>';
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
print '</td>';
}
else print '<td>&nbsp;</td>';
print '<td></td>';
print '<td></td>';
print '</td>';
}
print '</td>';
}
print "</tr>\n";
$i++;
}
}
}
else {
dol_print_error($db);
}
print "</tr>\n";
$i++;
}
}
}
else {
dol_print_error($db);
}
print '</table>';
print '</table>';
print '</div>';
print '</form>';
print '</form>';
}
print '<br>';

File diff suppressed because it is too large Load Diff

View File

@ -57,19 +57,19 @@ if (! defined("MAIN_MOTD")) define("MAIN_MOTD","");
if (GETPOST('cancel','alpha'))
{
$action='';
$action='';
}
if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACKGROUND))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$logofile=$conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND;
dol_delete_file($logofile);
dolibarr_del_const($db, "MAIN_LOGIN_BACKGROUND",$conf->entity);
$mysoc->logo='';
$logofile=$conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND;
dol_delete_file($logofile);
dolibarr_del_const($db, "MAIN_LOGIN_BACKGROUND",$conf->entity);
$mysoc->logo='';
/*$logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
/*$logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
dol_delete_file($logosmallfile);
dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$conf->entity);
$mysoc->logo_small='';
@ -89,7 +89,7 @@ if ($action == 'update')
$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE');
if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity);
else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'),'chaine',0,'',$conf->entity);
else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'),'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity);
@ -103,44 +103,44 @@ if ($action == 'update')
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'),array()))));
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val,'chaine',0,'',$conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val,'chaine',0,'',$conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'),array()))));
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val,'chaine',0,'',$conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val,'chaine',0,'',$conf->entity);
if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black)
if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black)
else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $_POST["THEME_ELDY_USE_HOVER"], 'chaine', 0, '', $conf->entity);
$val=(implode(',',(colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'),array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val,'chaine',0,'',$conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val,'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", $_POST["MAIN_DEFAULT_WORKING_DAYS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", $_POST["MAIN_DEFAULT_WORKING_DAYS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"],'chaine',0,'',0); // Param for all entities
dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity);
@ -151,43 +151,43 @@ if ($action == 'update')
$varforimage='imagebackground'; $dirforimage=$conf->mycompany->dir_output.'/logos/';
if ($_FILES[$varforimage]["tmp_name"])
{
if (preg_match('/([^\\/:]+)$/i',$_FILES[$varforimage]["name"],$reg))
{
$original_file=$reg[1];
if (preg_match('/([^\\/:]+)$/i',$_FILES[$varforimage]["name"],$reg))
{
$original_file=$reg[1];
$isimage=image_format_supported($original_file);
if ($isimage >= 0)
{
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
if (! is_dir($dirforimage))
{
dol_mkdir($dirforimage);
}
$result=dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"],$dirforimage.$original_file,1,0,$_FILES[$varforimage]['error']);
if ($result > 0)
{
dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND",$original_file,'chaine',0,'',$conf->entity);
}
else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result))
{
$error++;
$langs->load("errors");
$tmparray=explode(':',$result);
setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus',$tmparray[1]), null, 'errors');
}
else
{
$error++;
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
}
}
else
{
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
}
}
$isimage=image_format_supported($original_file);
if ($isimage >= 0)
{
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
if (! is_dir($dirforimage))
{
dol_mkdir($dirforimage);
}
$result=dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"],$dirforimage.$original_file,1,0,$_FILES[$varforimage]['error']);
if ($result > 0)
{
dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND",$original_file,'chaine',0,'',$conf->entity);
}
else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result))
{
$error++;
$langs->load("errors");
$tmparray=explode(':',$result);
setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus',$tmparray[1]), null, 'errors');
}
else
{
$error++;
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
}
}
else
{
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
}
}
}
@ -218,59 +218,59 @@ print "<br>\n";
if ($action == 'edit') // Edit
{
//WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
//WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<form enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
clearstatcache();
clearstatcache();
print '<br>';
print '<table summary="edit" class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Language").'</td><td></td>';
print '<br>';
print '<table summary="edit" class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Language").'</td><td></td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Default language
print '<tr><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300');
print '</td>';
// Default language
print '<tr><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300');
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Multilingual GUI
print '<tr><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>';
print $form->selectyesno('MAIN_MULTILANGS',$conf->global->MAIN_MULTILANGS,1);
print '</td>';
print '<tr><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>';
print $form->selectyesno('MAIN_MULTILANGS',$conf->global->MAIN_MULTILANGS,1);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
print '</table><br>'."\n";
// Themes and themes options
show_theme(null,1);
print '<br>';
// Themes and themes options
show_theme(null,1);
print '<br>';
// Other
print '<table summary="edit" class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
// Other
print '<table summary="edit" class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Max size of lists
print '<tr><td>'.$langs->trans("DefaultMaxSizeList").'</td><td><input class="flat" name="main_size_liste_limit" size="4" value="' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '"></td>';
print '<tr><td>'.$langs->trans("DefaultMaxSizeList").'</td><td><input class="flat" name="main_size_liste_limit" size="4" value="' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '"></td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Max size of short lists on customer card
print '<tr><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '"></td>';
print '<tr><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td><input class="flat" name="main_size_shortliste_limit" size="4" value="' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '"></td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// show input border
/*
// show input border
/*
print '<tr><td>'.$langs->trans("showInputBorder").'</td><td>';
print $form->selectyesno('main_showInputBorder',isset($conf->global->THEME_ELDY_SHOW_BORDER_INPUT)?$conf->global->THEME_ELDY_SHOW_BORDER_INPUT:0,1);
print '</td>';
@ -279,38 +279,38 @@ if ($action == 'edit') // Edit
*/
// Disable javascript and ajax
print '<tr><td>'.$langs->trans("DisableJavascript").'</td><td>';
print $form->selectyesno('main_disable_javascript',isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0,1);
print '</td>';
print '<tr><td>'.$langs->trans("DisableJavascript").'</td><td>';
print $form->selectyesno('main_disable_javascript',isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0,1);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// First day for weeks
print '<tr><td class="titlefield">'.$langs->trans("WeekStartOnDay").'</td><td>';
print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'),'MAIN_START_WEEK',0);
print '</td>';
// First day for weeks
print '<tr><td class="titlefield">'.$langs->trans("WeekStartOnDay").'</td><td>';
print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'),'MAIN_START_WEEK',0);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// DefaultWorkingDays
print '<tr><td class="titlefield">'.$langs->trans("DefaultWorkingDays").'</td><td>';
print '<input type="text" name="MAIN_DEFAULT_WORKING_DAYS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5').'">';
print '</td>';
// DefaultWorkingDays
print '<tr><td class="titlefield">'.$langs->trans("DefaultWorkingDays").'</td><td>';
print '<input type="text" name="MAIN_DEFAULT_WORKING_DAYS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5').'">';
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// DefaultWorkingHours
print '<tr><td class="titlefield">'.$langs->trans("DefaultWorkingHours").'</td><td>';
print '<input type="text" name="MAIN_DEFAULT_WORKING_HOURS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18').'">';
print '</td>';
// DefaultWorkingHours
print '<tr><td class="titlefield">'.$langs->trans("DefaultWorkingHours").'</td><td>';
print '<input type="text" name="MAIN_DEFAULT_WORKING_HOURS" size="5" value="'.(isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18').'">';
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Firstname/Name
print '<tr><td class="titlefield">'.$langs->trans("FirstnameNamePosition").'</td><td>';
print '<tr><td class="titlefield">'.$langs->trans("FirstnameNamePosition").'</td><td>';
$array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"),1=>$langs->trans("Lastname").' '.$langs->trans("Firstname"));
print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION',$array,(isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0));
print '</td>';
print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION',$array,(isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0));
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
@ -346,27 +346,27 @@ if ($action == 'edit') // Edit
print '</tr>';
// Hide wiki link on login page
print '<tr><td class="titlefield">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td>';
print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0,1);
print '</td>';
print '<tr><td class="titlefield">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td>';
print $form->selectyesno('MAIN_HELP_DISABLELINK', isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0,1);
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Message of the day on home page
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'));
complete_substitutions_array($substitutionarray, $langs);
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount'));
complete_substitutions_array($substitutionarray, $langs);
print '<tr><td class="titlefield">';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val)
{
$texthelp.=$key.'<br>';
}
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday');
print '<tr><td class="titlefield">';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val)
{
$texthelp.=$key.'<br>';
}
print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday');
print '</td><td colspan="2">';
print '</td><td colspan="2">';
$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
$doleditor = new DolEditor('main_motd', (isset($conf->global->MAIN_MOTD)?$conf->global->MAIN_MOTD:''), '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, '90%');
$doleditor->Create();
print '</td></tr>'."\n";
@ -383,12 +383,12 @@ if ($action == 'edit') // Edit
// Message on login page
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object','objectamount','user'));
complete_substitutions_array($substitutionarray, $langs);
print '<tr><td>';
complete_substitutions_array($substitutionarray, $langs);
print '<tr><td>';
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
foreach($substitutionarray as $key => $val)
{
$texthelp.=$key.'<br>';
$texthelp.=$key.'<br>';
}
print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin');
print '</td><td colspan="2">';
@ -405,16 +405,16 @@ if ($action == 'edit') // Edit
// Background
print '<tr><td><label for="imagebackground">'.$langs->trans("BackgroundImageLogin").' (png,jpg)</label></td><td colspan="2">';
print '<div class="centpercent inline-block">';
print '<div class="centpercent inline-block">';
print '<input type="file" class="flat class=minwidth200" name="imagebackground" id="imagebackground">';
if (! empty($conf->global->MAIN_LOGIN_BACKGROUND)) {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=removebackgroundlogin">'.img_delete($langs->trans("Delete")).'</a>';
if (file_exists($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) {
print ' &nbsp; ';
print '<img class="paddingleft valignmiddle" width="100px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('/'.$conf->global->MAIN_LOGIN_BACKGROUND).'">';
}
print '<a href="'.$_SERVER["PHP_SELF"].'?action=removebackgroundlogin">'.img_delete($langs->trans("Delete")).'</a>';
if (file_exists($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) {
print ' &nbsp; ';
print '<img class="paddingleft valignmiddle" width="100px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('/'.$conf->global->MAIN_LOGIN_BACKGROUND).'">';
}
} else {
print '<img class="paddingleft valignmiddle" width="100" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
print '<img class="paddingleft valignmiddle" width="100" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
}
print '</div>';
print '</td></tr>';
@ -422,31 +422,31 @@ if ($action == 'edit') // Edit
print '</table>'."\n";
print '<br><div class="center">';
print '<input class="button" type="submit" name="submit" value="'.$langs->trans("Save").'">';
print ' &nbsp; ';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '<br><div class="center">';
print '<input class="button" type="submit" name="submit" value="'.$langs->trans("Save").'">';
print ' &nbsp; ';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
print '</form>';
}
else // Show
{
// Language
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Language").'</td><td></td><td>&nbsp;</td></tr>';
// Language
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Language").'</td><td></td><td>&nbsp;</td></tr>';
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
$s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
print ($s?$s.' ':'');
print ($conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT));
print '</td>';
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultLanguage").'</td><td>';
$s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
print ($s?$s.' ':'');
print ($conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT));
print '</td>';
print '<td width="20">';
if ($user->admin && $conf->global->MAIN_LANG_DEFAULT!='auto') print info_admin($langs->trans("SubmitTranslation".($conf->global->MAIN_LANG_DEFAULT=='en_US'?'ENUS':''),$conf->global->MAIN_LANG_DEFAULT),1);
if ($user->admin && $conf->global->MAIN_LANG_DEFAULT!='auto') print info_admin($langs->trans("SubmitTranslation".($conf->global->MAIN_LANG_DEFAULT=='en_US'?'ENUS':''),$conf->global->MAIN_LANG_DEFAULT),1);
print '</td>';
print "</tr>";
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>' . yn($conf->global->MAIN_MULTILANGS) . '</td>';
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>' . yn($conf->global->MAIN_MULTILANGS) . '</td>';
print '<td width="20">&nbsp;</td>';
print "</tr>";
@ -454,19 +454,19 @@ else // Show
// Themes
show_theme(null,0);
print '<br>';
show_theme(null,0);
print '<br>';
// Other
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameters").'</td><td colspan="2">'.$langs->trans("Value").'</td></tr>';
// Other
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameters").'</td><td colspan="2">'.$langs->trans("Value").'</td></tr>';
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeList").'</td><td>' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '</td>';
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeList").'</td><td>' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '</td>';
print '<td width="20">&nbsp;</td>';
print "</tr>";
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td>' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '</td>';
print '<tr class="oddeven"><td>'.$langs->trans("DefaultMaxSizeShortList").'</td><td>' . $conf->global->MAIN_SIZE_SHORTLIST_LIMIT . '</td>';
print '<td width="20">&nbsp;</td>';
print "</tr>";
@ -477,38 +477,38 @@ else // Show
print "</tr>";
*/
// Disable javascript/ajax
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableJavascript").'</td><td>';
print yn($conf->global->MAIN_DISABLE_JAVASCRIPT)."</td>";
print '<td width="20">&nbsp;</td>';
print "</tr>";
// Disable javascript/ajax
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableJavascript").'</td><td>';
print yn($conf->global->MAIN_DISABLE_JAVASCRIPT)."</td>";
print '<td width="20">&nbsp;</td>';
print "</tr>";
// First day for weeks
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("WeekStartOnDay").'</td><td>';
print $langs->trans("Day".(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'));
print '</td>';
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("WeekStartOnDay").'</td><td>';
print $langs->trans("Day".(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'));
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// DefaultWorkingDays
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultWorkingDays").'</td><td>';
print isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5';
print '</td>';
// DefaultWorkingDays
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultWorkingDays").'</td><td>';
print isset($conf->global->MAIN_DEFAULT_WORKING_DAYS)?$conf->global->MAIN_DEFAULT_WORKING_DAYS:'1-5';
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// DefaultWorkingHours
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultWorkingHours").'</td><td>';
print isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18';
print '</td>';
// DefaultWorkingHours
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DefaultWorkingHours").'</td><td>';
print isset($conf->global->MAIN_DEFAULT_WORKING_HOURS)?$conf->global->MAIN_DEFAULT_WORKING_HOURS:'9-18';
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
// Firstname / Name position
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("FirstnameNamePosition").'</td><td>';
if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { print $langs->trans("Firstname").' '.$langs->trans("Lastname"); }
else { print $langs->trans("Lastname").' '.$langs->trans("Firstname"); }
print '</td>';
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("FirstnameNamePosition").'</td><td>';
if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { print $langs->trans("Firstname").' '.$langs->trans("Lastname"); }
else { print $langs->trans("Lastname").' '.$langs->trans("Firstname"); }
print '</td>';
print '<td width="20">&nbsp;</td>';
print '</tr>';
@ -517,8 +517,8 @@ else // Show
print yn((isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0),1);
print '</td></tr>';
// Show logo
print '<tr class="oddeven"><td>'.$langs->trans("EnableShowLogo").'</td><td>' . yn($conf->global->MAIN_SHOW_LOGO) . '</td>';
// Show logo
print '<tr class="oddeven"><td>'.$langs->trans("EnableShowLogo").'</td><td>' . yn($conf->global->MAIN_SHOW_LOGO) . '</td>';
print '<td width="20">&nbsp;</td>';
print "</tr>";
@ -531,62 +531,62 @@ else // Show
print '</tr>';
*/
// Show bugtrack link
// Show bugtrack link
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).'</td><td>';
print yn($conf->global->MAIN_BUGTRACK_ENABLELINK)."</td>";
print '<td width="20">&nbsp;</td>';
print "</tr>";
// Link to wiki help
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td colspan="2">';
print yn((isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0),1);
print '</td></tr>';
// Link to wiki help
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td colspan="2">';
print yn((isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0),1);
print '</td></tr>';
// Message of the day
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
if (isset($conf->global->MAIN_MOTD)) print dol_htmlcleanlastbr($conf->global->MAIN_MOTD);
else print '&nbsp;';
print '</td></tr>'."\n";
// Message of the day
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
if (isset($conf->global->MAIN_MOTD)) print dol_htmlcleanlastbr($conf->global->MAIN_MOTD);
else print '&nbsp;';
print '</td></tr>'."\n";
print '</table>'."\n";
print '</table>'."\n";
print '<br>';
print '<br>';
// Login page
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("LoginPage").'</td><td></td><td>&nbsp;</td></tr>';
// Login page
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("LoginPage").'</td><td></td><td>&nbsp;</td></tr>';
// Message login
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("MessageLogin").'</td><td colspan="2">';
if (isset($conf->global->MAIN_HOME)) print dol_htmlcleanlastbr($conf->global->MAIN_HOME);
else print '&nbsp;';
print '</td></tr>'."\n";
// Message login
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("MessageLogin").'</td><td colspan="2">';
if (isset($conf->global->MAIN_HOME)) print dol_htmlcleanlastbr($conf->global->MAIN_HOME);
else print '&nbsp;';
print '</td></tr>'."\n";
// Link to help center
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableLinkToHelpCenter").'</td><td colspan="2">';
print yn((isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0),1);
print '</td></tr>';
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("DisableLinkToHelpCenter").'</td><td colspan="2">';
print yn((isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0),1);
print '</td></tr>';
// Background login
print '<tr class="oddeven"><td>'.$langs->trans("BackgroundImageLogin").'</td><td colspan="2">';
print '<div class="centpercent inline-block">';
print $conf->global->MAIN_LOGIN_BACKGROUND;
if ($conf->global->MAIN_LOGIN_BACKGROUND && is_file($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND))
{
print '<img class="img_logo paddingleft valignmiddle" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'">';
}
else
{
print '<img class="img_logo paddingleft valignmiddle" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
}
print '</div>';
print '</td></tr>';
// Background login
print '<tr class="oddeven"><td>'.$langs->trans("BackgroundImageLogin").'</td><td colspan="2">';
print '<div class="centpercent inline-block">';
print $conf->global->MAIN_LOGIN_BACKGROUND;
if ($conf->global->MAIN_LOGIN_BACKGROUND && is_file($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND))
{
print '<img class="img_logo paddingleft valignmiddle" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'">';
}
else
{
print '<img class="img_logo paddingleft valignmiddle" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
}
print '</div>';
print '</td></tr>';
print '</table>'."\n";
print '</table>'."\n";
print '<div class="tabsAction tabsActionNoBottom">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
print '</div>';
print '<div class="tabsAction tabsActionNoBottom">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
print '</div>';
}

View File

@ -66,7 +66,7 @@ if ($action == 'setvalue' && $user->admin)
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE',GETPOST("fieldphone"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO',GETPOST("fieldphoneperso"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY',GETPOST("fieldcompany"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS',GETPOST("fieldaddress"),'chaine',0,'',$conf->entity)) $error++;
@ -85,22 +85,22 @@ if ($action == 'setvalue' && $user->admin)
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"),'chaine',0,'',$conf->entity)) $error++;
// This one must be after the others
$valkey='';
$key=GETPOST("key");
if ($key) $valkey=$conf->global->$key;
if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS',$valkey,'chaine',0,'',$conf->entity)) $error++;
// This one must be after the others
$valkey='';
$key=GETPOST("key");
if ($key) $valkey=$conf->global->$key;
if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS',$valkey,'chaine',0,'',$conf->entity)) $error++;
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
dol_print_error($db);
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
dol_print_error($db);
}
}

View File

@ -63,7 +63,7 @@ if ($action == 'setvalue' && $user->admin)
if (! dolibarr_set_const($db, 'LDAP_FIELD_MAIL',GETPOST("fieldmail"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE',GETPOST("fieldphone"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_SKYPE',GETPOST("fieldskype"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_COMPANY',GETPOST("fieldcompany"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS',GETPOST("fieldaddress"),'chaine',0,'',$conf->entity)) $error++;
@ -74,22 +74,22 @@ if ($action == 'setvalue' && $user->admin)
if (! dolibarr_set_const($db, 'LDAP_FIELD_SID',GETPOST("fieldsid"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_TITLE',GETPOST("fieldtitle"),'chaine',0,'',$conf->entity)) $error++;
// This one must be after the others
$valkey='';
$key=GETPOST("key");
if ($key) $valkey=$conf->global->$key;
if (! dolibarr_set_const($db, 'LDAP_KEY_USERS',$valkey,'chaine',0,'',$conf->entity)) $error++;
// This one must be after the others
$valkey='';
$key=GETPOST("key");
if ($key) $valkey=$conf->global->$key;
if (! dolibarr_set_const($db, 'LDAP_KEY_USERS',$valkey,'chaine',0,'',$conf->entity)) $error++;
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
dol_print_error($db);
}
if (! $error)
{
$db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
dol_print_error($db);
}
}
@ -430,7 +430,7 @@ if (function_exists("ldap_connect"))
{
$required_fields = array(
$conf->global->LDAP_KEY_USERS,
$conf->global->LDAP_FIELD_FULLNAME,
$conf->global->LDAP_FIELD_FULLNAME,
$conf->global->LDAP_FIELD_NAME,
$conf->global->LDAP_FIELD_FIRSTNAME,
$conf->global->LDAP_FIELD_LOGIN,
@ -439,7 +439,7 @@ if (function_exists("ldap_connect"))
$conf->global->LDAP_FIELD_PASSWORD_CRYPTED,
$conf->global->LDAP_FIELD_PHONE,
$conf->global->LDAP_FIELD_FAX,
$conf->global->LDAP_FIELD_SKYPE,
$conf->global->LDAP_FIELD_SKYPE,
$conf->global->LDAP_FIELD_MOBILE,
$conf->global->LDAP_FIELD_MAIL,
$conf->global->LDAP_FIELD_TITLE,
@ -447,35 +447,35 @@ if (function_exists("ldap_connect"))
$conf->global->LDAP_FIELD_SID
);
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
$required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement")));
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
$required_fields=array_unique(array_values(array_filter($required_fields, "dol_validElement")));
// Get from LDAP database an array of results
$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
//$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, '', 1);
// Get from LDAP database an array of results
$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1);
//$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, '', 1);
if (is_array($ldapusers))
{
$liste=array();
foreach ($ldapusers as $key => $ldapuser)
{
// Define the label string for this user
$label='';
foreach ($required_fields as $value)
{
if ($value)
{
$label.=$value."=".$ldapuser[$value]." ";
}
}
$liste[$key] = $label;
}
if (is_array($ldapusers))
{
$liste=array();
foreach ($ldapusers as $key => $ldapuser)
{
// Define the label string for this user
$label='';
foreach ($required_fields as $value)
{
if ($value)
{
$label.=$value."=".$ldapuser[$value]." ";
}
}
$liste[$key] = $label;
}
}
else
{
setEventMessages($ldap->error, $ldap->errors, 'errors');
}
}
else
{
setEventMessages($ldap->error, $ldap->errors, 'errors');
}
print "<br>\n";
print "LDAP search for user:<br>\n";

View File

@ -87,94 +87,94 @@ class Documents extends DolibarrApi
if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
{
throw new RestException(401);
throw new RestException(401);
}
if (!$accessallowed) {
throw new RestException(401);
}
if (!$accessallowed) {
throw new RestException(401);
}
// --- Generates the document
if ($regeneratedoc)
{
$hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1;
$hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1;
$hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1;
// --- Generates the document
if ($regeneratedoc)
{
$hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1;
$hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1;
$hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1;
if ($module_part == 'facture' || $module_part == 'invoice')
{
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$this->invoice = new Facture($this->db);
$result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
$result = $this->invoice->generateDocument($this->invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if( $result <= 0 ) {
throw new RestException(500, 'Error generating document');
}
}
}
if ($module_part == 'facture' || $module_part == 'invoice')
{
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$this->invoice = new Facture($this->db);
$result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if( ! $result ) {
throw new RestException(404, 'Invoice not found');
}
$result = $this->invoice->generateDocument($this->invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
if( $result <= 0 ) {
throw new RestException(500, 'Error generating document');
}
}
}
$filename = basename($original_file);
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
if (! file_exists($original_file_osencoded))
{
throw new RestException(404, 'File not found');
throw new RestException(404, 'File not found');
}
$file_content=file_get_contents($original_file_osencoded);
return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' );
}
return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' );
}
/**
* Return a document.
*
* @param int $id ID of document
* @return array Array with data of file
*
* @throws RestException
*/
/*
/**
* Return a document.
*
* @param int $id ID of document
* @return array Array with data of file
*
* @throws RestException
*/
/*
public function get($id) {
return array('note'=>'xxx');
}*/
/**
* Push a file.
* Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
* Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
*
* @param string $filename Name of file to create ('FA1705-0123')
* @param string $modulepart Name of module or area concerned by file upload ('facture', ...)
* @param string $ref Reference of object (This will define subdir automatically and store submited file into it)
* @param string $subdir Subdirectory (Only if ref not provided)
* @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided)
* @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64)
* @param int $overwriteifexists Overwrite file if exists (1 by default)
* @return bool State of copy
* @throws RestException
*/
public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0)
{
global $db, $conf;
/**
* Push a file.
* Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
* Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
*
* @param string $filename Name of file to create ('FA1705-0123')
* @param string $modulepart Name of module or area concerned by file upload ('facture', ...)
* @param string $ref Reference of object (This will define subdir automatically and store submited file into it)
* @param string $subdir Subdirectory (Only if ref not provided)
* @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided)
* @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64)
* @param int $overwriteifexists Overwrite file if exists (1 by default)
* @return bool State of copy
* @throws RestException
*/
public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0)
{
global $db, $conf;
/*var_dump($modulepart);
/*var_dump($modulepart);
var_dump($filename);
var_dump($filecontent);
exit;*/
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
if (!DolibarrApiAccess::$user->rights->ecm->upload) {
throw new RestException(401);
}
if (!DolibarrApiAccess::$user->rights->ecm->upload) {
throw new RestException(401);
}
$newfilecontent = '';
if (empty($fileencoding)) $newfilecontent = $filecontent;
if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent);
$newfilecontent = '';
if (empty($fileencoding)) $newfilecontent = $filecontent;
if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent);
$original_file = dol_sanitizeFileName($filename);

View File

@ -231,8 +231,8 @@ if (empty($reshook))
// Validation
else if ($action == 'confirm_validate' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
)
{
$result = $object->valid($user);
@ -294,15 +294,15 @@ if (empty($reshook))
$result = $object->set_ref_client($user, GETPOST('ref_client'));
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
// Set incoterm
elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled))
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
}
{
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
}
// Create proposal
else if ($action == 'add' && $user->rights->propal->creer)
@ -346,11 +346,11 @@ if (empty($reshook))
$object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = GETPOST('demand_reason_id');
$object->fk_delivery_address = GETPOST('fk_address');
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->duree_validite = $duration;
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->fk_account = GETPOST('fk_account', 'int');
$object->remise_percent = GETPOST('remise_percent');
$object->remise_absolue = GETPOST('remise_absolue');
$object->socid = GETPOST('socid');
@ -377,11 +377,11 @@ if (empty($reshook))
$object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = GETPOST('demand_reason_id');
$object->fk_delivery_address = GETPOST('fk_address');
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
$object->duree_validite = GETPOST('duree_validite');
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->fk_account = GETPOST('fk_account', 'int');
$object->contactid = GETPOST('contactid');
$object->fk_project = GETPOST('projectid');
$object->modelpdf = GETPOST('model');
@ -527,7 +527,7 @@ if (empty($reshook))
// Hooks
$parameters = array('objFrom' => $srcobject);
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
// modified by hook
if ($reshook < 0)
$error ++;
} else {
@ -561,23 +561,23 @@ if (empty($reshook))
{
$db->commit();
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
}
$ret = $object->fetch($id); // Reload to get new records
$result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db,$result);
}
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
exit();
@ -647,7 +647,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
$actiontypecode='AC_OTH_AUTO';
$actiontypecode='AC_OTH_AUTO';
$trigger_name='PROPAL_SENTBYMAIL';
$autocopy='MAIN_MAIL_AUTOCOPY_PROPOSAL_TO';
$trackid='pro'.$object->id;
@ -756,7 +756,7 @@ if (empty($reshook))
$db->begin();
// $tva_tx can be 'x.x (XXX)'
// $tva_tx can be 'x.x (XXX)'
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
@ -781,7 +781,7 @@ if (empty($reshook))
// On defini prix unitaire
if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level)
{
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
@ -801,7 +801,7 @@ if (empty($reshook))
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
if ($result) {
// If there is some prices specific to the customer
// If there is some prices specific to the customer
if (count($prodcustprice->lines) > 0) {
$pu_ht = price($prodcustprice->lines[0]->price);
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
@ -949,18 +949,18 @@ if (empty($reshook))
unset($_POST['idprod']);
unset($_POST['units']);
unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
unset($_POST['date_startsec']);
unset($_POST['date_startday']);
unset($_POST['date_startmonth']);
unset($_POST['date_startyear']);
unset($_POST['date_endhour']);
unset($_POST['date_endmin']);
unset($_POST['date_endsec']);
unset($_POST['date_endday']);
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
unset($_POST['date_startsec']);
unset($_POST['date_startday']);
unset($_POST['date_startmonth']);
unset($_POST['date_startyear']);
unset($_POST['date_endhour']);
unset($_POST['date_endmin']);
unset($_POST['date_endsec']);
unset($_POST['date_endday']);
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
} else {
$db->rollback();
@ -1159,12 +1159,12 @@ if (empty($reshook))
// bank account
else if ($action == 'setbankaccount' && $user->rights->propal->creer) {
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
}
// shipping method
else if ($action == 'setshippingmethod' && $user->rights->propal->creer) {
$result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
$result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
}
else if ($action == 'update_extras') {
@ -1225,10 +1225,10 @@ if (empty($reshook))
}
}
// Actions to build doc
$upload_dir = $conf->propal->dir_output;
$permissioncreate=$user->rights->propal->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to build doc
$upload_dir = $conf->propal->dir_output;
$permissioncreate=$user->rights->propal->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
}
@ -1252,7 +1252,7 @@ $now = dol_now();
// Add new proposal
if ($action == 'create')
{
$currency_code = $conf->currency;
$currency_code = $conf->currency;
print load_fiche_titre($langs->trans("NewProp"));
@ -1317,14 +1317,14 @@ if ($action == 'create')
if (!empty($conf->multicurrency->enabled))
{
if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
}
}
}
else
{
if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
}
$object = new Propal($db);
@ -1359,9 +1359,9 @@ if ($action == 'create')
print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="' . $soc->id . '">';
print '</td>';
if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && ! empty($soc->shipping_method_id)) {
$shipping_method_id = $soc->shipping_method_id;
}
if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && ! empty($soc->shipping_method_id)) {
$shipping_method_id = $soc->shipping_method_id;
}
} else {
print '<td>';
print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
@ -1427,12 +1427,12 @@ if ($action == 'create')
$form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id');
print '</td></tr>';
// Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) {
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td>';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
}
// Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) {
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td>';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
}
// What trigger creation
print '<tr><td>' . $langs->trans('Source') . '</td><td>';
@ -1444,12 +1444,12 @@ if ($action == 'create')
$form->selectAvailabilityDelay('', 'availability_id', '', 1);
print '</td></tr>';
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>';
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
print '</td></tr>';
}
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>';
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
print '</td></tr>';
}
// Delivery date (or manufacturing)
print '<tr><td>' . $langs->trans("DeliveryDate") . '</td>';
@ -1485,8 +1485,8 @@ if ($action == 'create')
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->libelle_incoterms, 1).'</label></td>';
print '<td class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:''));
print '<td class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:''));
print '</td></tr>';
}
@ -1503,8 +1503,8 @@ if ($action == 'create')
{
print '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
print '<td class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
print '</td></tr>';
}
@ -1522,7 +1522,7 @@ if ($action == 'create')
print '<tr>';
print '<td class="tdtop">' . $langs->trans('NotePrivate') . '</td>';
print '<td valign="top">';
$note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null));
$note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null));
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
// print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
@ -1587,7 +1587,7 @@ if ($action == 'create')
if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE))
{
print '<br><table>';
print '<br><table>';
// For backward compatibility
print '<tr>';
@ -1690,13 +1690,13 @@ if ($action == 'create')
//array('type' => 'other','name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '<textarea cols="30" rows="' . ROWS_3 . '" wrap="soft" name="note_private" id="note_private">'.$object->note_private.'</textarea>'));
array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => $object->note_private));
if (! empty($conf->notification->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
$notify = new Notify($db);
$formquestion = array_merge($formquestion, array(
array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)),
));
}
if (! empty($conf->notification->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
$notify = new Notify($db);
$formquestion = array_merge($formquestion, array(
array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)),
));
}
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('SetAcceptedRefused'), $text, 'setstatut', $formquestion, '', 1, 250);
@ -1765,50 +1765,50 @@ if ($action == 'create')
// Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->thirdparty->id.'">'.$langs->trans("OtherProposals").'</a>)';
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->propal->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->propal->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
@ -1941,24 +1941,24 @@ if ($action == 'create')
print '</td>';
print '</tr>';
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('SendingMethod');
print '</td>';
if ($action != 'editshippingmethod' && $user->rights->propal->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&amp;id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editshippingmethod') {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
} else {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none');
}
print '</td>';
print '</tr>';
}
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('SendingMethod');
print '</td>';
if ($action != 'editshippingmethod' && $user->rights->propal->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&amp;id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editshippingmethod') {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
} else {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none');
}
print '</td>';
print '</tr>';
}
// Origin of demand
print '<tr><td>';
@ -2054,36 +2054,36 @@ if ($action == 'create')
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled))
{
// Bank Account
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('BankAccount');
print '</td>';
if ($action != 'editbankaccount' && $user->rights->propal->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
// Bank Account
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('BankAccount');
print '</td>';
if ($action != 'editbankaccount' && $user->rights->propal->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
}
// Incoterms
if (!empty($conf->incoterm->enabled))
{
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->propal->creer) print '<a href="'.DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td align="right">';
if ($user->rights->propal->creer) print '<a href="'.DOL_URL_ROOT.'/comm/propal/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td>';
if ($action != 'editincoterm')
{
print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1);
@ -2092,7 +2092,7 @@ if ($action == 'create')
{
print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms)?$object->location_incoterms:''), $_SERVER['PHP_SELF'].'?id='.$object->id);
}
print '</td></tr>';
print '</td></tr>';
}
// Other attributes
@ -2105,25 +2105,25 @@ if ($action == 'create')
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '<table class="border centpercent">';
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
{
// Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
{
// Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Amount HT
print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
@ -2138,15 +2138,15 @@ if ($action == 'create')
// Amount Local Taxes
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) // Localtax1
{
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>';
print '<td class="nowrap">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td>';
print '<td class="nowrap">' . price($object->total_localtax1, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
}
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) // Localtax2
{
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>';
print '<td class="nowrap">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td>';
print '<td class="nowrap">' . price($object->total_localtax2, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
print '</tr>';
}
// Amount TTC
@ -2162,7 +2162,7 @@ if ($action == 'create')
// Margin Infos
if (! empty($conf->margin->enabled))
{
$formmargin->displayMarginInfos($object);
$formmargin->displayMarginInfos($object);
}
print '</div>';
@ -2201,7 +2201,7 @@ if ($action == 'create')
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
}
print '<div class="div-table-responsive">';
print '<div class="div-table-responsive">';
print '<table id="tablelines" class="noborder noshadow" width="100%">';
if (! empty($object->lines))
@ -2223,7 +2223,7 @@ if ($action == 'create')
}
print '</table>';
print '</div>';
print '</div>';
print "</form>\n";
@ -2237,7 +2237,7 @@ if ($action == 'create')
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
// modified by hook
if (empty($reshook))
{
if ($action != 'editline')
@ -2245,12 +2245,12 @@ if ($action == 'create')
// Validate
if ($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0)
{
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
{
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>';
}
else
}
else
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">' . $langs->trans('Validate') . '</a></div>';
}
// Create event

View File

@ -30,225 +30,225 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
class Proposals extends DolibarrApi
{
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
'socid'
);
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
'socid'
);
/**
* @var propal $propal {@type propal}
*/
public $propal;
/**
* @var propal $propal {@type propal}
*/
public $propal;
/**
* Constructor
*/
function __construct()
{
/**
* Constructor
*/
function __construct()
{
global $db, $conf;
$this->db = $db;
$this->propal = new Propal($this->db);
}
$this->propal = new Propal($this->db);
}
/**
* Get properties of a commercial proposal object
*
* Return an array with commercial proposal informations
*
* @param int $id ID of commercial proposal
* @return array|mixed data without useless information
/**
* Get properties of a commercial proposal object
*
* @throws RestException
*/
function get($id)
{
* Return an array with commercial proposal informations
*
* @param int $id ID of commercial proposal
* @return array|mixed data without useless information
*
* @throws RestException
*/
function get($id)
{
if(! DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found');
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->propal->fetchObjectLinked();
$this->propal->fetchObjectLinked();
return $this->_cleanObjectDatas($this->propal);
}
}
/**
* List commercial proposals
*
* Get a list of commercial proposals
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter commercial proposal of. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
* @return array Array of order objects
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
global $db, $conf;
/**
* List commercial proposals
*
* Get a list of commercial proposals
*
* @param string $sortfield Sort field
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $thirdparty_ids Thirdparty ids to filter commercial proposal of. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i}
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
* @return array Array of order objects
*/
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
global $db, $conf;
$obj_ret = array();
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."propal as t";
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
$sql.= " FROM ".MAIN_DB_PREFIX."propal as t";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
$sql.= ' WHERE t.entity IN ('.getEntity('propal').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Insert sale filter
if ($search_sale > 0)
{
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= ' WHERE t.entity IN ('.getEntity('propal').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Insert sale filter
if ($search_sale > 0)
{
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
if ($sqlfilters)
{
if (! DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql.= $db->order($sortfield, $sortorder);
if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
$sql.= $db->plimit($limit + 1, $offset);
}
$sql.= $db->plimit($limit + 1, $offset);
}
$result = $db->query($sql);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
{
$obj = $db->fetch_object($result);
$propal_static = new Propal($db);
if($propal_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($propal_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No order found');
}
if ($result)
{
$num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min)
{
$obj = $db->fetch_object($result);
$propal_static = new Propal($db);
if($propal_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($propal_static);
}
$i++;
}
}
else {
throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror());
}
if( ! count($obj_ret)) {
throw new RestException(404, 'No order found');
}
return $obj_ret;
}
}
/**
* Create commercial proposal object
*
* @param array $request_data Request data
* @return int ID of propal
*/
function post($request_data = NULL)
{
if(! DolibarrApiAccess::$user->rights->propal->creer) {
/**
* Create commercial proposal object
*
* @param array $request_data Request data
* @return int ID of propal
*/
function post($request_data = NULL)
{
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
$result = $this->_validate($request_data);
// Check mandatory fields
$result = $this->_validate($request_data);
foreach($request_data as $field => $value) {
$this->propal->$field = $value;
}
/*if (isset($request_data["lines"])) {
foreach($request_data as $field => $value) {
$this->propal->$field = $value;
}
/*if (isset($request_data["lines"])) {
$lines = array();
foreach ($request_data["lines"] as $line) {
array_push($lines, (object) $line);
}
$this->propal->lines = $lines;
}*/
if ($this->propal->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors));
}
if ($this->propal->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors));
}
return $this->propal->id;
}
return $this->propal->id;
}
/**
* Get lines of a commercial proposal
*
* @param int $id Id of commercial proposal
*
* @url GET {id}/lines
*
* @return int
*/
function getLines($id) {
if(! DolibarrApiAccess::$user->rights->propal->lire) {
/**
* Get lines of a commercial proposal
*
* @param int $id Id of commercial proposal
*
* @url GET {id}/lines
*
* @return int
*/
function getLines($id) {
if(! DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found');
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->propal->getLinesArray();
$result = array();
foreach ($this->propal->lines as $line) {
array_push($result,$this->_cleanObjectDatas($line));
}
return $result;
}
}
$this->propal->getLinesArray();
$result = array();
foreach ($this->propal->lines as $line) {
array_push($result,$this->_cleanObjectDatas($line));
}
return $result;
}
/**
* Add a line to given commercial proposal
*
* @param int $id Id of commercial proposal to update
* @param array $request_data Commercial proposal line data
*
* @url POST {id}/lines
*
* @return int
*/
function postLine($id, $request_data = NULL)
{
/**
* Add a line to given commercial proposal
*
* @param int $id Id of commercial proposal to update
* @param array $request_data Commercial proposal line data
*
* @url POST {id}/lines
*
* @return int
*/
function postLine($id, $request_data = NULL)
{
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
if (! $result) {
throw new RestException(404, 'Commercial Proposal not found');
}
$result = $this->propal->fetch($id);
if (! $result) {
throw new RestException(404, 'Commercial Proposal not found');
}
if (! DolibarrApi::_checkAccessToResource('propal',$this->propal->id))
{
@ -257,288 +257,288 @@ class Proposals extends DolibarrApi
$request_data = (object) $request_data;
$updateRes = $this->propal->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
'HT',
0,
$request_data->info_bits,
$request_data->product_type,
$request_data->rang,
$request_data->special_code,
$fk_parent_line,
$request_data->fk_fournprice,
$request_data->pa_ht,
$request_data->label,
$request_data->date_start,
$request_data->date_end,
$request_data->array_options,
$request_data->fk_unit,
$this->element,
$request_data->id,
$request_data->multicurrency_subprice,
$request_data->fk_remise_except
);
$updateRes = $this->propal->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
'HT',
0,
$request_data->info_bits,
$request_data->product_type,
$request_data->rang,
$request_data->special_code,
$fk_parent_line,
$request_data->fk_fournprice,
$request_data->pa_ht,
$request_data->label,
$request_data->date_start,
$request_data->date_end,
$request_data->array_options,
$request_data->fk_unit,
$this->element,
$request_data->id,
$request_data->multicurrency_subprice,
$request_data->fk_remise_except
);
if ($updateRes > 0) {
return $this->get($id)->line->rowid;
if ($updateRes > 0) {
return $this->get($id)->line->rowid;
}
return false;
}
}
return false;
}
/**
* Update a line of given commercial proposal
*
* @param int $id Id of commercial proposal to update
* @param int $lineid Id of line to update
* @param array $request_data Commercial proposal line data
*
* @url PUT {id}/lines/{lineid}
*
* @return object
*/
function putLine($id, $lineid, $request_data = NULL)
{
if(! DolibarrApiAccess::$user->rights->propal->creer) {
/**
* Update a line of given commercial proposal
*
* @param int $id Id of commercial proposal to update
* @param int $lineid Id of line to update
* @param array $request_data Commercial proposal line data
*
* @url PUT {id}/lines/{lineid}
*
* @return object
*/
function putLine($id, $lineid, $request_data = NULL)
{
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
if($result <= 0) {
throw new RestException(404, 'Proposal not found');
}
$result = $this->propal->fetch($id);
if($result <= 0) {
throw new RestException(404, 'Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
}
$request_data = (object) $request_data;
$request_data = (object) $request_data;
$propalline = new PropaleLigne($this->db);
$result = $propalline->fetch($lineid);
if ($result <= 0) {
throw new RestException(404, 'Proposal line not found');
}
$propalline = new PropaleLigne($this->db);
$result = $propalline->fetch($lineid);
if ($result <= 0) {
throw new RestException(404, 'Proposal line not found');
}
$updateRes = $this->propal->updateline(
$lineid,
isset($request_data->subprice)?$request_data->subprice:$propalline->subprice,
isset($request_data->qty)?$request_data->qty:$propalline->qty,
isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent,
isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx,
isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx,
isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx,
isset($request_data->desc)?$request_data->desc:$propalline->desc,
'HT',
isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits,
isset($request_data->special_code)?$request_data->special_code:$propalline->special_code,
isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line,
0,
isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice,
isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht,
isset($request_data->label)?$request_data->label:$propalline->label,
isset($request_data->product_type)?$request_data->product_type:$propalline->product_type,
isset($request_data->date_start)?$request_data->date_start:$propalline->date_start,
isset($request_data->date_end)?$request_data->date_end:$propalline->date_end,
isset($request_data->array_options)?$request_data->array_options:$propalline->array_options,
isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit,
isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice
);
$updateRes = $this->propal->updateline(
$lineid,
isset($request_data->subprice)?$request_data->subprice:$propalline->subprice,
isset($request_data->qty)?$request_data->qty:$propalline->qty,
isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent,
isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx,
isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx,
isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx,
isset($request_data->desc)?$request_data->desc:$propalline->desc,
'HT',
isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits,
isset($request_data->special_code)?$request_data->special_code:$propalline->special_code,
isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line,
0,
isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice,
isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht,
isset($request_data->label)?$request_data->label:$propalline->label,
isset($request_data->product_type)?$request_data->product_type:$propalline->product_type,
isset($request_data->date_start)?$request_data->date_start:$propalline->date_start,
isset($request_data->date_end)?$request_data->date_end:$propalline->date_end,
isset($request_data->array_options)?$request_data->array_options:$propalline->array_options,
isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit,
isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice
);
if ($updateRes > 0) {
$result = $this->get($id);
unset($result->line);
return $this->_cleanObjectDatas($result);
}
return false;
}
if ($updateRes > 0) {
$result = $this->get($id);
unset($result->line);
return $this->_cleanObjectDatas($result);
}
return false;
}
/**
* Delete a line of given commercial proposal
*
*
* @param int $id Id of commercial proposal to update
* @param int $lineid Id of line to delete
*
* @url DELETE {id}/lines/{lineid}
*
* @return int
*/
function delLine($id, $lineid) {
if(! DolibarrApiAccess::$user->rights->propal->creer) {
/**
* Delete a line of given commercial proposal
*
*
* @param int $id Id of commercial proposal to update
* @param int $lineid Id of line to delete
*
* @url DELETE {id}/lines/{lineid}
*
* @return int
*/
function delLine($id, $lineid) {
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Proposal not found');
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
}
$request_data = (object) $request_data;
$updateRes = $this->propal->deleteline($lineid);
if ($updateRes == 1) {
return $this->get($id);
}
return false;
}
$updateRes = $this->propal->deleteline($lineid);
if ($updateRes == 1) {
return $this->get($id);
}
return false;
}
/**
* Update commercial proposal general fields (won't touch lines of commercial proposal)
*
* @param int $id Id of commercial proposal to update
* @param array $request_data Datas
*
* @return int
*/
function put($id, $request_data = NULL) {
if(! DolibarrApiAccess::$user->rights->propal->creer) {
/**
* Update commercial proposal general fields (won't touch lines of commercial proposal)
*
* @param int $id Id of commercial proposal to update
* @param array $request_data Datas
*
* @return int
*/
function put($id, $request_data = NULL) {
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Proposal not found');
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach($request_data as $field => $value) {
if ($field == 'id') continue;
$this->propal->$field = $value;
}
foreach($request_data as $field => $value) {
if ($field == 'id') continue;
$this->propal->$field = $value;
}
if($this->propal->update($id, DolibarrApiAccess::$user,1,'','','update'))
return $this->get($id);
if($this->propal->update($id, DolibarrApiAccess::$user,1,'','','update'))
return $this->get($id);
return false;
}
return false;
}
/**
* Delete commercial proposal
*
* @param int $id Commercial proposal ID
*
* @return array
*/
function delete($id)
{
if(! DolibarrApiAccess::$user->rights->propal->supprimer) {
/**
* Delete commercial proposal
*
* @param int $id Commercial proposal ID
*
* @return array
*/
function delete($id)
{
if(! DolibarrApiAccess::$user->rights->propal->supprimer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found');
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if( ! $this->propal->delete(DolibarrApiAccess::$user)) {
throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error);
}
if( ! $this->propal->delete(DolibarrApiAccess::$user)) {
throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Commercial Proposal deleted'
)
);
return array(
'success' => array(
'code' => 200,
'message' => 'Commercial Proposal deleted'
)
);
}
}
/**
* Validate a commercial proposal
*
* @param int $id Commercial proposal ID
* @param int $notrigger Use {}
*
* @url POST {id}/validate
*
* @return array
* FIXME An error 403 is returned if the request has an empty body.
* Error message: "Forbidden: Content type `text/plain` is not supported."
* Workaround: send this in the body
* {
* "notrigger": 0
* }
*/
function validate($id, $notrigger=0)
{
if(! DolibarrApiAccess::$user->rights->propal->creer) {
/**
* Validate a commercial proposal
*
* @param int $id Commercial proposal ID
* @param int $notrigger Use {}
*
* @url POST {id}/validate
*
* @return array
* FIXME An error 403 is returned if the request has an empty body.
* Error message: "Forbidden: Content type `text/plain` is not supported."
* Workaround: send this in the body
* {
* "notrigger": 0
* }
*/
function validate($id, $notrigger=0)
{
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found');
}
$result = $this->propal->fetch($id);
if( ! $result ) {
throw new RestException(404, 'Commercial Proposal not found');
}
if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->propal->valid(DolibarrApiAccess::$user, $notrigger);
if ($result == 0) {
throw new RestException(500, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error);
}
$result = $this->propal->valid(DolibarrApiAccess::$user, $notrigger);
if ($result == 0) {
throw new RestException(500, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Commercial Proposal validated (Ref='.$this->propal->ref.')'
)
);
}
return array(
'success' => array(
'code' => 200,
'message' => 'Commercial Proposal validated (Ref='.$this->propal->ref.')'
)
);
}
/**
* Validate fields before create or update object
*
* @param array $data Array with data to verify
* @return array
* @throws RestException
*/
function _validate($data)
{
$propal = array();
foreach (Proposals::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, "$field field missing");
$propal[$field] = $data[$field];
/**
* Validate fields before create or update object
*
* @param array $data Array with data to verify
* @return array
* @throws RestException
*/
function _validate($data)
{
$propal = array();
foreach (Proposals::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, "$field field missing");
$propal[$field] = $data[$field];
}
return $propal;
}
}
return $propal;
}
/**
* Clean sensible object datas
*
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object) {
/**
* Clean sensible object datas
*
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
function _cleanObjectDatas($object) {
$object = parent::_cleanObjectDatas($object);
$object = parent::_cleanObjectDatas($object);
unset($object->name);
unset($object->lastname);
unset($object->firstname);
unset($object->civility_id);
unset($object->address);
unset($object->name);
unset($object->lastname);
unset($object->firstname);
unset($object->civility_id);
unset($object->address);
return $object;
}
return $object;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -72,204 +72,204 @@ if ($cancel) $action='';
if ($action == 'add')
{
$error=0;
$error=0;
$db->begin();
$db->begin();
// Create account
$object = new Account($db);
// Create account
$object = new Account($db);
$object->ref = dol_sanitizeFileName(trim($_POST["ref"]));
$object->label = trim($_POST["label"]);
$object->courant = $_POST["type"];
$object->clos = $_POST["clos"];
$object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
$object->url = $_POST["url"];
$object->ref = dol_sanitizeFileName(trim($_POST["ref"]));
$object->label = trim($_POST["label"]);
$object->courant = $_POST["type"];
$object->clos = $_POST["clos"];
$object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
$object->url = $_POST["url"];
$object->bank = trim($_POST["bank"]);
$object->code_banque = trim($_POST["code_banque"]);
$object->code_guichet = trim($_POST["code_guichet"]);
$object->number = trim($_POST["number"]);
$object->cle_rib = trim($_POST["cle_rib"]);
$object->bic = trim($_POST["bic"]);
$object->iban = trim($_POST["iban"]);
$object->domiciliation = trim($_POST["domiciliation"]);
$object->code_banque = trim($_POST["code_banque"]);
$object->code_guichet = trim($_POST["code_guichet"]);
$object->number = trim($_POST["number"]);
$object->cle_rib = trim($_POST["cle_rib"]);
$object->bic = trim($_POST["bic"]);
$object->iban = trim($_POST["iban"]);
$object->domiciliation = trim($_POST["domiciliation"]);
$object->proprio = trim($_POST["proprio"]);
$object->owner_address = trim($_POST["owner_address"]);
$object->proprio = trim($_POST["proprio"]);
$object->owner_address = trim($_POST["owner_address"]);
$account_number = GETPOST('account_number','alpha');
if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; }
$fk_accountancy_journal = GETPOST('fk_accountancy_journal','int');
if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; }
$object->solde = $_POST["solde"];
$object->date_solde = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
$object->solde = $_POST["solde"];
$object->date_solde = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
$object->currency_code = trim($_POST["account_currency_code"]);
$object->currency_code = trim($_POST["account_currency_code"]);
$object->state_id = $_POST["account_state_id"];
$object->country_id = $_POST["account_country_id"];
$object->state_id = $_POST["account_state_id"];
$object->country_id = $_POST["account_country_id"];
$object->min_allowed = GETPOST("account_min_allowed",'int');
$object->min_desired = GETPOST("account_min_desired",'int');
$object->comment = trim(GETPOST("account_comment"));
$object->min_allowed = GETPOST("account_min_allowed",'int');
$object->min_desired = GETPOST("account_min_desired",'int');
$object->comment = trim(GETPOST("account_comment"));
$object->fk_user_author = $user->id;
$object->fk_user_author = $user->id;
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
$action='create'; // Force chargement page en mode creation
$error++;
}
if (empty($object->ref))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
$action='create'; // Force chargement page en mode creation
$error++;
}
if (empty($object->label))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
$action='create'; // Force chargement page en mode creation
$error++;
}
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors');
$action='create'; // Force chargement page en mode creation
$error++;
}
if (empty($object->ref))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
$action='create'; // Force chargement page en mode creation
$error++;
}
if (empty($object->label))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
$action='create'; // Force chargement page en mode creation
$error++;
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if (! $error)
{
$id = $object->create($user);
if ($id > 0)
{
// Category association
$categories = GETPOST('categories', 'array');
$object->setCategories($categories);
if (! $error)
{
$id = $object->create($user);
if ($id > 0)
{
// Category association
$categories = GETPOST('categories', 'array');
$object->setCategories($categories);
$_GET["id"]=$id; // Force chargement page en mode visu
$_GET["id"]=$id; // Force chargement page en mode visu
$action='';
}
else {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
$action='';
}
else {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
$action='create'; // Force chargement page en mode creation
}
}
$action='create'; // Force chargement page en mode creation
}
}
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
}
if ($action == 'update')
{
$error=0;
$error=0;
// Update account
$object = new Account($db);
$object->fetch(GETPOST("id"));
// Update account
$object = new Account($db);
$object->fetch(GETPOST("id"));
$object->ref = dol_string_nospecial(trim($_POST["ref"]));
$object->label = trim($_POST["label"]);
$object->courant = $_POST["type"];
$object->clos = $_POST["clos"];
$object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
$object->url = trim($_POST["url"]);
$object->ref = dol_string_nospecial(trim($_POST["ref"]));
$object->label = trim($_POST["label"]);
$object->courant = $_POST["type"];
$object->clos = $_POST["clos"];
$object->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1;
$object->url = trim($_POST["url"]);
$object->bank = trim($_POST["bank"]);
$object->code_banque = trim($_POST["code_banque"]);
$object->code_guichet = trim($_POST["code_guichet"]);
$object->number = trim($_POST["number"]);
$object->cle_rib = trim($_POST["cle_rib"]);
$object->bic = trim($_POST["bic"]);
$object->iban = trim($_POST["iban"]);
$object->domiciliation = trim($_POST["domiciliation"]);
$object->bank = trim($_POST["bank"]);
$object->code_banque = trim($_POST["code_banque"]);
$object->code_guichet = trim($_POST["code_guichet"]);
$object->number = trim($_POST["number"]);
$object->cle_rib = trim($_POST["cle_rib"]);
$object->bic = trim($_POST["bic"]);
$object->iban = trim($_POST["iban"]);
$object->domiciliation = trim($_POST["domiciliation"]);
$object->proprio = trim($_POST["proprio"]);
$object->owner_address = trim($_POST["owner_address"]);
$object->proprio = trim($_POST["proprio"]);
$object->owner_address = trim($_POST["owner_address"]);
$account_number = GETPOST('account_number', 'int');
if ($account_number <= 0) { $object->account_number = ''; } else { $object->account_number = $account_number; }
$fk_accountancy_journal = GETPOST('fk_accountancy_journal','int');
if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; }
$object->currency_code = trim($_POST["account_currency_code"]);
$object->currency_code = trim($_POST["account_currency_code"]);
$object->state_id = $_POST["account_state_id"];
$object->country_id = $_POST["account_country_id"];
$object->state_id = $_POST["account_state_id"];
$object->country_id = $_POST["account_country_id"];
$object->min_allowed = GETPOST("account_min_allowed",'int');
$object->min_desired = GETPOST("account_min_desired",'int');
$object->comment = trim(GETPOST("account_comment"));
$object->min_allowed = GETPOST("account_min_allowed",'int');
$object->min_desired = GETPOST("account_min_desired",'int');
$object->comment = trim(GETPOST("account_comment"));
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error');
$action='edit'; // Force chargement page en mode creation
$error++;
}
if (empty($object->ref))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
$action='edit'; // Force chargement page en mode creation
$error++;
}
if (empty($object->label))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
$action='edit'; // Force chargement page en mode creation
$error++;
}
if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error');
$action='edit'; // Force chargement page en mode creation
$error++;
}
if (empty($object->ref))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
$action='edit'; // Force chargement page en mode creation
$error++;
}
if (empty($object->label))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors');
$action='edit'; // Force chargement page en mode creation
$error++;
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
if (! $error)
{
$result = $object->update($user);
if ($result >= 0)
{
// Category association
$categories = GETPOST('categories', 'array');
$object->setCategories($categories);
if (! $error)
{
$result = $object->update($user);
if ($result >= 0)
{
// Category association
$categories = GETPOST('categories', 'array');
$object->setCategories($categories);
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$action='edit'; // Force chargement page edition
}
}
$_GET["id"]=$_POST["id"]; // Force chargement page en mode visu
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$action='edit'; // Force chargement page edition
}
}
}
if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer)
{
// Delete
$object = new Account($db);
$object->fetch(GETPOST("id","int"));
$result = $object->delete($user);
// Delete
$object = new Account($db);
$object->fetch(GETPOST("id","int"));
$result = $object->delete($user);
if ($result > 0)
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
header("Location: ".DOL_URL_ROOT."/compta/bank/list.php");
exit;
}
else
{
setEventMessages($account->error, $account->errors, 'errors');
$action='';
}
if ($result > 0)
{
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
header("Location: ".DOL_URL_ROOT."/compta/bank/list.php");
exit;
}
else
{
setEventMessages($account->error, $account->errors, 'errors');
$action='';
}
}
@ -297,10 +297,10 @@ if ($action == 'create')
print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'title_bank.png');
if ($conf->use_javascript_ajax)
{
if ($conf->use_javascript_ajax)
{
print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () {
print 'jQuery(document).ready(function () {
jQuery("#selecttype").change(function() {
document.formsoc.action.value="create";
document.formsoc.submit();
@ -310,8 +310,8 @@ if ($action == 'create')
document.formsoc.submit();
});
})';
print '</script>'."\n";
}
print '</script>'."\n";
}
print '<form action="'.$_SERVER["PHP_SELF"].'" name="formsoc" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -347,12 +347,12 @@ if ($action == 'create')
print '</td></tr>';
// Status
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
print '<td>';
print $form->selectarray("clos", $object->status,(GETPOST("clos",'int')!=''?GETPOST("clos",'int'):$object->clos));
print '</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
print '<td>';
print $form->selectarray("clos", $object->status,(GETPOST("clos",'int')!=''?GETPOST("clos",'int'):$object->clos));
print '</td></tr>';
// Country
// Country
$selectedcode='';
if (isset($_POST["account_country_id"]))
{
@ -383,24 +383,24 @@ if ($action == 'create')
print '<tr><td>'.$langs->trans("Web").'</td>';
print '<td><input class="minwidth300" type="text" class="flat" name="url" value="'.GETPOST("url").'"></td></tr>';
// Tags-Categories
if ($conf->categorie->enabled)
{
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
$c = new Categorie($db);
$cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
foreach($cats as $cat) {
$arrayselected[] = $cat->id;
}
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
print "</td></tr>";
}
// Tags-Categories
if ($conf->categorie->enabled)
{
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
$c = new Categorie($db);
$cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
foreach($cats as $cat) {
$arrayselected[] = $cat->id;
}
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
print "</td></tr>";
}
// Comment
print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>';
print '<td>';
// Editor wysiwyg
// Editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$object->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,'90%');
$doleditor->Create();
@ -409,7 +409,7 @@ if ($action == 'create')
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields,'edit',$parameters);
@ -504,7 +504,7 @@ if ($action == 'create')
print '<table class="border" width="100%">';
// Accountancy code
$fieldrequired='';
if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired ';
if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired ';
if (! empty($conf->accounting->enabled))
{
@ -523,7 +523,7 @@ if ($action == 'create')
if (! empty($conf->accounting->enabled))
{
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<td>';
print '<td>';
print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
print '</td></tr>';
}
@ -547,7 +547,7 @@ if ($action == 'create')
/* ************************************************************************** */
else
{
if (($_GET["id"] || $_GET["ref"]) && $action != 'edit')
if (($_GET["id"] || $_GET["ref"]) && $action != 'edit')
{
$object = new Account($db);
if ($_GET["id"])
@ -605,7 +605,7 @@ else
print '<td>';
$conciliate=$object->canBeConciliated();
if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
else print ($object->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')'));
print '</td></tr>';
@ -624,15 +624,15 @@ else
print $accountingaccount->getNomUrl(0,1,1,'',1);
} else {
print $object->account_number;
print $object->account_number;
}
print '</td></tr>';
// Accountancy journal
if (! empty($conf->accounting->enabled))
{
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<td>';
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<td>';
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($object->fk_accountancy_journal);
@ -655,12 +655,12 @@ else
print '<table class="border centpercent">';
// Categories
if ($conf->categorie->enabled) {
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($object->id,'bank_account',1);
print "</td></tr>";
}
// Categories
if ($conf->categorie->enabled) {
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($object->id,'bank_account',1);
print "</td></tr>";
}
print '<tr><td class="tdtop titlefield">'.$langs->trans("Comment").'</td>';
print '<td>'.dol_htmlentitiesbr($object->comment).'</td></tr>';
@ -669,11 +669,11 @@ else
if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT)
{
print '<br>';
print '<br>';
print '<div class="underbanner clearboth"></div>';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '<table class="border centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("BankName").'</td>';
print '<td>'.$object->bank.'</td></tr>';
@ -764,23 +764,23 @@ else
}
/* ************************************************************************** */
/* */
/* Edition */
/* */
/* ************************************************************************** */
/* ************************************************************************** */
/* */
/* Edition */
/* */
/* ************************************************************************** */
if (GETPOST('id','int') && $action == 'edit' && $user->rights->banque->configurer)
{
$object = new Account($db);
$object->fetch(GETPOST('id','int'));
if (GETPOST('id','int') && $action == 'edit' && $user->rights->banque->configurer)
{
$object = new Account($db);
$object->fetch(GETPOST('id','int'));
print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'title_bank.png');
print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'title_bank.png');
if ($conf->use_javascript_ajax)
{
print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () {
if ($conf->use_javascript_ajax)
{
print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () {
jQuery("#selecttype").change(function() {
document.formsoc.action.value="edit";
document.formsoc.submit();
@ -793,33 +793,33 @@ else
document.formsoc.submit();
});
})';
print '</script>'."\n";
}
print '</script>'."\n";
}
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formsoc">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$_REQUEST["id"].'">'."\n\n";
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post" name="formsoc">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$_REQUEST["id"].'">'."\n\n";
dol_fiche_head('');
dol_fiche_head('');
print '<div class="underbanner clearboth"></div>';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<table class="border" width="100%">';
// Ref
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
print '<td><input size="8" type="text" class="flat" name="ref" value="'.(isset($_POST["ref"])?GETPOST("ref"):$object->ref).'"></td></tr>';
// Label
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
print '<td><input type="text" class="flat minwidth300" name="label" value="'.(isset($_POST["label"])?GETPOST("label"):$object->label).'"></td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
print '<td><input type="text" class="flat minwidth300" name="label" value="'.(isset($_POST["label"])?GETPOST("label"):$object->label).'"></td></tr>';
// Type
print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
print '<td class="maxwidth200onsmartphone">';
// Type
print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
print '<td class="maxwidth200onsmartphone">';
$formbank->selectTypeOfBankAccount((isset($_POST["type"])?$_POST["type"]:$object->type),"type");
print '</td></tr>';
print '</td></tr>';
// Currency
print '<tr><td class="fieldrequired">'.$langs->trans("Currency");
@ -834,10 +834,10 @@ else
print '</td></tr>';
// Status
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
print '<td class="maxwidth200onsmartphone">';
print $form->selectarray("clos", $object->status, (isset($_POST["clos"])?$_POST["clos"]:$object->clos));
print '</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
print '<td class="maxwidth200onsmartphone">';
print $form->selectarray("clos", $object->status, (isset($_POST["clos"])?$_POST["clos"]:$object->clos));
print '</td></tr>';
// Country
$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id;
@ -865,15 +865,15 @@ else
print '</td></tr>';
// Conciliable
print '<tr><td>'.$langs->trans("Conciliable").'</td>';
print '<td>';
$conciliate=$object->canBeConciliated();
if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
else print '<input type="checkbox" class="flat" name="norappro"'.(($conciliate > 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation");
print '</td></tr>';
print '<tr><td>'.$langs->trans("Conciliable").'</td>';
print '<td>';
$conciliate=$object->canBeConciliated();
if ($conciliate == -2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
else if ($conciliate == -3) print $langs->trans("No").' ('.$langs->trans("Closed").')';
else print '<input type="checkbox" class="flat" name="norappro"'.(($conciliate > 0)?'':' checked="checked"').'"> '.$langs->trans("DisableConciliation");
print '</td></tr>';
// Balance
// Balance
print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(isset($_POST["account_min_allowed"])?GETPOST("account_min_allowed"):$object->min_allowed).'"></td></tr>';
@ -881,28 +881,28 @@ else
print '<td ><input size="12" type="text" class="flat" name="account_min_desired" value="'.(isset($_POST["account_min_desired"])?GETPOST("account_min_desired"):$object->min_desired).'"></td></tr>';
// Web
print '<tr><td>'.$langs->trans("Web").'</td>';
print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(isset($_POST["url"])?GETPOST("url"):$object->url).'">';
print '</td></tr>';
print '<tr><td>'.$langs->trans("Web").'</td>';
print '<td><input class="maxwidth200onsmartphone" type="text" class="flat" name="url" value="'.(isset($_POST["url"])?GETPOST("url"):$object->url).'">';
print '</td></tr>';
// Tags-Categories
if ($conf->categorie->enabled)
{
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
$c = new Categorie($db);
$cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
foreach($cats as $cat) {
$arrayselected[] = $cat->id;
}
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
print "</td></tr>";
}
// Tags-Categories
if ($conf->categorie->enabled)
{
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
$c = new Categorie($db);
$cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT);
foreach($cats as $cat) {
$arrayselected[] = $cat->id;
}
print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%');
print "</td></tr>";
}
// Comment
print '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>';
print '<td>';
// Editor wysiwyg
// Editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$object->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,'95%');
$doleditor->Create();
@ -911,7 +911,7 @@ else
// Other attributes
$parameters=array();
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print $hookmanager->resPrint;
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields,'edit');
@ -929,15 +929,15 @@ else
$tdextra = ' class="titlefieldcreate"';
if (!empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) {
$tdextra = ' class="fieldrequired titlefieldcreate"';
$tdextra = ' class="fieldrequired titlefieldcreate"';
}
print '<tr class="liste_titre_add"><td'.$tdextra.'>'.$langs->trans("AccountancyCode").'</td>';
print '<td>';
if (!empty($conf->accounting->enabled)) {
print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
} else {
print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
print '<input type="text" name="account_number" value="'.(GETPOST("account_number") ? GETPOST("account_number") : $object->account_number).'">';
}
print '</td></tr>';
@ -954,9 +954,9 @@ else
if ($_POST["type"] == Account::TYPE_SAVINGS || $_POST["type"] == Account::TYPE_CURRENT)
{
print '<br>';
print '<br>';
//print '<div class="underbanner clearboth"></div>';
//print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';

View File

@ -63,50 +63,50 @@ if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm
}
if ($action == 'reopen' && $user->rights->tax->charges->creer) {
$result = $object->fetch($id);
if ($object->paye)
{
$result = $object->set_unpaid($user);
if ($result > 0)
{
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
exit();
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
$result = $object->fetch($id);
if ($object->paye)
{
$result = $object->set_unpaid($user);
if ($result > 0)
{
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
exit();
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
// Link to a project
if ($action == 'classin' && $user->rights->tax->charges->creer)
{
$object->fetch($id);
$object->setProject(GETPOST('projectid'));
$object->fetch($id);
$object->setProject(GETPOST('projectid'));
}
if ($action == 'setlib' && $user->rights->tax->charges->creer)
{
$object->fetch($id);
$result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY');
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
$object->fetch($id);
$result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY');
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
// payment mode
if ($action == 'setmode' && $user->rights->tax->charges->creer) {
$object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
$object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
// bank account
if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) {
$object->fetch($id);
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
$object->fetch($id);
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
// Delete social contribution
@ -131,8 +131,8 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
{
$dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
$dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
$amount=price2num(GETPOST('amount'));
$actioncode=GETPOST('actioncode');
$amount=price2num(GETPOST('amount'));
$actioncode=GETPOST('actioncode');
if (! $dateech)
{
@ -166,8 +166,8 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
$object->date_ech = $dateech;
$object->periode = $dateperiod;
$object->amount = $amount;
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->fk_account = GETPOST('fk_account', 'int');
$object->fk_project = GETPOST('fk_project');
$id=$object->create($user);
@ -182,43 +182,43 @@ if ($action == 'add' && $user->rights->tax->charges->creer)
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->creer)
{
$dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
$dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
$amount=price2num(GETPOST('amount'));
$dateech=dol_mktime(GETPOST('echhour'),GETPOST('echmin'),GETPOST('echsec'),GETPOST('echmonth'),GETPOST('echday'),GETPOST('echyear'));
$dateperiod=dol_mktime(GETPOST('periodhour'),GETPOST('periodmin'),GETPOST('periodsec'),GETPOST('periodmonth'),GETPOST('periodday'),GETPOST('periodyear'));
$amount=price2num(GETPOST('amount'));
if (! $dateech)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors');
$action = 'edit';
}
elseif (! $dateperiod)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
$action = 'edit';
}
elseif (empty($amount))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
$action = 'edit';
}
if (! $dateech)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateDue")), null, 'errors');
$action = 'edit';
}
elseif (! $dateperiod)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
$action = 'edit';
}
elseif (empty($amount))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
$action = 'edit';
}
elseif (! is_numeric($amount))
{
setEventMessages($langs->trans("ErrorFieldMustBeANumeric",$langs->transnoentities("Amount")), null, 'errors');
$action = 'create';
}
else
else
{
$result=$object->fetch($id);
$result=$object->fetch($id);
$object->date_ech = $dateech;
$object->periode = $dateperiod;
$object->amount = price2num($amount);
$object->date_ech = $dateech;
$object->periode = $dateperiod;
$object->amount = price2num($amount);
$result=$object->update($user);
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
}
$result=$object->update($user);
if ($result <= 0)
{
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@ -293,51 +293,51 @@ if ($action == 'create')
{
print load_fiche_titre($langs->trans("NewSocialContribution"));
$var=false;
$var=false;
print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
dol_fiche_head();
dol_fiche_head();
print '<table class="border" width="100%">';
// Label
print "<tr>";
print '<td class="titlefieldcreate fieldrequired">';
print $langs->trans("Label");
print '</td>';
print '<td><input type="text" size="34" name="label" class="flat" value="'.dol_escape_htmltag(GETPOST('label','alpha')).'" autofocus></td>';
print '</tr>';
print '<tr>';
// Label
print "<tr>";
print '<td class="titlefieldcreate fieldrequired">';
print $langs->trans("Label");
print '</td>';
print '<td><input type="text" size="34" name="label" class="flat" value="'.dol_escape_htmltag(GETPOST('label','alpha')).'" autofocus></td>';
print '</tr>';
print '<tr>';
// Type
print '<td class="fieldrequired">';
print $langs->trans("Type");
print '</td>';
print '<td>';
$formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode",'alpha')?GETPOST("actioncode",'alpha'):'','actioncode',1);
print '</td>';
print '</tr>';
// Type
print '<td class="fieldrequired">';
print $langs->trans("Type");
print '</td>';
print '<td>';
$formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode",'alpha')?GETPOST("actioncode",'alpha'):'','actioncode',1);
print '</td>';
print '</tr>';
// Date end period
print '<tr>';
print '<td class="fieldrequired">';
print $langs->trans("PeriodEndDate");
print '</td>';
print '<td>';
print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
print '<tr>';
print '<td class="fieldrequired">';
print $langs->trans("PeriodEndDate");
print '</td>';
print '</tr>';
print '<td>';
print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
print '</td>';
print '</tr>';
// Amount
print '<tr>';
print '<td class="fieldrequired">';
print $langs->trans("Amount");
print '</td>';
// Amount
print '<tr>';
print '<td class="fieldrequired">';
print $langs->trans("Amount");
print '</td>';
print '<td><input type="text" size="6" name="amount" class="flat" value="'.dol_escape_htmltag(GETPOST('amount','alpha')).'"></td>';
print '</tr>';
print '</tr>';
// Project
if (! empty($conf->projet->enabled))
@ -354,30 +354,30 @@ if ($action == 'create')
print '</td></tr>';
}
// Payment Mode
print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
print '</td></tr>';
// Payment Mode
print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
print '</td></tr>';
// Bank Account
if (! empty($conf->banque->enabled))
{
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
}
// Bank Account
if (! empty($conf->banque->enabled))
{
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
}
// Date due
print '<tr>';
print '<td class="fieldrequired">';
print $langs->trans("DateDue");
print '</td>';
print '<td>';
print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
// Date due
print '<tr>';
print '<td class="fieldrequired">';
print $langs->trans("DateDue");
print '</td>';
print "</tr>\n";
print '<td>';
print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
print '</td>';
print "</tr>\n";
print '</table>';
print '</table>';
dol_fiche_end();
@ -387,7 +387,7 @@ if ($action == 'create')
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
print '</div>';
print '</form>';
print '</form>';
}
/* *************************************************************************** */
@ -398,7 +398,7 @@ if ($action == 'create')
if ($id > 0)
{
$object = new ChargeSociales($db);
$result=$object->fetch($id);
$result=$object->fetch($id);
if ($result > 0)
{
@ -414,7 +414,7 @@ if ($id > 0)
);
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneTax'),$langs->trans('ConfirmCloneTax',$object->ref),'confirm_clone',$formclone,'yes');
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneTax'),$langs->trans('ConfirmCloneTax',$object->ref),'confirm_clone',$formclone,'yes');
}
// Confirmation de la suppression de la charge
@ -445,34 +445,34 @@ if ($id > 0)
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->tax->charges->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
$langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->tax->charges->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
@ -492,7 +492,7 @@ if ($id > 0)
print '<tr><td class="titlefield">'.$langs->trans("Type")."</td><td>".$object->type_libelle."</td>";
print "</tr>";
// Period end date
// Period end date
print "<tr><td>".$langs->trans("PeriodEndDate")."</td>";
print "<td>";
if ($action == 'edit')
@ -517,51 +517,51 @@ if ($id > 0)
}
// Amount
if ($action == 'edit')
{
print '<tr><td>'.$langs->trans("AmountTTC")."</td><td>";
print '<input type="text" name="amount" size="12" class="flat" value="'.$object->amount.'">';
print "</td></tr>";
}
else {
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
}
if ($action == 'edit')
{
print '<tr><td>'.$langs->trans("AmountTTC")."</td><td>";
print '<input type="text" name="amount" size="12" class="flat" value="'.$object->amount.'">';
print "</td></tr>";
}
else {
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
}
// Mode of payment
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($action != 'editmode')
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editmode') {
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
} else {
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none');
}
print '</td></tr>';
// Mode of payment
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($action != 'editmode')
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editmode') {
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id');
} else {
$form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none');
}
print '</td></tr>';
// Bank Account
if (! empty($conf->banque->enabled))
{
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('BankAccount');
print '<td>';
if ($action != 'editbankaccount' && $user->rights->tax->charges->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
}
// Bank Account
if (! empty($conf->banque->enabled))
{
print '<tr><td class="nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('BankAccount');
print '<td>';
if ($action != 'editbankaccount' && $user->rights->tax->charges->creer)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>';
print '</td><td>';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
}
print '</td>';
print '</tr>';
}
print '</table>';
@ -588,59 +588,59 @@ if ($id > 0)
$resql = $db->query($sql);
if ($resql)
{
$totalpaye = 0;
$totalpaye = 0;
$num = $db->num_rows($resql);
$i = 0; $total = 0;
print '<table class="noborder paymenttable">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("RefPayment").'</td>';
print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Amount").'</td>';
print '</tr>';
$num = $db->num_rows($resql);
$i = 0; $total = 0;
print '<table class="noborder paymenttable">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("RefPayment").'</td>';
print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Type").'</td>';
print '<td align="right">'.$langs->trans("Amount").'</td>';
print '</tr>';
$var=true;
if ($num > 0)
{
while ($i < $num)
{
$objp = $db->fetch_object($resql);
$var=true;
if ($num > 0)
{
while ($i < $num)
{
$objp = $db->fetch_object($resql);
print "<tr ".$bc[$var]."><td>";
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
print '<td align="right">'.price($objp->amount)."</td>\n";
print "</tr>";
$totalpaye += $objp->amount;
$i++;
}
}
else
{
print "<tr ".$bc[$var]."><td>";
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
$labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type;
print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
print '<td align="right">'.price($objp->amount)."</td>\n";
print "</tr>";
$totalpaye += $objp->amount;
$i++;
}
}
else
{
print '<tr class="oddeven"><td colspan="'.$nbcols.'" class="opacitymedium">'.$langs->trans("None").'</td><td></td><td></td><td></td></tr>';
}
print '<tr class="oddeven"><td colspan="'.$nbcols.'" class="opacitymedium">'.$langs->trans("None").'</td><td></td><td></td><td></td></tr>';
}
//if ($object->status == ChargeSociales::STATUS_DRAFT)
//{
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaye)."</td></tr>\n";
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->amount)."</td></tr>\n";
//if ($object->status == ChargeSociales::STATUS_DRAFT)
//{
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\">".price($totalpaye)."</td></tr>\n";
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\">".price($object->amount)."</td></tr>\n";
$resteapayer = $object->amount - $totalpaye;
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
$resteapayer = $object->amount - $totalpaye;
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
print '<td align="right"'.($resteapayer?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>'.price($resteapayer)."</td></tr>\n";
//}
print "</table>";
$db->free($resql);
print "<tr><td colspan=\"3\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
print '<td align="right"'.($resteapayer?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>'.price($resteapayer)."</td></tr>\n";
//}
print "</table>";
$db->free($resql);
}
else
{
dol_print_error($db);
dol_print_error($db);
}
print '</div>';

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -92,8 +92,8 @@ class Ldap
/**
* The internal LDAP connection handle
*/
* The internal LDAP connection handle
*/
var $connection;
/**
* Result of any connections etc.
@ -749,7 +749,7 @@ class Ldap
// Attribute methods -----------------------------------------------------
/**
/**
* Add a LDAP attribute in entry
* Ldap object connect and bind must have been done
*
@ -801,7 +801,7 @@ class Ldap
}
}
/**
/**
* Update a LDAP attribute in entry
* Ldap object connect and bind must have been done
*
@ -853,7 +853,7 @@ class Ldap
}
}
/**
/**
* Delete a LDAP attribute in entry
* Ldap object connect and bind must have been done
*
@ -905,7 +905,7 @@ class Ldap
}
}
/**
/**
* Returns an array containing attributes and values for first record
*
* @param string $dn DN entry key
@ -1262,7 +1262,7 @@ class Ldap
$i=0;
while ($i <= 2)
{
dol_syslog(get_class($this)."::fetch search with searchDN=".$searchDN." filter=".$filter);
dol_syslog(get_class($this)."::fetch search with searchDN=".$searchDN." filter=".$filter);
$this->result = @ldap_search($this->connection, $searchDN, $filter);
if ($this->result)
{
@ -1273,9 +1273,9 @@ class Ldap
}
else
{
$this->error = ldap_errno($this->connection)." ".ldap_error($this->connection);
dol_syslog(get_class($this)."::fetch search fails");
return -1;
$this->error = ldap_errno($this->connection)." ".ldap_error($this->connection);
dol_syslog(get_class($this)."::fetch search fails");
return -1;
}
if (! $result)
@ -1324,7 +1324,7 @@ class Ldap
$this->domainFQDN = $domain;
// Set ldapUserDn (each user can have a different dn)
//var_dump($result[0]);exit;
//var_dump($result[0]);exit;
$this->ldapUserDN=$result[0]['dn'];
ldap_free_result($this->result);
@ -1350,11 +1350,11 @@ class Ldap
}
/**
* UserAccountControl Flgs to more human understandable form...
*
* @param string $uacf UACF
* @return void
*/
* UserAccountControl Flgs to more human understandable form...
*
* @param string $uacf UACF
* @return void
*/
function parseUACF($uacf)
{
//All flags array
@ -1396,11 +1396,11 @@ class Ldap
}
/**
* SamAccountType value to text
*
* @param string $samtype SamType
* @return string Sam string
*/
* SamAccountType value to text
*
* @param string $samtype SamType
* @return string Sam string
*/
function parseSAT($samtype)
{
$stypes = array(
@ -1443,7 +1443,7 @@ class Ldap
/**
* Convert a string into output/memory charset
*
*
* @param string $str String to convert
* @param string $pagecodefrom Page code of src string
* @return string Converted string
@ -1458,7 +1458,7 @@ class Ldap
/**
* Convert a string from output/memory charset
*
*
* @param string $str String to convert
* @param string $pagecodeto Page code for result string
* @return string Converted string

View File

@ -30,56 +30,56 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/CMailFile.class.php';
*/
class Notify
{
var $id;
var $db;
var $error;
var $errors=array();
var $id;
var $db;
var $error;
var $errors=array();
var $author;
var $ref;
var $date;
var $duree;
var $note;
var $fk_project;
var $author;
var $ref;
var $date;
var $duree;
var $note;
var $fk_project;
// Les codes actions sont definis dans la table llx_notify_def
// codes actions supported are
public $arrayofnotifsupported = array(
'BILL_VALIDATE',
'BILL_PAYED',
'ORDER_VALIDATE',
'PROPAL_VALIDATE',
'PROPAL_CLOSE_SIGNED',
'FICHINTER_VALIDATE',
'FICHINTER_ADD_CONTACT',
'ORDER_SUPPLIER_VALIDATE',
'ORDER_SUPPLIER_APPROVE',
'ORDER_SUPPLIER_REFUSE',
'SHIPPING_VALIDATE'
);
// codes actions supported are
public $arrayofnotifsupported = array(
'BILL_VALIDATE',
'BILL_PAYED',
'ORDER_VALIDATE',
'PROPAL_VALIDATE',
'PROPAL_CLOSE_SIGNED',
'FICHINTER_VALIDATE',
'FICHINTER_ADD_CONTACT',
'ORDER_SUPPLIER_VALIDATE',
'ORDER_SUPPLIER_APPROVE',
'ORDER_SUPPLIER_REFUSE',
'SHIPPING_VALIDATE'
);
/**
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
}
*/
function __construct($db)
{
$this->db = $db;
}
/**
* Return message that say how many notification (and to which email) will occurs on requested event.
* This is to show confirmation messages before event is recorded.
*
* @param string $action Id of action in llx_c_action_trigger
* @param int $socid Id of third party
* @param Object $object Object the notification is about
* @return string Message
*/
/**
* Return message that say how many notification (and to which email) will occurs on requested event.
* This is to show confirmation messages before event is recorded.
*
* @param string $action Id of action in llx_c_action_trigger
* @param int $socid Id of third party
* @param Object $object Object the notification is about
* @return string Message
*/
function confirmMessage($action,$socid,$object)
{
global $langs;
@ -96,175 +96,175 @@ class Notify
if (is_array($listofnotiftodo))
{
$i=0;
foreach ($listofnotiftodo as $key => $val)
{
if ($i) $texte.=', ';
else $texte.=' (';
if ($val['isemailvalid']) $texte.=$val['email'];
else $texte.=$val['emaildesc'];
$i++;
}
if ($i) $texte.=')';
$i=0;
foreach ($listofnotiftodo as $key => $val)
{
if ($i) $texte.=', ';
else $texte.=' (';
if ($val['isemailvalid']) $texte.=$val['email'];
else $texte.=$val['emaildesc'];
$i++;
}
if ($i) $texte.=')';
}
return $texte;
}
/**
* Return number of notifications activated for action code (and third party)
*
* @param string $notifcode Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* @param int $socid Id of third party or 0 for all thirdparties or -1 for no thirdparties
* @param Object $object Object the notification is about (need it to check threshold value of some notifications)
* @param int $userid Id of user or 0 for all users or -1 for no users
* @param array $scope Scope where to search
* @return array|int <0 if KO, array of notifications to send if OK
*/
/**
* Return number of notifications activated for action code (and third party)
*
* @param string $notifcode Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* @param int $socid Id of third party or 0 for all thirdparties or -1 for no thirdparties
* @param Object $object Object the notification is about (need it to check threshold value of some notifications)
* @param int $userid Id of user or 0 for all users or -1 for no users
* @param array $scope Scope where to search
* @return array|int <0 if KO, array of notifications to send if OK
*/
function getNotificationsArray($notifcode, $socid=0, $object=null, $userid=0, $scope=array('thirdparty', 'user', 'global'))
{
global $conf, $user;
$error=0;
$resarray=array();
$resarray=array();
$valueforthreshold = 0;
if (is_object($object)) $valueforthreshold = $object->total_ht;
if (! $error)
{
if ($socid >= 0 && in_array('thirdparty', $scope))
{
$sql = "SELECT a.code, c.email, c.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql.= " ".MAIN_DB_PREFIX."socpeople as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE n.fk_contact = c.rowid";
$sql.= " AND a.rowid = n.fk_action";
$sql.= " AND n.fk_soc = s.rowid";
if ($notifcode)
{
if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage
else $sql.= " AND a.code = '".$notifcode."'"; // New usage
}
$sql.= " AND s.entity IN (".getEntity('societe').")";
if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($obj)
{
$newval2=trim($obj->email);
$isvalid=isValidEmail($newval2);
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
}
$i++;
}
}
else
{
$error++;
$this->error=$this->db->lasterror();
}
}
}
if (! $error)
{
if ($userid >= 0 && in_array('user', $scope))
{
$sql = "SELECT a.code, c.email, c.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql.= " ".MAIN_DB_PREFIX."user as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a";
$sql.= " WHERE n.fk_user = c.rowid";
$sql.= " AND a.rowid = n.fk_action";
if ($notifcode)
{
if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage
else $sql.= " AND a.code = '".$notifcode."'"; // New usage
}
$sql.= " AND c.entity IN (".getEntity('user').")";
if ($userid > 0) $sql.= " AND c.rowid = ".$userid;
dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($obj)
{
$newval2=trim($obj->email);
$isvalid=isValidEmail($newval2);
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
}
$i++;
}
}
else
{
$error++;
$this->error=$this->db->lasterror();
}
}
}
$valueforthreshold = 0;
if (is_object($object)) $valueforthreshold = $object->total_ht;
if (! $error)
{
if (in_array('global', $scope))
{
// List of notifications enabled for fixed email
foreach($conf->global as $key => $val)
{
if ($notifcode)
{
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
}
else
{
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
}
if ($socid >= 0 && in_array('thirdparty', $scope))
{
$sql = "SELECT a.code, c.email, c.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql.= " ".MAIN_DB_PREFIX."socpeople as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE n.fk_contact = c.rowid";
$sql.= " AND a.rowid = n.fk_action";
$sql.= " AND n.fk_soc = s.rowid";
if ($notifcode)
{
if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage
else $sql.= " AND a.code = '".$notifcode."'"; // New usage
}
$sql.= " AND s.entity IN (".getEntity('societe').")";
if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
$threshold = (float) $reg[1];
if ($valueforthreshold < $threshold) continue;
dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
$tmpemail=explode(',',$val);
foreach($tmpemail as $key2 => $val2)
{
$newval2=trim($val2);
if ($newval2 == '__SUPERVISOREMAIL__')
{
if ($user->fk_user > 0)
{
$tmpuser=new User($this->db);
$tmpuser->fetch($user->fk_user);
if ($tmpuser->email) $newval2=trim($tmpuser->email);
else $newval2='';
}
else $newval2='';
}
if ($newval2)
{
$isvalid=isValidEmail($newval2, 0);
if (empty($resarray[$newval2])) $resarray[$newval2]=array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
}
}
}
}
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($obj)
{
$newval2=trim($obj->email);
$isvalid=isValidEmail($newval2);
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
}
$i++;
}
}
else
{
$error++;
$this->error=$this->db->lasterror();
}
}
}
if (! $error)
{
if ($userid >= 0 && in_array('user', $scope))
{
$sql = "SELECT a.code, c.email, c.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
$sql.= " ".MAIN_DB_PREFIX."user as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a";
$sql.= " WHERE n.fk_user = c.rowid";
$sql.= " AND a.rowid = n.fk_action";
if ($notifcode)
{
if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage
else $sql.= " AND a.code = '".$notifcode."'"; // New usage
}
$sql.= " AND c.entity IN (".getEntity('user').")";
if ($userid > 0) $sql.= " AND c.rowid = ".$userid;
dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if ($obj)
{
$newval2=trim($obj->email);
$isvalid=isValidEmail($newval2);
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
}
$i++;
}
}
else
{
$error++;
$this->error=$this->db->lasterror();
}
}
}
if (! $error)
{
if (in_array('global', $scope))
{
// List of notifications enabled for fixed email
foreach($conf->global as $key => $val)
{
if ($notifcode)
{
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
}
else
{
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
}
$threshold = (float) $reg[1];
if ($valueforthreshold < $threshold) continue;
$tmpemail=explode(',',$val);
foreach($tmpemail as $key2 => $val2)
{
$newval2=trim($val2);
if ($newval2 == '__SUPERVISOREMAIL__')
{
if ($user->fk_user > 0)
{
$tmpuser=new User($this->db);
$tmpuser->fetch($user->fk_user);
if ($tmpuser->email) $newval2=trim($tmpuser->email);
else $newval2='';
}
else $newval2='';
}
if ($newval2)
{
$isvalid=isValidEmail($newval2, 0);
if (empty($resarray[$newval2])) $resarray[$newval2]=array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
}
}
}
}
}
if ($error) return -1;
@ -273,47 +273,47 @@ class Notify
return $resarray;
}
/**
* Check if notification are active for couple action/company.
* If yes, send mail and save trace into llx_notify.
*
* @param string $notifcode Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* @param Object $object Object the notification deals on
* @return int <0 if KO, or number of changes if OK
*/
function send($notifcode, $object)
{
global $user,$conf,$langs,$mysoc;
global $hookmanager;
global $dolibarr_main_url_root;
/**
* Check if notification are active for couple action/company.
* If yes, send mail and save trace into llx_notify.
*
* @param string $notifcode Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* @param Object $object Object the notification deals on
* @return int <0 if KO, or number of changes if OK
*/
function send($notifcode, $object)
{
global $user,$conf,$langs,$mysoc;
global $hookmanager;
global $dolibarr_main_url_root;
if (! in_array($notifcode, $this->arrayofnotifsupported)) return 0;
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('notification'));
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('notification'));
dol_syslog(get_class($this)."::send notifcode=".$notifcode.", object=".$object->id);
dol_syslog(get_class($this)."::send notifcode=".$notifcode.", object=".$object->id);
$langs->load("other");
$langs->load("other");
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$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
// Define some vars
$application = 'Dolibarr';
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE;
$replyto = $conf->notification->email_from;
$filename = basename($file);
$mimefile = dol_mimetype($file);
$application = 'Dolibarr';
if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE;
$replyto = $conf->notification->email_from;
$filename = basename($file);
$mimefile = dol_mimetype($file);
$object_type = '';
$link = '';
$link = '';
$num = 0;
$oldref=(empty($object->oldref)?$object->ref:$object->oldref);
@ -322,56 +322,56 @@ class Notify
// Check notification per third party
$sql = "SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,";
$sql.= " a.rowid as adid, a.label, a.code, n.rowid, n.type";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql.= " ".MAIN_DB_PREFIX."notify_def as n,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
$sql.= " AND n.fk_soc = s.rowid";
if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage
else $sql.= " AND a.code = '".$notifcode."'"; // New usage
$sql .= " AND s.rowid = ".$object->socid;
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql.= " ".MAIN_DB_PREFIX."notify_def as n,";
$sql.= " ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
$sql.= " AND n.fk_soc = s.rowid";
if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage
else $sql.= " AND a.code = '".$notifcode."'"; // New usage
$sql .= " AND s.rowid = ".$object->socid;
// Check notification per user
$sql.= "\nUNION\n";
$sql.= "\nUNION\n";
$sql.= "SELECT 'touserid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.lang as default_lang,";
$sql.= " a.rowid as adid, a.label, a.code, n.rowid, n.type";
$sql.= " FROM ".MAIN_DB_PREFIX."user as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql.= " ".MAIN_DB_PREFIX."notify_def as n";
$sql.= " WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action";
if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage
else $sql.= " AND a.code = '".$notifcode."'"; // New usage
$sql.= "SELECT 'touserid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.lang as default_lang,";
$sql.= " a.rowid as adid, a.label, a.code, n.rowid, n.type";
$sql.= " FROM ".MAIN_DB_PREFIX."user as c,";
$sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,";
$sql.= " ".MAIN_DB_PREFIX."notify_def as n";
$sql.= " WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action";
if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage
else $sql.= " AND a.code = '".$notifcode."'"; // New usage
$result = $this->db->query($sql);
if ($result)
{
$num = $this->db->num_rows($result);
$result = $this->db->query($sql);
if ($result)
{
$num = $this->db->num_rows($result);
if ($num > 0)
{
$i = 0;
while ($i < $num && ! $error) // For each notification couple defined (third party/actioncode)
{
$obj = $this->db->fetch_object($result);
if ($num > 0)
{
$i = 0;
while ($i < $num && ! $error) // For each notification couple defined (third party/actioncode)
{
$obj = $this->db->fetch_object($result);
$sendto = dolGetFirstLastname($obj->firstname,$obj->lastname) . " <".$obj->email.">";
$sendto = dolGetFirstLastname($obj->firstname,$obj->lastname) . " <".$obj->email.">";
$notifcodedefid = $obj->adid;
if (dol_strlen($obj->email))
{
// Set output language
$outputlangs = $langs;
if ($obj->default_lang && $obj->default_lang != $langs->defaultlang)
{
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($obj->default_lang);
}
if (dol_strlen($obj->email))
{
// Set output language
$outputlangs = $langs;
if ($obj->default_lang && $obj->default_lang != $langs->defaultlang)
{
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($obj->default_lang);
}
$subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification");
$subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification");
switch ($notifcode) {
switch ($notifcode) {
case 'BILL_VALIDATE':
$link='/compta/facture/card.php?facid='.$object->id;
$dir_output = $conf->facture->dir_output;
@ -396,12 +396,12 @@ class Notify
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$newref);
break;
case 'PROPAL_CLOSE_SIGNED':
$link='/comm/propal/card.php?id='.$object->id;
$dir_output = $conf->propal->dir_output;
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$newref);
break;
case 'PROPAL_CLOSE_SIGNED':
$link='/comm/propal/card.php?id='.$object->id;
$dir_output = $conf->propal->dir_output;
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$newref);
break;
case 'FICHINTER_ADD_CONTACT':
$link='/fichinter/card.php?id='.$object->id;
$dir_output = $conf->facture->dir_output;
@ -444,7 +444,7 @@ class Notify
$mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated",$newref);
break;
}
$ref = dol_sanitizeFileName($newref);
$ref = dol_sanitizeFileName($newref);
$pdf_path = $dir_output."/".$ref."/".$ref.".pdf";
if (! dol_is_file($pdf_path))
{
@ -456,104 +456,104 @@ class Notify
$filepdf = $pdf_path;
}
$message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n";
$message.= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n";
$message.= "\n";
$message.= $mesg;
if ($link) $message=dol_concatdesc($message,$urlwithroot.$link);
$message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n";
$message.= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n";
$message.= "\n";
$message.= $mesg;
if ($link) $message=dol_concatdesc($message,$urlwithroot.$link);
$parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$file, 'mimefile'=>$mimefile, 'filename'=>$filename);
$reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject'];
if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message'];
}
$parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$file, 'mimefile'=>$mimefile, 'filename'=>$filename);
$reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject'];
if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message'];
}
$mailfile = new CMailFile(
$subject,
$sendto,
$replyto,
$message,
array($file),
array($mimefile),
array($filename[count($filename)-1]),
'',
'',
0,
-1
);
$mailfile = new CMailFile(
$subject,
$sendto,
$replyto,
$message,
array($file),
array($mimefile),
array($filename[count($filename)-1]),
'',
'',
0,
-1
);
if ($mailfile->sendfile())
{
if ($obj->type_target == 'touserid') {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
if ($mailfile->sendfile())
{
if ($obj->type_target == 'touserid') {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
}
else {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)";
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
}
else {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)";
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
}
if (! $this->db->query($sql))
{
dol_print_error($this->db);
}
}
else
}
if (! $this->db->query($sql))
{
dol_print_error($this->db);
}
}
else
{
$error++;
$this->errors[]=$mailfile->error;
}
}
else
{
dol_syslog("No notification sent for ".$sendto." because email is empty");
}
$i++;
}
}
else
{
dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".$object->socid);
$this->errors[]=$mailfile->error;
}
}
else
{
dol_syslog("No notification sent for ".$sendto." because email is empty");
}
$i++;
}
}
}
else
{
$error++;
$this->errors[]=$this->db->lasterror();
dol_syslog("Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR);
return -1;
}
else
{
dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".$object->socid);
}
}
else
{
$error++;
$this->errors[]=$this->db->lasterror();
dol_syslog("Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR);
return -1;
}
// Check notification using fixed email
if (! $error)
{
foreach($conf->global as $key => $val)
{
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
// Check notification using fixed email
if (! $error)
{
foreach($conf->global as $key => $val)
{
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
$threshold = (float) $reg[1];
if (!empty($object->total_ht) && $object->total_ht <= $threshold)
{
dol_syslog("A notification is requested for notifcode = ".$notifcode." but amount = ".$object->total_ht." so lower than threshold = ".$threshold.". We discard this notification");
continue;
}
$threshold = (float) $reg[1];
if (!empty($object->total_ht) && $object->total_ht <= $threshold)
{
dol_syslog("A notification is requested for notifcode = ".$notifcode." but amount = ".$object->total_ht." so lower than threshold = ".$threshold.". We discard this notification");
continue;
}
$param='NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1];
$param='NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1];
$sendto = $conf->global->$param;
$notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid');
if ($notifcodedefid <= 0) dol_print_error($this->db, 'Failed to get id from code');
$sendto = $conf->global->$param;
$notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid');
if ($notifcodedefid <= 0) dol_print_error($this->db, 'Failed to get id from code');
$object_type = '';
$link = '';
$num++;
$object_type = '';
$link = '';
$num++;
$subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification");
$subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification");
switch ($notifcode) {
switch ($notifcode) {
case 'BILL_VALIDATE':
$link='/compta/facture/card.php?facid='.$object->id;
$dir_output = $conf->facture->dir_output;
@ -578,32 +578,32 @@ class Notify
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated",$newref);
break;
case 'PROPAL_CLOSE_SIGNED':
$link='/comm/propal/card.php?id='.$object->id;
$dir_output = $conf->propal->dir_output;
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$newref);
break;
case 'FICHINTER_ADD_CONTACT':
$link='/fichinter/card.php?id='.$object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact",$newref);
break;
case 'PROPAL_CLOSE_SIGNED':
$link='/comm/propal/card.php?id='.$object->id;
$dir_output = $conf->propal->dir_output;
$object_type = 'propal';
$mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned",$newref);
break;
case 'FICHINTER_ADD_CONTACT':
$link='/fichinter/card.php?id='.$object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact",$newref);
break;
case 'FICHINTER_VALIDATE':
$link='/fichinter/card.php?id='.$object->id;
$dir_output = $conf->facture->dir_output;
$object_type = 'ficheinter';
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated",$newref);
break;
case 'ORDER_SUPPLIER_VALIDATE':
$link='/fourn/commande/card.php?id='.$object->id;
$dir_output = $conf->fournisseur->commande->dir_output;
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy",$newref,$user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'ORDER_SUPPLIER_VALIDATE':
$link='/fourn/commande/card.php?id='.$object->id;
$dir_output = $conf->fournisseur->commande->dir_output;
$object_type = 'order_supplier';
$mesg = $langs->transnoentitiesnoconv("Hello").",\n\n";
$mesg.= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy",$newref,$user->getFullName($langs));
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
break;
case 'ORDER_SUPPLIER_APPROVE':
$link='/fourn/commande/card.php?id='.$object->id;
$dir_output = $conf->fournisseur->commande->dir_output;
@ -646,73 +646,73 @@ class Notify
$filepdf = $pdf_path;
}
$message = $langs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n";
$message.= $langs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n";
$message.= "\n";
$message.= $mesg;
if ($link) $message=dol_concatdesc($message,$urlwithroot.$link);
$message = $langs->transnoentities("YouReceiveMailBecauseOfNotification",$application,$mysoc->name)."\n";
$message.= $langs->transnoentities("YouReceiveMailBecauseOfNotification2",$application,$mysoc->name)."\n";
$message.= "\n";
$message.= $mesg;
if ($link) $message=dol_concatdesc($message,$urlwithroot.$link);
// Replace keyword __SUPERVISOREMAIL__
if (preg_match('/__SUPERVISOREMAIL__/', $sendto))
{
$newval='';
if ($user->fk_user > 0)
{
$supervisoruser=new User($this->db);
$supervisoruser->fetch($user->fk_user);
if ($supervisoruser->email) $newval=trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>');
}
dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval);
$sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto);
$sendto = preg_replace('/^[\s,]+/','',$sendto); // Clean start of string
$sendto = preg_replace('/[\s,]+$/','',$sendto); // Clean end of string
}
// Replace keyword __SUPERVISOREMAIL__
if (preg_match('/__SUPERVISOREMAIL__/', $sendto))
{
$newval='';
if ($user->fk_user > 0)
{
$supervisoruser=new User($this->db);
$supervisoruser->fetch($user->fk_user);
if ($supervisoruser->email) $newval=trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>');
}
dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval);
$sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto);
$sendto = preg_replace('/^[\s,]+/','',$sendto); // Clean start of string
$sendto = preg_replace('/[\s,]+$/','',$sendto); // Clean end of string
}
if ($sendto)
{
$parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$file, 'mimefile'=>$mimefile, 'filename'=>$filename);
$reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject'];
if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message'];
}
if ($sendto)
{
$parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$file, 'mimefile'=>$mimefile, 'filename'=>$filename);
$reshook=$hookmanager->executeHooks('formatNotificationMessage',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject'];
if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message'];
}
$mailfile = new CMailFile(
$subject,
$sendto,
$replyto,
$message,
array($file),
array($mimefile),
array($filename[count($filename)-1]),
'',
'',
0,
-1
);
$mailfile = new CMailFile(
$subject,
$sendto,
$replyto,
$message,
array($file),
array($mimefile),
array($filename[count($filename)-1]),
'',
'',
0,
-1
);
if ($mailfile->sendfile())
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)";
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')";
if (! $this->db->query($sql))
{
dol_print_error($this->db);
}
}
else
{
$error++;
$this->errors[]=$mailfile->error;
}
}
}
}
if ($mailfile->sendfile())
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)";
$sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')";
if (! $this->db->query($sql))
{
dol_print_error($this->db);
}
}
else
{
$error++;
$this->errors[]=$mailfile->error;
}
}
}
}
if (! $error) return $num;
else return -1 * $error;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -44,7 +44,7 @@ function project_prepare_head($object)
$head[$h][2] = 'project';
$h++;
$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.'/projet/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans("ProjectContact");
if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
@ -69,22 +69,22 @@ function project_prepare_head($object)
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$nbNote = 0;
if(!empty($object->note_private)) $nbNote++;
{
$nbNote = 0;
if(!empty($object->note_private)) $nbNote++;
if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
$head[$h][2] = 'notes';
$h++;
}
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->projet->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);
$nbLinks=Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
@ -123,12 +123,12 @@ function project_prepare_head($object)
}
$head[$h][0] = DOL_URL_ROOT.'/projet/info.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][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++;
@ -171,8 +171,8 @@ function task_prepare_head($object)
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $nbTimeSpent=1;
$obj = $db->fetch_object($resql);
if ($obj) $nbTimeSpent=1;
}
else dol_print_error($db);
@ -189,23 +189,23 @@ function task_prepare_head($object)
complete_head_from_modules($conf,$langs,$object,$head,$h,'task');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$nbNote = 0;
if(!empty($object->note_private)) $nbNote++;
{
$nbNote = 0;
if(!empty($object->note_private)) $nbNote++;
if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
$head[$h][2] = 'task_notes';
$h++;
}
}
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->project->ref) . '/' .dol_sanitizeFileName($object->ref);
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$nbFiles = count(dol_dir_list($filesdir,'files',0,'','(\.meta|_preview.*\.png)$'));
$nbLinks=Link::count($db, $object->element, $object->id);
$nbLinks=Link::count($db, $object->element, $object->id);
$head[$h][1] = $langs->trans('Documents');
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
$head[$h][2] = 'task_document';
@ -467,11 +467,11 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
// Date end
print '<td align="center">';
$taskstatic->projectstatus = $lines[$i]->projectstatus;
$taskstatic->progress = $lines[$i]->progress;
$taskstatic->fk_statut = $lines[$i]->status;
$taskstatic->datee = $lines[$i]->date_end;
print dol_print_date($lines[$i]->date_end,'dayhour');
if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
$taskstatic->progress = $lines[$i]->progress;
$taskstatic->fk_statut = $lines[$i]->status;
$taskstatic->datee = $lines[$i]->date_end;
print dol_print_date($lines[$i]->date_end,'dayhour');
if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late"));
print '</td>';
$plannedworkloadoutputformat='allhourmin';
@ -531,9 +531,9 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
if ($level >= 0) // Call sublevels
{
$level++;
if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
$level--;
$level++;
if ($lines[$i]->id) projectLinesa($inc, $lines[$i]->id, $lines, $level, $var, $showproject, $taskrole, $projectsListId, $addordertick);
$level--;
}
$total_projectlinesa_spent += $lines[$i]->duration;
@ -605,13 +605,13 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
if ($parent == 0) // Always and only if at first level
{
for ($i = 0 ; $i < $numlines ; $i++)
{
if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
}
for ($i = 0 ; $i < $numlines ; $i++)
{
if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
}
}
//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
//dol_syslog('projectLinesPerDay inc='.$inc.' preselectedday='.$preselectedday.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
for ($i = 0 ; $i < $numlines ; $i++)
{
if ($parent == 0) $level = 0;
@ -621,26 +621,26 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
// If we want all or we have a role on task, we show it
if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
{
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
// Break on a new project
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
$lastprojectid=$lines[$i]->fk_project;
if ($preselectedday)
{
$projectstatic->id = $lines[$i]->fk_project;
}
}
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
$lastprojectid=$lines[$i]->fk_project;
if ($preselectedday)
{
$projectstatic->id = $lines[$i]->fk_project;
}
}
if (empty($workloadforid[$projectstatic->id]))
{
if ($preselectedday)
{
$projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
$workloadforid[$projectstatic->id]=1;
}
}
if (empty($workloadforid[$projectstatic->id]))
{
if ($preselectedday)
{
$projectstatic->loadTimeSpent($preselectedday, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
$workloadforid[$projectstatic->id]=1;
}
}
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
@ -665,12 +665,12 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY))
{
// Thirdparty
print '<td class="tdoverflowmax100">';
$thirdpartystatic->id=$lines[$i]->socid;
$thirdpartystatic->name=$lines[$i]->thirdparty_name;
print $thirdpartystatic->getNomUrl(1, 'project', 10);
print '</td>';
// Thirdparty
print '<td class="tdoverflowmax100">';
$thirdpartystatic->id=$lines[$i]->socid;
$thirdpartystatic->name=$lines[$i]->thirdparty_name;
print $thirdpartystatic->getNomUrl(1, 'project', 10);
print '</td>';
}
// Ref
@ -753,14 +753,14 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
print '<td align="center" class="duration'.($cssonholiday?' '.$cssonholiday:'').'">';
$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id];
$alreadyspent='';
if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
$alreadyspent='';
if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
$idw = 0;
$idw = 0;
$tableCell='';
$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
$tableCell.='<span class="hideonsmartphone"> + </span>';
$tableCell.='<span class="hideonsmartphone"> + </span>';
//$tableCell.='&nbsp;&nbsp;&nbsp;';
$tableCell.=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1);
//$tableCell.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled':'').' value="'.$langs->trans("Add").'">';
@ -800,8 +800,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
$level++;
if ($lines[$i]->id > 0)
{
if ($parent == 0) projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
if ($parent == 0) projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
else projectLinesPerDay($inc, $lines[$i]->id, $fuser, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable);
}
$level--;
}
@ -845,13 +845,13 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
// Create a smaller array with sublevels only to be used later. This increase dramatically performances.
if ($parent == 0) // Always and only if at first level
{
for ($i = 0 ; $i < $numlines ; $i++)
{
if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
}
for ($i = 0 ; $i < $numlines ; $i++)
{
if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[]=$lines[$i];
}
}
//dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
//dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
for ($i = 0 ; $i < $numlines ; $i++)
{
@ -862,20 +862,20 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
// If we want all or we have a role on task, we show it
if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
{
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
//dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
// Break on a new project
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
$lastprojectid=$lines[$i]->fk_project;
$projectstatic->id = $lines[$i]->fk_project;
}
// Break on a new project
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
$lastprojectid=$lines[$i]->fk_project;
$projectstatic->id = $lines[$i]->fk_project;
}
if (empty($workloadforid[$projectstatic->id]))
{
$projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
$workloadforid[$projectstatic->id]=1;
}
if (empty($workloadforid[$projectstatic->id]))
{
$projectstatic->loadTimeSpent($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
$workloadforid[$projectstatic->id]=1;
}
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
@ -899,12 +899,12 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY))
{
// Thirdparty
print '<td class="tdoverflowmax100">';
$thirdpartystatic->id=$lines[$i]->thirdparty_id;
$thirdpartystatic->name=$lines[$i]->thirdparty_name;
print $thirdpartystatic->getNomUrl(1, 'project');
print '</td>';
// Thirdparty
print '<td class="tdoverflowmax100">';
$thirdpartystatic->id=$lines[$i]->thirdparty_id;
$thirdpartystatic->name=$lines[$i]->thirdparty_name;
print $thirdpartystatic->getNomUrl(1, 'project');
print '</td>';
}
// Ref
@ -979,7 +979,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
// Fields to show current time
$tableCell=''; $modeinput='hours';
for ($idw = 0; $idw < 7; $idw++)
{
{
$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd');
$cssonholiday='';
@ -988,28 +988,28 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon ';
$tmparray=dol_getdate($tmpday);
$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
$alreadyspent='';
if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
$alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
$dayWorkLoad = $projectstatic->weekWorkLoadPerTask[$tmpday][$lines[$i]->id];
$alreadyspent='';
if ($dayWorkLoad > 0) $alreadyspent=convertSecondToTime($dayWorkLoad,'allhourmin');
$alttitle=$langs->trans("AddHereTimeSpentForDay",$tmparray['day'],$tmparray['mon']);
$tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').'">';
if ($alreadyspent)
{
$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
//$placeholder=' placeholder="00:00"';
$placeholder='';
//$tableCell.='+';
}
$tableCell.='<input type="text" alt="'.($disabledtask?'':$alttitle).'" title="'.($disabledtask?'':$alttitle).'" '.($disabledtask?'disabled':$placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"';
$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
$tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
$tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
$tableCell.='</td>';
print $tableCell;
}
$tableCell ='<td align="center" class="hide'.$idw.($cssonholiday?' '.$cssonholiday:'').'">';
if ($alreadyspent)
{
$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center smallpadd" size="2" disabled id="timespent['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="'.$alreadyspent.'"></span>';
//$placeholder=' placeholder="00:00"';
$placeholder='';
//$tableCell.='+';
}
$tableCell.='<input type="text" alt="'.($disabledtask?'':$alttitle).'" title="'.($disabledtask?'':$alttitle).'" '.($disabledtask?'disabled':$placeholder).' class="center smallpadd" size="2" id="timeadded['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"';
$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
$tableCell.=' onkeyup="updateTotal('.$idw.',\''.$modeinput.'\')"';
$tableCell.=' onblur="regexEvent(this,event,\''.$modeinput.'\'); updateTotal('.$idw.',\''.$modeinput.'\')" />';
$tableCell.='</td>';
print $tableCell;
}
// Warning
// Warning
print '<td align="right">';
if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
else if ($disabledtask)
@ -1021,7 +1021,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
}
print '</td>';
print "</tr>\n";
print "</tr>\n";
}
// Call to show task with a lower level (task under the current task)
@ -1029,8 +1029,8 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
$level++;
if ($lines[$i]->id > 0)
{
if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
if ($parent == 0) projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lineswithoutlevel0, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
else projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, $lines, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable);
}
$level--;
}
@ -1100,7 +1100,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$projectstatic=new Project($db);
$thirdpartystatic=new Societe($db);
$thirdpartystatic=new Societe($db);
$sortfield='';
$sortorder='';
@ -1161,12 +1161,12 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
$resql = $db->query($sql1);
if ($resql)
{
$i=0;
$i=0;
$num = $db->num_rows($resql);
while ($i < $num)
{
$objp = $db->fetch_object($resql);
$arrayidofprojects[$objp->projectid]=$objp->projectid;
$arrayidofprojects[$objp->projectid]=$objp->projectid;
$i++;
}
}
@ -1194,22 +1194,22 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
$num = $db->num_rows($resql);
$i = 0;
print '<tr class="liste_titre">';
print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder);
print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder);
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder);
if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
}
print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
print '<tr class="liste_titre">';
print_liste_field_titre($title.' <span class="badge">'.$num.'</span>',$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"","","","",$sortfield,$sortorder);
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print_liste_field_titre("OpportunityAmount","","","","",'align="right"',$sortfield,$sortorder);
print_liste_field_titre("OpportunityStatus","","","","",'align="right"',$sortfield,$sortorder);
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print_liste_field_titre("Tasks","","","","",'align="right"',$sortfield,$sortorder);
if (! in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload","","","","",'align="right"',$sortfield,$sortorder);
if (! in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared","","","","",'align="right"',$sortfield,$sortorder);
}
print_liste_field_titre("Status","","","","",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
while ($i < $num)
{
@ -1223,11 +1223,11 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
$userAccess = $projectstatic->restrictedProjectArea($user);
if ($userAccess >= 0)
{
$projectstatic->ref=$objp->ref;
$projectstatic->statut = $objp->status;
$projectstatic->title = $objp->title;
$projectstatic->datee = $db->jdate($objp->datee);
$projectstatic->dateo = $db->jdate($objp->dateo);
$projectstatic->ref=$objp->ref;
$projectstatic->statut = $objp->status;
$projectstatic->title = $objp->title;
$projectstatic->datee = $db->jdate($objp->datee);
$projectstatic->dateo = $db->jdate($objp->dateo);
print '<tr class="oddeven">';
@ -1238,41 +1238,41 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
print '<td>';
if ($objp->fk_soc > 0)
{
$thirdpartystatic->id=$objp->fk_soc;
$thirdpartystatic->ref=$objp->socname;
$thirdpartystatic->name=$objp->socname;
print $thirdpartystatic->getNomUrl(1);
$thirdpartystatic->id=$objp->fk_soc;
$thirdpartystatic->ref=$objp->socname;
$thirdpartystatic->name=$objp->socname;
print $thirdpartystatic->getNomUrl(1);
}
print '</td>';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
print '<td align="right">';
if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
print '</td>';
print '<td align="right">';
$code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
if ($code) print $langs->trans("OppStatus".$code);
if ($code) print $langs->trans("OppStatus".$code);
print '</td>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<td align="right">'.$objp->nb.'</td>';
print '<td align="right">'.$objp->nb.'</td>';
$plannedworkload=$objp->planned_workload;
$total_plannedworkload+=$plannedworkload;
if (! in_array('plannedworkload', $hiddenfields))
{
print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>';
}
if (! in_array('declaredprogress', $hiddenfields))
{
$declaredprogressworkload=$objp->declared_progess_workload;
$total_declaredprogressworkload+=$declaredprogressworkload;
print '<td align="right">';
//print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':'');
print '</td>';
}
$plannedworkload=$objp->planned_workload;
$total_plannedworkload+=$plannedworkload;
if (! in_array('plannedworkload', $hiddenfields))
{
print '<td align="right">'.($plannedworkload?convertSecondToTime($plannedworkload):'').'</td>';
}
if (! in_array('declaredprogress', $hiddenfields))
{
$declaredprogressworkload=$objp->declared_progess_workload;
$total_declaredprogressworkload+=$declaredprogressworkload;
print '<td align="right">';
//print $objp->planned_workload.'-'.$objp->declared_progess_workload."<br>";
print ($plannedworkload?round(100*$declaredprogressworkload/$plannedworkload,0).'%':'');
print '</td>';
}
}
print '<td align="right">'.$projectstatic->getLibStatut(3).'</td>';
@ -1295,12 +1295,12 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks=
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print '<td class="liste_total" align="right">'.$total_task.'</td>';
if (! in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
print '<td class="liste_total" align="right">'.$total_task.'</td>';
if (! in_array('plannedworkload', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?convertSecondToTime($total_plannedworkload):'').'</td>';
if (! in_array('declaredprogress', $hiddenfields)) print '<td class="liste_total" align="right">'.($total_plannedworkload?round(100*$total_declaredprogressworkload/$total_plannedworkload,0).'%':'').'</td>';
}
print '<td class="liste_total"></td>';
print '</tr>';
print '</tr>';
$db->free($resql);
}

View File

@ -45,10 +45,10 @@ function user_prepare_head($object)
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/user/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("UserCard");
$head[$h][2] = 'user';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("UserCard");
$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)))
@ -60,10 +60,10 @@ function user_prepare_head($object)
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id;
$head[$h][1] = $langs->trans("UserGUISetup");
$head[$h][2] = 'guisetup';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/param_ihm.php?id='.$object->id;
$head[$h][1] = $langs->trans("UserGUISetup");
$head[$h][2] = 'guisetup';
$h++;
if ($canreadperms)
{
@ -73,116 +73,116 @@ function user_prepare_head($object)
$h++;
}
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->agenda->enabled))
{
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
$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;
$i++;
$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;
$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][2] = 'extsites';
$h++;
}
if (! empty($conf->clicktodial->enabled))
{
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$object->id;
$head[$h][1] = $langs->trans("ClickToDial");
$head[$h][2] = 'clicktodial';
$h++;
}
// Notifications
if ($user->societe_id == 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);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$nbNote=$obj->nb;
$i++;
}
}
else {
dol_print_error($db);
}
$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>';
$head[$h][2] = 'notify';
$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,'user');
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
{
// Bank
$head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id;
$head[$h][1] = $langs->trans("HRAndBank");
$head[$h][2] = 'bank';
$h++;
$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][2] = 'extsites';
$h++;
}
// Such info on users is visible only by internal user
if (empty($user->societe_id))
{
// Notes
$nbNote = 0;
if(!empty($object->note)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/user/note.php?id='.$object->id;
$head[$h][1] = $langs->trans("Note");
if (! empty($conf->clicktodial->enabled))
{
$head[$h][0] = DOL_URL_ROOT.'/user/clicktodial.php?id='.$object->id;
$head[$h][1] = $langs->trans("ClickToDial");
$head[$h][2] = 'clicktodial';
$h++;
}
// Notifications
if ($user->societe_id == 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);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$nbNote=$obj->nb;
$i++;
}
}
else {
dol_print_error($db);
}
$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>';
$head[$h][2] = 'note';
$h++;
$head[$h][2] = 'notify';
$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);
$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>';
$head[$h][2] = 'document';
$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,'user');
$head[$h][0] = DOL_URL_ROOT.'/user/info.php?id='.$object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
}
if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
|| (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read)))
{
// Bank
$head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id;
$head[$h][1] = $langs->trans("HRAndBank");
$head[$h][2] = 'bank';
$h++;
}
complete_head_from_modules($conf,$langs,$object,$head,$h,'user','remove');
// Such info on users is visible only by internal user
if (empty($user->societe_id))
{
// Notes
$nbNote = 0;
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>';
$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);
$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>';
$head[$h][2] = 'document';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/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,'user','remove');
return $head;
}
@ -206,10 +206,10 @@ function group_prepare_head($object)
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/user/group/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("GroupCard");
$head[$h][2] = 'group';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/group/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("GroupCard");
$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)))
@ -229,15 +229,15 @@ function group_prepare_head($object)
$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,'group');
// 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,'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;
return $head;
}
/**
@ -252,25 +252,25 @@ function user_admin_prepare_head()
$langs->load("users");
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/admin/user.php';
$head[$h][1] = $langs->trans("Parameters");
$head[$h][2] = 'card';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/admin/user.php';
$head[$h][1] = $langs->trans("Parameters");
$head[$h][2] = 'card';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/admin/usergroup.php';
$head[$h][1] = $langs->trans("Group");
$head[$h][2] = 'usergroupcard';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/admin/usergroup.php';
$head[$h][1] = $langs->trans("Group");
$head[$h][2] = 'usergroupcard';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/admin/user_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/admin/user_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/user/admin/group_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields")." ".$langs->trans("Groups");
$head[$h][2] = 'attributes_group';
$h++;
$head[$h][1] = $langs->trans("ExtraFields")." ".$langs->trans("Groups");
$head[$h][2] = 'attributes_group';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
@ -293,134 +293,134 @@ function user_admin_prepare_head()
*/
function show_theme($fuser,$edit=0,$foruserprofile=false)
{
global $conf,$langs,$db,$form;
global $bc;
global $conf,$langs,$db,$form;
global $bc;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
$formother = new FormOther($db);
$formother = new FormOther($db);
$dirthemes=array('/theme');
if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application
{
foreach($conf->modules_parts['theme'] as $reldir)
{
$dirthemes=array_merge($dirthemes,(array) ($reldir.'theme'));
}
}
$dirthemes=array_unique($dirthemes);
$dirthemes=array('/theme');
if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application
{
foreach($conf->modules_parts['theme'] as $reldir)
{
$dirthemes=array_merge($dirthemes,(array) ($reldir.'theme'));
}
}
$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'):'');
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'):'');
$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" width="100%">';
// Title
if ($foruserprofile)
{
print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("Parameter").'</th><th>'.$langs->trans("DefaultValue").'</th>';
print '<th colspan="2">&nbsp;</th>';
print '</tr>';
// Title
if ($foruserprofile)
{
print '<tr class="liste_titre"><th class="titlefield">'.$langs->trans("Parameter").'</th><th>'.$langs->trans("DefaultValue").'</th>';
print '<th colspan="2">&nbsp;</th>';
print '</tr>';
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>&nbsp;</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';
print '<a href="'.$url.'" target="_blank">';
print $langs->trans('DownloadMoreSkins');
print '</a>';
print '</th></tr>';
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>&nbsp;</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';
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>';
print '<td>'.$langs->trans("ThemeDir").'</td>';
print '<td>';
foreach($dirthemes as $dirtheme)
{
echo '"'.$dirtheme.'" ';
}
print '</td>';
print '</tr>';
}
print '<tr><td colspan="'.$colspan.'">';
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 align="center">';
$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);
$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);
if (is_dir($dirtheme))
{
$handle=opendir($dirtheme);
if (is_resource($handle))
{
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))
{
// 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 (is_dir($dirtheme))
{
$handle=opendir($dirtheme);
if (is_resource($handle))
{
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))
{
// 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."/".$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;">';
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>';
}
else
{
print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
}
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;">';
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>';
}
else
{
print '<input '.($edit?'':'disabled').' type="radio" class="themethumbs" style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
}
print '</div>';
$i++;
}
}
}
}
}
$i++;
}
}
}
}
}
print '</div></td></tr></table>';
print '</div></td></tr></table>';
print '</td></tr>';
print '</td></tr>';
// TopMenuDisableImages
if ($foruserprofile)
{
/*
// TopMenuDisableImages
if ($foruserprofile)
{
/*
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>';
@ -440,30 +440,30 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
}
if ($edit) print '<br>('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
print '</td>';*/
}
else
{
$default=$langs->trans('No');
print '<tr class="oddeven">';
print '<td>'.$langs->trans("TopMenuDisableImages").'</td>';
print '<td colspan="'.($colspan-1).'">';
if ($edit)
{
print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1);
}
else
{
print yn($conf->global->THEME_TOPMENU_DISABLE_IMAGE);
}
print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
}
else
{
$default=$langs->trans('No');
print '<tr class="oddeven">';
print '<td>'.$langs->trans("TopMenuDisableImages").'</td>';
print '<td colspan="'.($colspan-1).'">';
if ($edit)
{
print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1);
}
else
{
print yn($conf->global->THEME_TOPMENU_DISABLE_IMAGE);
}
print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
// Background color THEME_ELDY_BACKBODY
if ($foruserprofile)
if ($foruserprofile)
{
/*
/*
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>';
@ -486,29 +486,29 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
}
else
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("BackgroundColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
//var_dump($conf->global->THEME_ELDY_BACKBODY);
if ($edit)
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("BackgroundColor").'</td>';
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).' ';
}
}
else
{
$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");
}
print ' &nbsp; ('.$langs->trans("Default").': <strong>ffffff</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
print ' &nbsp; ('.$langs->trans("Default").': <strong>ffffff</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
// TopMenuBackgroundColor
if ($foruserprofile)
if ($foruserprofile)
{
/*
/*
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>';
@ -531,25 +531,25 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
}
else
{
$default='5a6482';
if ($conf->theme == 'md') $default='5a3278';
$default='5a6482';
if ($conf->theme == 'md') $default='5a3278';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
if ($edit)
{
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).' ';
}
}
else
{
$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");
}
print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
// LeftMenuBackgroundColor
@ -607,22 +607,22 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
}
else
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("BackgroundTableTitleColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
if ($edit)
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("BackgroundTableTitleColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
if ($edit)
{
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 ' &nbsp; ('.$langs->trans("Default").': <strong>f0f0f0</strong>) '; // $colorbacktitle1 in CSS
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
print ' &nbsp; ('.$langs->trans("Default").': <strong>f0f0f0</strong>) '; // $colorbacktitle1 in CSS
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
print '</tr>';
print '</tr>';
}
// BackgroundTableLineOddColor
@ -632,25 +632,25 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
}
else
{
$default='ffffff';
if ($conf->theme == 'md') $default='ffffff';
$default='ffffff';
if ($conf->theme == 'md') $default='ffffff';
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).' ';
}
else
{
$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");
}
print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
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).' ';
}
else
{
$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");
}
print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
// BackgroundTableLineEvenColor
@ -660,25 +660,25 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
}
else
{
$default='f8f8f8';
if ($conf->theme == 'md') $default='f8f8f8';
$default='f8f8f8';
if ($conf->theme == 'md') $default='f8f8f8';
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).' ';
}
else
{
$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");
}
print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
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).' ';
}
else
{
$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");
}
print ' &nbsp; ('.$langs->trans("Default").': <strong>'.$default.'</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
// TextTitleColor
@ -689,29 +689,29 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
}
else
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("TextTitleColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
if ($edit)
{
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 ' &nbsp; ('.$langs->trans("Default").': <strong><span style="color: #3c3c14">3c3c14</span></strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '<tr class="oddeven">';
print '<td>'.$langs->trans("TextTitleColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
if ($edit)
{
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 ' &nbsp; ('.$langs->trans("Default").': <strong><span style="color: #3c3c14">3c3c14</span></strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
print '</td>';
print '</tr>';
print '</tr>';
}
// Text LinkColor
if ($foruserprofile)
{
/*
/*
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>';
@ -734,33 +734,33 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
}
else
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("LinkColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
if ($edit)
{
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()),'');
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 '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$defaultcolor.'" value="'.$langs->trans("Default").'">';
//print '<span style="color: #000078">'.$langs->trans("Default").'</span>';
print $langs->trans("Default");
}
}
print ' &nbsp; ('.$langs->trans("Default").': <strong><span style="color: #000078">000078</span></strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("LinkColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
if ($edit)
{
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()),'');
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 '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$defaultcolor.'" value="'.$langs->trans("Default").'">';
//print '<span style="color: #000078">'.$langs->trans("Default").'</span>';
print $langs->trans("Default");
}
}
print ' &nbsp; ('.$langs->trans("Default").': <strong><span style="color: #000078">000078</span></strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
// Use Hover
if ($foruserprofile)
{
/* Must first change option to choose color of highlight instead of yes or no.
/* 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>';
@ -773,33 +773,33 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
}
else
{
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 ' &nbsp; ('.$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).' ';
}
else
{
if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
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.'">';
else print $langs->trans("Default");
}
else print $langs->trans("None");
}
print ' &nbsp; ('.$langs->trans("Default").': <strong>edf4fb</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
print '</tr>';
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 ' &nbsp; ('.$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).' ';
}
else
{
if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb';
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.'">';
else print $langs->trans("Default");
}
else print $langs->trans("None");
}
print ' &nbsp; ('.$langs->trans("Default").': <strong>edf4fb</strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
print '</tr>';
}
print '</table>';
print '</table>';
}

View File

@ -31,59 +31,59 @@
*/
function dolWebsiteOutput($content)
{
global $db, $langs, $conf, $user;
global $dolibarr_main_url_root, $dolibarr_main_data_root;
global $db, $langs, $conf, $user;
global $dolibarr_main_url_root, $dolibarr_main_data_root;
dol_syslog("dolWebsiteOutput start (mode=".(defined('USEDOLIBARRSERVER')?'USEDOLIBARRSERVER':'').')');
dol_syslog("dolWebsiteOutput start (mode=".(defined('USEDOLIBARRSERVER')?'USEDOLIBARRSERVER':'').')');
// 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
// 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
// Note: This seems never called when page is output inside the website editor (search 'REPLACEMENT OF LINKS When page called by website editor')
// Note: This seems never called when page is output inside the website editor (search 'REPLACEMENT OF LINKS When page called by website editor')
if (! defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from virtual host
{
$symlinktomediaexists=1;
if (! defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from virtual host
{
$symlinktomediaexists=1;
// Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server
// <img alt="" src="/dolibarr_dev/htdocs/viewimage.php?modulepart=medias&amp;entity=1&amp;file=image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
// become
// <img alt="" src="'.$urlwithroot.'/medias/image/ldestailleur_166x166.jpg" style="height:166px; width:166px" />
$nbrep=0;
if (! $symlinktomediaexists)
{
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
}
else
{
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1medias/\4\5', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
}
}
else // REPLACEMENT OF LINKS When page called from dolibarr server
{
global $website;
$nbrep=0;
if (! $symlinktomediaexists)
{
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1'.$urlwithroot.'/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep);
}
else
{
$content=preg_replace('/(<img[^>]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1medias/\4\5', $content, -1, $nbrep);
$content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep);
}
}
else // REPLACEMENT OF LINKS When page called from dolibarr server
{
global $website;
// Replace relative link / with dolibarr URL: ...href="/"...
$content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
// Replace relative link /xxx.php with dolibarr URL: ...href="....php"
$content=preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
// Replace relative link / with dolibarr URL: ...href="/"...
$content=preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
// Replace relative link /xxx.php with dolibarr URL: ...href="....php"
$content=preg_replace('/(href=")\/?([^\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
// Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart="
$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: ...href="/viewimage.php?modulepart="
$content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
// Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart="
$content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: ...href="/viewimage.php?modulepart="
$content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep);
// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
$content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
}
// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
$content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
}
dol_syslog("dolWebsiteOutput end");
dol_syslog("dolWebsiteOutput end");
print $content;
print $content;
}

View File

@ -98,12 +98,12 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
$resultFetchLdapUser=0;
// Define $userSearchFilter
$userSearchFilter = "";
if (empty($dolibarr_main_auth_ldap_filter)) {
$userSearchFilter = "(" . $ldapuserattr . "=" . $usertotest . ")";
} else {
$userSearchFilter = str_replace('%1%', $usertotest, $dolibarr_main_auth_ldap_filter);
}
$userSearchFilter = "";
if (empty($dolibarr_main_auth_ldap_filter)) {
$userSearchFilter = "(" . $ldapuserattr . "=" . $usertotest . ")";
} else {
$userSearchFilter = str_replace('%1%', $usertotest, $dolibarr_main_auth_ldap_filter);
}
// If admin login provided
// Code to get user in LDAP from an admin connection (may differ from user connection, done later)
@ -127,7 +127,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
}
else
{
if ($ldapdebug) print "DEBUG: ".$ldap->error."<br>\n";
if ($ldapdebug) print "DEBUG: ".$ldap->error."<br>\n";
}
$ldap->close();
}
@ -135,15 +135,15 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
// Forge LDAP user and password to test with them
// If LDAP need a dn with login like "uid=jbloggs,ou=People,dc=foo,dc=com", default dn may work even if previous code with
// admin login no exectued.
$ldap->searchUser=$ldapuserattr."=".$usertotest.",".$ldapdn; // Default dn (will work if LDAP accept a dn with login value inside)
$ldap->searchUser=$ldapuserattr."=".$usertotest.",".$ldapdn; // Default dn (will work if LDAP accept a dn with login value inside)
// But if LDAP need a dn with name like "cn=Jhon Bloggs,ou=People,dc=foo,dc=com", previous part must have been executed to have
// dn detected into ldapUserDN.
if ($resultFetchLdapUser && !empty($ldap->ldapUserDN)) $ldap->searchUser = $ldap->ldapUserDN;
$ldap->searchPassword=$passwordtotest;
$ldap->searchPassword=$passwordtotest;
// Test with this->seachUser and this->searchPassword
//print $resultFetchLdapUser."-".$ldap->ldapUserDN."-".$ldap->searchUser.'-'.$ldap->searchPassword;exit;
$result=$ldap->connect_bind();
//print $resultFetchLdapUser."-".$ldap->ldapUserDN."-".$ldap->searchUser.'-'.$ldap->searchPassword;exit;
$result=$ldap->connect_bind();
if ($result > 0)
{
if ($result == 2) // Connection is ok for user/pass into LDAP
@ -214,7 +214,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
}
else
{
/* Login failed. Return false, together with the error code and text from
/* Login failed. Return false, together with the error code and text from
** the LDAP server. The common error codes and reasons are listed below :
** (for iPlanet, other servers may differ)
** 19 - Account locked out (too many invalid login attempts)
@ -222,13 +222,13 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
** 49 - Wrong password
** 53 - Account inactive (manually locked out by administrator)
*/
dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP for '".$usertotest."'");
if (is_resource($ldap->connection)) // If connection ok but bind ko
{
$ldap->ldapErrorCode = ldap_errno($ldap->connection);
$ldap->ldapErrorText = ldap_error($ldap->connection);
dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText);
}
dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP for '".$usertotest."'");
if (is_resource($ldap->connection)) // If connection ok but bind ko
{
$ldap->ldapErrorCode = ldap_errno($ldap->connection);
$ldap->ldapErrorText = ldap_error($ldap->connection);
dol_syslog("functions_ldap::check_user_password_ldap ".$ldap->ldapErrorCode." ".$ldap->ldapErrorText);
}
sleep(2); // Anti brut force protection
$langs->load('main');
$langs->load('other');

File diff suppressed because it is too large Load Diff

View File

@ -35,22 +35,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
*/
class html_cerfafr extends ModeleDon
{
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
function __construct($db)
{
global $conf,$langs;
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
function __construct($db)
{
global $conf,$langs;
$this->db = $db;
$this->name = "cerfafr";
$this->description = $langs->trans('DonationsReceiptModel').' - fr_FR - Cerfa 11580*03';
$this->db = $db;
$this->name = "cerfafr";
$this->description = $langs->trans('DonationsReceiptModel').' - fr_FR - Cerfa 11580*03';
// Dimension page for size A4
$this->type = 'html';
}
// Dimension page for size A4
$this->type = 'html';
}
/**
@ -64,16 +64,16 @@ class html_cerfafr extends ModeleDon
}
/**
* Write the object to document file to disk
*
* @param Don $don Donation object
* @param Translate $outputlangs Lang object for output language
/**
* Write the object to document file to disk
*
* @param Don $don Donation object
* @param Translate $outputlangs Lang object for output language
* @param string $currency Currency code
* @return int >0 if OK, <0 if KO
*/
function write_file($don,$outputlangs,$currency='')
{
* @return int >0 if OK, <0 if KO
*/
function write_file($don,$outputlangs,$currency='')
{
global $user,$conf,$langs,$mysoc;
$now=dol_now();
@ -91,13 +91,13 @@ class html_cerfafr extends ModeleDon
$currency = !empty($currency) ? $currency : $conf->currency;
if (! empty($conf->don->dir_output))
{
{
// Definition of the object don (for upward compatibility)
if (! is_object($don))
{
$don = new Don($this->db);
$ret=$don->fetch($id);
$id=$don->id;
if (! is_object($don))
{
$don = new Don($this->db);
$ret=$don->fetch($id);
$id=$don->id;
}
// Definition of $dir and $file
@ -113,27 +113,27 @@ class html_cerfafr extends ModeleDon
$file = $dir . "/" . $donref . ".html";
}
if (! file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return -1;
}
}
if (! file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return -1;
}
}
if (file_exists($dir))
{
$formclass = new Form($this->db);
if (file_exists($dir))
{
$formclass = new Form($this->db);
// This is not the proper way to do it but $formclass->form_modes_reglement
// prints the translation instead of returning it
if ($don->modepaiementid)
{
$formclass->load_cache_types_paiements();
$paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label'];
}
else $paymentmode = '';
// This is not the proper way to do it but $formclass->form_modes_reglement
// prints the translation instead of returning it
if ($don->modepaiementid)
{
$formclass->load_cache_types_paiements();
$paymentmode = $formclass->cache_types_paiements[$don->modepaiementid]['label'];
}
else $paymentmode = '';
if ($don->modepaiementid==7){
$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
@ -160,52 +160,52 @@ class html_cerfafr extends ModeleDon
}
*/
// Define contents
$donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html";
$form = implode('', file($donmodel));
$form = str_replace('__REF__',$don->id,$form);
$form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form);
//$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist
$form = str_replace('__AMOUNT__',$don->amount,$form);
// Define contents
$donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html";
$form = implode('', file($donmodel));
$form = str_replace('__REF__',$don->id,$form);
$form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form);
//$form = str_replace('__IP__',$user->ip,$form); // TODO $user->ip not exist
$form = str_replace('__AMOUNT__',$don->amount,$form);
$form = str_replace('__AMOUNTLETTERS__',chiffre_en_lettre($don->amount),$form);
$form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form);
$form = str_replace('__CURRENCYCODE__',$conf->currency,$form);
$form = str_replace('__MAIN_INFO_SOCIETE_NOM__',$mysoc->name,$form);
$form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__',$mysoc->address,$form);
$form = str_replace('__MAIN_INFO_SOCIETE_ZIP__',$mysoc->zip,$form);
$form = str_replace('__MAIN_INFO_SOCIETE_TOWN__',$mysoc->town,$form);
$form = str_replace('__CURRENCY__',$outputlangs->transnoentitiesnoconv("Currency".$currency),$form);
$form = str_replace('__CURRENCYCODE__',$conf->currency,$form);
$form = str_replace('__MAIN_INFO_SOCIETE_NOM__',$mysoc->name,$form);
$form = str_replace('__MAIN_INFO_SOCIETE_ADDRESS__',$mysoc->address,$form);
$form = str_replace('__MAIN_INFO_SOCIETE_ZIP__',$mysoc->zip,$form);
$form = str_replace('__MAIN_INFO_SOCIETE_TOWN__',$mysoc->town,$form);
$form = str_replace('__MAIN_INFO_SOCIETE_OBJECT__',$mysoc->object,$form);
$form = str_replace('__DONATOR_FIRSTNAME__',$don->firstname,$form);
$form = str_replace('__DONATOR_LASTNAME__',$don->lastname,$form);
$form = str_replace('__DONATOR_LASTNAME__',$don->lastname,$form);
$form = str_replace('__DONATOR_SOCIETE__',$don->societe,$form);
$form = str_replace('__DONATOR_STATUT__',$don->statut,$form);
$form = str_replace('__DONATOR_ADDRESS__',$don->address,$form);
$form = str_replace('__DONATOR_ZIP__',$don->zip,$form);
$form = str_replace('__DONATOR_TOWN__',$don->town,$form);
$form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$form);
$form = str_replace('__DONATOR_ADDRESS__',$don->address,$form);
$form = str_replace('__DONATOR_ZIP__',$don->zip,$form);
$form = str_replace('__DONATOR_TOWN__',$don->town,$form);
$form = str_replace('__PAYMENTMODE_LIB__ ', $paymentmode,$form);
$form = str_replace('__ModePaiement__', $ModePaiement,$form);
$form = str_replace('__NOW__',dol_print_date($now,'day',false,$outputlangs),$form);
$form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form);
$form = str_replace('__NOW__',dol_print_date($now,'day',false,$outputlangs),$form);
$form = str_replace('__DonationRef__',$outputlangs->trans("DonationRef"),$form);
$form = str_replace('__DonationTitle__',$outputlangs->trans("DonationTitle"),$form);
$form = str_replace('__DonationReceipt__',$outputlangs->trans("DonationReceipt"),$form);
$form = str_replace('__DonationRecipient__',$outputlangs->trans("DonationRecipient"),$form);
$form = str_replace('__DonationDatePayment__',$outputlangs->trans("DonationDatePayment"),$form);
$form = str_replace('__DonationReceipt__',$outputlangs->trans("DonationReceipt"),$form);
$form = str_replace('__DonationRecipient__',$outputlangs->trans("DonationRecipient"),$form);
$form = str_replace('__DonationDatePayment__',$outputlangs->trans("DonationDatePayment"),$form);
$form = str_replace('__PaymentMode__',$outputlangs->trans("PaymentMode"),$form);
// $form = str_replace('__CodeDon__',$CodeDon,$form);
$form = str_replace('__Name__',$outputlangs->trans("Name"),$form);
$form = str_replace('__Address__',$outputlangs->trans("Address"),$form);
$form = str_replace('__Zip__',$outputlangs->trans("Zip"),$form);
$form = str_replace('__Town__',$outputlangs->trans("Town"),$form);
$form = str_replace('__Name__',$outputlangs->trans("Name"),$form);
$form = str_replace('__Address__',$outputlangs->trans("Address"),$form);
$form = str_replace('__Zip__',$outputlangs->trans("Zip"),$form);
$form = str_replace('__Town__',$outputlangs->trans("Town"),$form);
$form = str_replace('__Object__',$outputlangs->trans("Object"),$form);
$form = str_replace('__Donor__',$outputlangs->trans("Donor"),$form);
$form = str_replace('__Date__',$outputlangs->trans("Date"),$form);
$form = str_replace('__Signature__',$outputlangs->trans("Signature"),$form);
$form = str_replace('__Message__',$outputlangs->trans("Message"),$form);
$form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form);
$form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form);
$form = str_replace('__Donor__',$outputlangs->trans("Donor"),$form);
$form = str_replace('__Date__',$outputlangs->trans("Date"),$form);
$form = str_replace('__Signature__',$outputlangs->trans("Signature"),$form);
$form = str_replace('__Message__',$outputlangs->trans("Message"),$form);
$form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form);
$form = str_replace('__DonationMessage__',$conf->global->DONATION_MESSAGE,$form);
$frencharticle='';
if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>';
if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='<font size="+1">Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)</font>';
$form = str_replace('__FrenchArticle__',$frencharticle,$form);
$frencheligibility='';
@ -252,176 +252,176 @@ class html_cerfafr extends ModeleDon
$form = str_replace('__ARTICLE885__',$art885,$form);
// Save file on disk
dol_syslog("html_cerfafr::write_file $file");
$handle=fopen($file,"w");
fwrite($handle,$form);
fclose($handle);
dol_syslog("html_cerfafr::write_file $file");
$handle=fopen($file,"w");
fwrite($handle,$form);
fclose($handle);
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
return 1;
}
else
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
else
{
$this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR");
return 0;
return 1;
}
else
{
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
return 0;
}
}
}
else
{
$this->error=$langs->trans("ErrorConstantNotDefined","DON_OUTPUTDIR");
return 0;
}
}
}
function chiffre_en_lettre($montant, $devise1='', $devise2='')
{
if(empty($devise1)) $dev1='euros';
else $dev1=$devise1;
if(empty($devise2)) $dev2='centimes';
else $dev2=$devise2;
$valeur_entiere=intval($montant);
$valeur_decimal=intval(round($montant-intval($montant), 2)*100);
$dix_c=intval($valeur_decimal%100/10);
$cent_c=intval($valeur_decimal%1000/100);
$unite[1]=$valeur_entiere%10;
$dix[1]=intval($valeur_entiere%100/10);
$cent[1]=intval($valeur_entiere%1000/100);
$unite[2]=intval($valeur_entiere%10000/1000);
$dix[2]=intval($valeur_entiere%100000/10000);
$cent[2]=intval($valeur_entiere%1000000/100000);
$unite[3]=intval($valeur_entiere%10000000/1000000);
$dix[3]=intval($valeur_entiere%100000000/10000000);
$cent[3]=intval($valeur_entiere%1000000000/100000000);
$chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf');
$secon_c='';
$trio_c='';
for($i=1; $i<=3; $i++){
$prim[$i]='';
$secon[$i]='';
$trio[$i]='';
if($dix[$i]==0){
$secon[$i]='';
$prim[$i]=$chif[$unite[$i]];
}
else if($dix[$i]==1){
$secon[$i]='';
$prim[$i]=$chif[($unite[$i]+10)];
}
else if($dix[$i]==2){
if($unite[$i]==1){
$secon[$i]='vingt et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='vingt';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==3){
if($unite[$i]==1){
$secon[$i]='trente et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='trente';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==4){
if($unite[$i]==1){
$secon[$i]='quarante et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='quarante';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==5){
if($unite[$i]==1){
$secon[$i]='cinquante et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='cinquante';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==6){
if($unite[$i]==1){
$secon[$i]='soixante et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='soixante';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==7){
if($unite[$i]==1){
$secon[$i]='soixante et';
$prim[$i]=$chif[$unite[$i]+10];
}
else {
$secon[$i]='soixante';
$prim[$i]=$chif[$unite[$i]+10];
}
}
else if($dix[$i]==8){
if($unite[$i]==1){
$secon[$i]='quatre-vingts et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='quatre-vingt';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==9){
if($unite[$i]==1){
$secon[$i]='quatre-vingts et';
$prim[$i]=$chif[$unite[$i]+10];
}
else {
$secon[$i]='quatre-vingts';
$prim[$i]=$chif[$unite[$i]+10];
}
}
if($cent[$i]==1) $trio[$i]='cent';
else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents';
}
if(empty($devise1)) $dev1='euros';
else $dev1=$devise1;
if(empty($devise2)) $dev2='centimes';
else $dev2=$devise2;
$valeur_entiere=intval($montant);
$valeur_decimal=intval(round($montant-intval($montant), 2)*100);
$dix_c=intval($valeur_decimal%100/10);
$cent_c=intval($valeur_decimal%1000/100);
$unite[1]=$valeur_entiere%10;
$dix[1]=intval($valeur_entiere%100/10);
$cent[1]=intval($valeur_entiere%1000/100);
$unite[2]=intval($valeur_entiere%10000/1000);
$dix[2]=intval($valeur_entiere%100000/10000);
$cent[2]=intval($valeur_entiere%1000000/100000);
$unite[3]=intval($valeur_entiere%10000000/1000000);
$dix[3]=intval($valeur_entiere%100000000/10000000);
$cent[3]=intval($valeur_entiere%1000000000/100000000);
$chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf');
$secon_c='';
$trio_c='';
for($i=1; $i<=3; $i++){
$prim[$i]='';
$secon[$i]='';
$trio[$i]='';
if($dix[$i]==0){
$secon[$i]='';
$prim[$i]=$chif[$unite[$i]];
}
else if($dix[$i]==1){
$secon[$i]='';
$prim[$i]=$chif[($unite[$i]+10)];
}
else if($dix[$i]==2){
if($unite[$i]==1){
$secon[$i]='vingt et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='vingt';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==3){
if($unite[$i]==1){
$secon[$i]='trente et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='trente';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==4){
if($unite[$i]==1){
$secon[$i]='quarante et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='quarante';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==5){
if($unite[$i]==1){
$secon[$i]='cinquante et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='cinquante';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==6){
if($unite[$i]==1){
$secon[$i]='soixante et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='soixante';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==7){
if($unite[$i]==1){
$secon[$i]='soixante et';
$prim[$i]=$chif[$unite[$i]+10];
}
else {
$secon[$i]='soixante';
$prim[$i]=$chif[$unite[$i]+10];
}
}
else if($dix[$i]==8){
if($unite[$i]==1){
$secon[$i]='quatre-vingts et';
$prim[$i]=$chif[$unite[$i]];
}
else {
$secon[$i]='quatre-vingt';
$prim[$i]=$chif[$unite[$i]];
}
}
else if($dix[$i]==9){
if($unite[$i]==1){
$secon[$i]='quatre-vingts et';
$prim[$i]=$chif[$unite[$i]+10];
}
else {
$secon[$i]='quatre-vingts';
$prim[$i]=$chif[$unite[$i]+10];
}
}
if($cent[$i]==1) $trio[$i]='cent';
else if($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents';
}
$chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix');
$secon_c=$chif2[$dix_c];
if($cent_c==1) $trio_c='cent';
else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents';
$secon_c=$chif2[$dix_c];
if($cent_c==1) $trio_c='cent';
else if($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents';
if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1))
$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million ';
else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!=''))
$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions ';
else
$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3];
if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1))
$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million ';
else if(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!=''))
$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions ';
else
$somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3];
if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1))
$somme = $somme.' mille ';
else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!=''))
$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles ';
else
$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2];
if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1))
$somme = $somme.' mille ';
else if(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!=''))
$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles ';
else
$somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2];
$somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1];
$somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1];
$somme = $somme. ' '. $dev1 .' ' ;
$somme = $somme. ' '. $dev1 .' ' ;
if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c==''))
return $somme. ' et z&eacute;ro '. $dev2;
else
return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2;
if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c==''))
return $somme. ' et z&eacute;ro '. $dev2;
else
return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2;
}

View File

@ -35,18 +35,18 @@ class InterfaceNotification extends DolibarrTriggers
public $version = self::VERSION_DOLIBARR;
public $picto = 'email';
var $listofmanagedevents=array(
'BILL_VALIDATE',
'BILL_PAYED',
'ORDER_VALIDATE',
'PROPAL_VALIDATE',
'PROPAL_CLOSE_SIGNED',
'FICHINTER_VALIDATE',
'FICHINTER_ADD_CONTACT',
'ORDER_SUPPLIER_VALIDATE',
'ORDER_SUPPLIER_APPROVE',
'ORDER_SUPPLIER_REFUSE',
'SHIPPING_VALIDATE'
var $listofmanagedevents=array(
'BILL_VALIDATE',
'BILL_PAYED',
'ORDER_VALIDATE',
'PROPAL_VALIDATE',
'PROPAL_CLOSE_SIGNED',
'FICHINTER_VALIDATE',
'FICHINTER_ADD_CONTACT',
'ORDER_SUPPLIER_VALIDATE',
'ORDER_SUPPLIER_APPROVE',
'ORDER_SUPPLIER_REFUSE',
'SHIPPING_VALIDATE'
);
/**
@ -74,62 +74,62 @@ class InterfaceNotification extends DolibarrTriggers
$notify->send($action, $object);
return 1;
}
}
/**
* Return list of events managed by notification module
*
* @return array Array of events managed by notification module
*/
function getListOfManagedEvents()
{
global $conf;
/**
* Return list of events managed by notification module
*
* @return array Array of events managed by notification module
*/
function getListOfManagedEvents()
{
global $conf;
$ret=array();
$ret=array();
$sql = "SELECT rowid, code, label, description, elementtype";
$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
$sql.= $this->db->order("rang, elementtype, code");
dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj=$this->db->fetch_object($resql);
$sql = "SELECT rowid, code, label, description, elementtype";
$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
$sql.= $this->db->order("rang, elementtype, code");
dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj=$this->db->fetch_object($resql);
$qualified=0;
// Check is this event is supported by notification module
if (in_array($obj->code,$this->listofmanagedevents)) $qualified=1;
// Check if module for this event is active
if ($qualified)
{
//print 'xx'.$obj->code;
$element=$obj->elementtype;
$qualified=0;
// Check is this event is supported by notification module
if (in_array($obj->code,$this->listofmanagedevents)) $qualified=1;
// Check if module for this event is active
if ($qualified)
{
//print 'xx'.$obj->code;
$element=$obj->elementtype;
// Exclude events if related module is disabled
if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0;
elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0;
elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0;
elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member')) && empty($conf->$element->enabled)) $qualified=0;
}
// Exclude events if related module is disabled
if ($element == 'order_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
elseif ($element == 'invoice_supplier' && empty($conf->fournisseur->enabled)) $qualified=0;
elseif ($element == 'withdraw' && empty($conf->prelevement->enabled)) $qualified=0;
elseif ($element == 'shipping' && empty($conf->expedition->enabled)) $qualified=0;
elseif ($element == 'member' && empty($conf->adherent->enabled)) $qualified=0;
elseif (! in_array($element,array('order_supplier','invoice_supplier','withdraw','shipping','member')) && empty($conf->$element->enabled)) $qualified=0;
}
if ($qualified)
{
$ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
}
if ($qualified)
{
$ret[]=array('rowid'=>$obj->rowid,'code'=>$obj->code,'label'=>$obj->label,'description'=>$obj->description,'elementtype'=>$obj->elementtype);
}
$i++;
}
}
else dol_print_error($this->db);
$i++;
}
}
else dol_print_error($this->db);
return $ret;
}
return $ret;
}
}

View File

@ -88,7 +88,7 @@ class EcmFiles //extends CommonObject
*/
public function create(User $user, $notrigger = false)
{
global $conf;
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
@ -140,25 +140,25 @@ class EcmFiles //extends CommonObject
if (isset($this->acl)) {
$this->acl = trim($this->acl);
}
if (empty($this->date_c)) $this->date_c = dol_now();
if (empty($this->date_c)) $this->date_c = dol_now();
// If ref not defined
$ref = dol_hash($this->filepath.'/'.$this->filename, 3);
// If ref not defined
$ref = dol_hash($this->filepath.'/'.$this->filename, 3);
if (! empty($this->ref)) $ref=$this->ref;
$maxposition=0;
$maxposition=0;
if (empty($this->position)) // Get max used
{
$sql = "SELECT MAX(position) as maxposition FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql.= " WHERE filepath ='".$this->db->escape($this->filepath)."'";
$sql = "SELECT MAX(position) as maxposition FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql.= " WHERE filepath ='".$this->db->escape($this->filepath)."'";
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
$maxposition = (int) $obj->maxposition;
}
else dol_print_error($this->db);
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
$maxposition = (int) $obj->maxposition;
}
else dol_print_error($this->db);
}
$maxposition=$maxposition+1;
@ -217,7 +217,7 @@ class EcmFiles //extends CommonObject
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
$this->position = $maxposition;
$this->position = $maxposition;
if (!$notrigger) {
// Uncomment this and change MYOBJECT to your own tag if you
@ -408,7 +408,7 @@ class EcmFiles //extends CommonObject
$sql .= $this->db->order($sortfield,$sortorder);
}
if (!empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit, $offset);
$sql .= ' ' . $this->db->plimit($limit, $offset);
}
$this->lines = array();
@ -676,49 +676,49 @@ class EcmFiles //extends CommonObject
*
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param string $option On what the link point to
* @param int $notooltip 1=Disable tooltip
* @param int $maxlen Max length of visible user name
* @param string $morecss Add more css on link
* @param int $notooltip 1=Disable tooltip
* @param int $maxlen Max length of visible user name
* @param string $morecss Add more css on link
* @return string String with URL
*/
function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
{
global $db, $conf, $langs;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
$result = '';
$companylink = '';
$result = '';
$companylink = '';
$label = '<u>' . $langs->trans("MyModule") . '</u>';
$label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$label = '<u>' . $langs->trans("MyModule") . '</u>';
$label.= '<br>';
$label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
$url = DOL_URL_ROOT.'/ecm/'.$this->table_name.'_card.php?id='.$this->id;
$url = DOL_URL_ROOT.'/ecm/'.$this->table_name.'_card.php?id='.$this->id;
$linkclose='';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowProject");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
}
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
$linkclose='';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowProject");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
}
else $linkclose = ($morecss?' class="'.$morecss.'"':'');
$linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
if ($withpicto)
{
$result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
if ($withpicto != 2) $result.=' ';
if ($withpicto)
{
$result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
if ($withpicto != 2) $result.=' ';
}
$result.= $linkstart . $this->ref . $linkend;
return $result;
@ -793,7 +793,7 @@ class EcmFiles //extends CommonObject
*/
public function initAsSpecimen()
{
global $conf,$user;
global $conf,$user;
$this->id = 0;

View File

@ -48,7 +48,7 @@ class Expedition extends CommonObject
public $table_element="expedition";
public $table_element_line="expeditiondet";
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto = 'sending';
public $picto = 'sending';
var $socid;
var $ref_customer;
@ -131,29 +131,29 @@ class Expedition extends CommonObject
global $langs, $conf;
$langs->load("sendings");
if (!empty($conf->global->EXPEDITION_ADDON_NUMBER))
{
if (!empty($conf->global->EXPEDITION_ADDON_NUMBER))
{
$mybool = false;
$file = $conf->global->EXPEDITION_ADDON_NUMBER.".php";
$classname = $conf->global->EXPEDITION_ADDON_NUMBER;
// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/expedition/");
$dir = dol_buildpath($reldir."core/modules/expedition/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
}
if (! $mybool)
{
dol_print_error('',"Failed to include file ".$file);
return '';
}
if (! $mybool)
{
dol_print_error('',"Failed to include file ".$file);
return '';
}
$obj = new $classname();
$numref = "";
@ -168,19 +168,19 @@ class Expedition extends CommonObject
dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
return "";
}
}
else
{
print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined");
return "";
}
}
else
{
print $langs->trans("Error")." ".$langs->trans("Error_EXPEDITION_ADDON_NUMBER_NotDefined");
return "";
}
}
/**
* Create expedition en base
*
* @param User $user Objet du user qui cree
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 si erreur, id expedition creee si ok
*/
function create($user, $notrigger=0)
@ -249,8 +249,8 @@ class Expedition extends CommonObject
$sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null");
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@ -315,10 +315,10 @@ class Expedition extends CommonObject
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('SHIPPING_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('SHIPPING_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
if (! $error)
{
@ -393,7 +393,7 @@ class Expedition extends CommonObject
$resql = $this->db->query($sql);
if ($resql)
{
$line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet");
$line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet");
}
else
{
@ -471,7 +471,7 @@ class Expedition extends CommonObject
* @param int $id Id of object to load
* @param string $ref Ref of object
* @param string $ref_ext External reference of object
* @param string $ref_int Internal reference of other object
* @param string $ref_int Internal reference of other object
* @return int >0 if OK, 0 if not found, <0 if KO
*/
function fetch($id, $ref='', $ref_ext='', $ref_int='')
@ -487,16 +487,16 @@ class Expedition extends CommonObject
$sql.= ", e.fk_shipping_method, e.tracking_number";
$sql.= ", el.fk_source as origin_id, el.sourcetype as origin";
$sql.= ", e.note_private, e.note_public";
$sql.= ', e.fk_incoterms, e.location_incoterms';
$sql.= ', i.libelle as libelle_incoterms';
$sql.= ', e.fk_incoterms, e.location_incoterms';
$sql.= ', i.libelle as libelle_incoterms';
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'";
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid';
$sql.= " WHERE e.entity IN (".getEntity('expedition').")";
if ($id) $sql.= " AND e.rowid=".$id;
if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'";
if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'";
if ($ref_int) $sql.= " AND e.ref_int='".$this->db->escape($ref_int)."'";
if ($ref) $sql.= " AND e.ref='".$this->db->escape($ref)."'";
if ($ref_ext) $sql.= " AND e.ref_ext='".$this->db->escape($ref_ext)."'";
if ($ref_int) $sql.= " AND e.ref_int='".$this->db->escape($ref_int)."'";
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
@ -600,14 +600,14 @@ class Expedition extends CommonObject
* Validate object and update stock if option enabled
*
* @param User $user Object user that validate
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if OK, >0 if KO
*/
function valid($user, $notrigger=0)
{
global $conf, $langs;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_syslog(get_class($this)."::valid");
@ -618,8 +618,8 @@ class Expedition extends CommonObject
return 0;
}
if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate))))
if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->expedition->shipping_advance->validate))))
{
$this->error='Permission denied';
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
@ -646,7 +646,7 @@ class Expedition extends CommonObject
{
$numref = "EXP".$this->id;
}
$this->newref = $numref;
$this->newref = $numref;
$now=dol_now();
@ -725,7 +725,7 @@ class Expedition extends CommonObject
// line with batch detail
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record.
// Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version)
// Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version)
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock);
if ($result < 0) {
$error++;
@ -748,22 +748,22 @@ class Expedition extends CommonObject
// Change status of order to "shipment in process"
$ret = $this->setStatut(Commande::STATUS_SHIPMENTONPROCESS, $this->origin_id, $this->origin);
if (! $ret)
if (! $ret)
{
$error++;
$error++;
}
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('SHIPPING_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('SHIPPING_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
{
$this->oldref = $this->ref;
$this->oldref = $this->ref;
// Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref))
@ -780,17 +780,17 @@ class Expedition extends CommonObject
if (@rename($dirsource, $dirdest))
{
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles=dol_dir_list($conf->expedition->dir_output.'/sending/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
foreach($listoffiles as $fileentry)
{
$dirsource=$fileentry['name'];
$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
$dirsource=$fileentry['path'].'/'.$dirsource;
$dirdest=$fileentry['path'].'/'.$dirdest;
@rename($dirsource, $dirdest);
}
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles=dol_dir_list($conf->expedition->dir_output.'/sending/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
foreach($listoffiles as $fileentry)
{
$dirsource=$fileentry['name'];
$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
$dirsource=$fileentry['path'].'/'.$dirsource;
$dirdest=$fileentry['path'].'/'.$dirdest;
@rename($dirsource, $dirdest);
}
}
}
}
@ -812,8 +812,8 @@ class Expedition extends CommonObject
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::valid ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
dol_syslog(get_class($this)."::valid ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
@ -885,14 +885,14 @@ class Expedition extends CommonObject
if (! ($entrepot_id > 0) && empty($conf->global->STOCK_WAREHOUSE_NOT_REQUIRED_FOR_SHIPMENTS))
{
$langs->load("errors");
$langs->load("errors");
$this->error=$langs->trans("ErrorWarehouseRequiredIntoShipmentLine");
return -1;
}
if ($conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT)
{
// Check must be done for stock of product into warehouse if $entrepot_id defined
// Check must be done for stock of product into warehouse if $entrepot_id defined
$product=new Product($this->db);
$result=$product->fetch($fk_product);
@ -906,8 +906,8 @@ class Expedition extends CommonObject
$product_type=$product->type;
if ($product_type == 0 && $product_stock < $qty)
{
$langs->load("errors");
$this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $product->ref);
$langs->load("errors");
$this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $product->ref);
$this->db->rollback();
return -3;
}
@ -917,8 +917,8 @@ class Expedition extends CommonObject
// If product need a batch number, we should not have called this function but addline_batch instead.
if (! empty($conf->productbatch->enabled) && ! empty($orderline->fk_product) && ! empty($orderline->product_tobatch))
{
$this->error='ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH';
return -4;
$this->error='ADDLINE_WAS_CALLED_INSTEAD_OF_ADDLINEBATCH';
return -4;
}
// extrafields
@ -928,7 +928,7 @@ class Expedition extends CommonObject
$this->lines[$num] = $line;
}
/**
/**
* Add a shipment line with batch record
*
* @param array $dbatch Array of value (key 'detail' -> Array, key 'qty' total quantity for line, key ix_l : original line index)
@ -952,7 +952,7 @@ class Expedition extends CommonObject
// $value['id_batch']=id into llx_product_batch of record to move
//var_dump($value);
$linebatch = new ExpeditionLineBatch($this->db);
$linebatch = new ExpeditionLineBatch($this->db);
$ret=$linebatch->fetchFromStock($value['id_batch']); // load serial, sellby, eatby
if ($ret<0)
{
@ -970,8 +970,8 @@ class Expedition extends CommonObject
if ($prod_batch->qty < $linebatch->dluo_qty)
{
$langs->load("errors");
$this->errors[]=$langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $prod_batch->fk_product);
$langs->load("errors");
$this->errors[]=$langs->trans('ErrorStockIsNotEnoughToAddProductOnShipment', $prod_batch->fk_product);
dol_syslog(get_class($this)."::addline_batch error=Product ".$prod_batch->batch.": ".$this->errorsToString(), LOG_ERR);
$this->db->rollback();
return -1;
@ -996,16 +996,16 @@ class Expedition extends CommonObject
}
}
/**
* Update database
*
* @param User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user=null, $notrigger=0)
{
global $conf;
/**
* Update database
*
* @param User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user=null, $notrigger=0)
{
global $conf;
$error=0;
// Clean parameters
@ -1035,8 +1035,8 @@ class Expedition extends CommonObject
// Check parameters
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET";
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
@ -1063,32 +1063,32 @@ class Expedition extends CommonObject
$sql.= " model_pdf=".(isset($this->modelpdf)?"'".$this->db->escape($this->modelpdf)."'":"null").",";
$sql.= " entity=".$conf->entity;
$sql.= " WHERE rowid=".$this->id;
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('SHIPPING_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
// Call trigger
$result=$this->call_trigger('SHIPPING_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
}
// Commit or rollback
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
@ -1098,7 +1098,7 @@ class Expedition extends CommonObject
$this->db->commit();
return 1;
}
}
}
/**
* Delete shipment.
@ -1231,18 +1231,18 @@ class Expedition extends CommonObject
if (! empty($this->origin) && $this->origin_id > 0)
{
$this->fetch_origin();
$origin=$this->origin;
if ($this->$origin->statut == Commande::STATUS_SHIPMENTONPROCESS) // If order source of shipment is "shipment in progress"
{
// Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress"
$this->$origin->loadExpeditions();
//var_dump($this->$origin->expeditions);exit;
if (count($this->$origin->expeditions) <= 0)
{
$this->$origin->setStatut(Commande::STATUS_VALIDATED);
}
}
$this->fetch_origin();
$origin=$this->origin;
if ($this->$origin->statut == Commande::STATUS_SHIPMENTONPROCESS) // If order source of shipment is "shipment in progress"
{
// Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress"
$this->$origin->loadExpeditions();
//var_dump($this->$origin->expeditions);exit;
if (count($this->$origin->expeditions) <= 0)
{
$this->$origin->setStatut(Commande::STATUS_VALIDATED);
}
}
}
if (! $error)
@ -1354,13 +1354,13 @@ class Expedition extends CommonObject
{
$obj = $this->db->fetch_object($resql);
if ($originline == $obj->fk_origin_line) {
$line->entrepot_id = 0; // entrepod_id in details_entrepot
$line->qty_shipped += $obj->qty_shipped;
if ($originline == $obj->fk_origin_line) {
$line->entrepot_id = 0; // entrepod_id in details_entrepot
$line->qty_shipped += $obj->qty_shipped;
} else {
$line = new ExpeditionLigne($this->db);
$line->entrepot_id = $obj->fk_entrepot;
$line->qty_shipped = $obj->qty_shipped;
$line = new ExpeditionLigne($this->db);
$line->entrepot_id = $obj->fk_entrepot;
$line->qty_shipped = $obj->qty_shipped;
}
$detail_entrepot = new stdClass;
@ -1368,13 +1368,13 @@ class Expedition extends CommonObject
$detail_entrepot->qty_shipped = $obj->qty_shipped;
$line->details_entrepot[] = $detail_entrepot;
$line->line_id = $obj->line_id;
$line->rowid = $obj->line_id; // TODO deprecated
$line->id = $obj->line_id;
$line->line_id = $obj->line_id;
$line->rowid = $obj->line_id; // TODO deprecated
$line->id = $obj->line_id;
$line->fk_origin = 'orderline';
$line->fk_origin_line = $obj->fk_origin_line;
$line->origin_line_id = $obj->fk_origin_line; // TODO deprecated
$line->fk_origin = 'orderline';
$line->fk_origin_line = $obj->fk_origin_line;
$line->origin_line_id = $obj->fk_origin_line; // TODO deprecated
$line->fk_expedition = $this->id; // id of parent
@ -1382,8 +1382,8 @@ class Expedition extends CommonObject
$line->fk_product = $obj->fk_product;
$line->fk_product_type = $obj->fk_product_type;
$line->ref = $obj->product_ref; // TODO deprecated
$line->product_ref = $obj->product_ref;
$line->product_label = $obj->product_label;
$line->product_ref = $obj->product_ref;
$line->product_label = $obj->product_label;
$line->libelle = $obj->product_label; // TODO deprecated
$line->product_tobatch = $obj->product_tobatch;
$line->label = $obj->custom_label;
@ -1440,34 +1440,34 @@ class Expedition extends CommonObject
// Eat-by date
if (! empty($conf->productbatch->enabled) && $obj->line_id > 0)
{
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php';
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expeditionbatch.class.php';
$newdetailbatch = ExpeditionLineBatch::fetchAll($this->db,$obj->line_id);
if (is_array($newdetailbatch))
{
if ($originline != $obj->fk_origin_line)
{
$line->detail_batch = $newdetailbatch;
}
else
$newdetailbatch = ExpeditionLineBatch::fetchAll($this->db,$obj->line_id);
if (is_array($newdetailbatch))
{
if ($originline != $obj->fk_origin_line)
{
$line->detail_batch = array_merge($line->detail_batch, $newdetailbatch);
}
}
$line->detail_batch = $newdetailbatch;
}
else
{
$line->detail_batch = array_merge($line->detail_batch, $newdetailbatch);
}
}
}
if ($originline != $obj->fk_origin_line)
{
$this->lines[$lineindex] = $line;
$lineindex++;
$this->lines[$lineindex] = $line;
$lineindex++;
}
else
{
$line->total_ht += $tabprice[0];
$line->total_localtax1 += $tabprice[9];
$line->total_localtax2 += $tabprice[10];
$line->total_ttc += $tabprice[2];
$line->total_tva += $tabprice[1];
$line->total_ht += $tabprice[0];
$line->total_localtax1 += $tabprice[9];
$line->total_localtax2 += $tabprice[10];
$line->total_ttc += $tabprice[2];
$line->total_tva += $tabprice[1];
}
$i++;
@ -1484,24 +1484,24 @@ class Expedition extends CommonObject
}
/**
* Return clicable link of object (with eventually picto)
*
* @param int $withpicto Add picto into link
* @param string $option Where the link point to
* @param int $max Max length to show
* @param int $short Use short labels
* @param int $notooltip 1=No tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL
*/
* Return clicable link of object (with eventually picto)
*
* @param int $withpicto Add picto into link
* @param string $option Where the link point to
* @param int $max Max length to show
* @param int $short Use short labels
* @param int $notooltip 1=No tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL
*/
function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1)
{
global $langs;
$result='';
$label = '<u>' . $langs->trans("ShowSending") . '</u>';
$label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref;
$label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.($this->ref_customer ? $this->ref_customer : $this->ref_client);
$label = '<u>' . $langs->trans("ShowSending") . '</u>';
$label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref;
$label .= '<br><b>'.$langs->trans('RefCustomer').':</b> '.($this->ref_customer ? $this->ref_customer : $this->ref_client);
$url = DOL_URL_ROOT.'/expedition/card.php?id='.$this->id;
@ -1518,16 +1518,16 @@ class Expedition extends CommonObject
$linkclose='';
if (empty($notooltip))
{
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowSending");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"';
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label=$langs->trans("ShowSending");
$linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"';
}
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
$picto='sending';
@ -1539,11 +1539,11 @@ class Expedition extends CommonObject
}
/**
* Return status label
*
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto
* @return string Libelle
*/
* Return status label
*
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto
* @return string Libelle
*/
function getLibStatut($mode=0)
{
return $this->LibStatut($this->statut,$mode);
@ -1593,11 +1593,11 @@ class Expedition extends CommonObject
}
/**
* Initialise an instance with random values.
* Used to build previews or test instances.
* id must be 0 if object instance is a specimen.
*
* @return void
* Initialise an instance with random values.
* Used to build previews or test instances.
* id must be 0 if object instance is a specimen.
*
* @return void
*/
function initAsSpecimen()
{
@ -1607,7 +1607,7 @@ class Expedition extends CommonObject
dol_syslog(get_class($this)."::initAsSpecimen");
// Load array of products prodids
// Load array of products prodids
$num_prods = 0;
$prodids = array();
$sql = "SELECT rowid";
@ -1648,11 +1648,11 @@ class Expedition extends CommonObject
$this->commande_id = 0;
$this->commande = $order;
$this->origin_id = 1;
$this->origin = 'commande';
$this->origin_id = 1;
$this->origin = 'commande';
$this->note_private = 'Private note';
$this->note_public = 'Public note';
$this->note_private = 'Private note';
$this->note_public = 'Public note';
$nbp = 5;
$xnbp = 0;
@ -1732,99 +1732,99 @@ class Expedition extends CommonObject
}
}
/**
* Fetch all deliveries method and return an array. Load array this->listmeths.
*
* @param id $id only this carrier, all if none
* @return void
*/
function list_delivery_methods($id='')
{
global $langs;
/**
* Fetch all deliveries method and return an array. Load array this->listmeths.
*
* @param id $id only this carrier, all if none
* @return void
*/
function list_delivery_methods($id='')
{
global $langs;
$this->listmeths = array();
$i=0;
$this->listmeths = array();
$i=0;
$sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em";
if ($id!='') $sql.= " WHERE em.rowid=".$id;
$sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em";
if ($id!='') $sql.= " WHERE em.rowid=".$id;
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
$this->listmeths[$i]['rowid'] = $obj->rowid;
$this->listmeths[$i]['code'] = $obj->code;
$label=$langs->trans('SendingMethod'.$obj->code);
$this->listmeths[$i]['libelle'] = ($label != 'SendingMethod'.$obj->code?$label:$obj->libelle);
$this->listmeths[$i]['description'] = $obj->description;
$this->listmeths[$i]['tracking'] = $obj->tracking;
$this->listmeths[$i]['active'] = $obj->active;
$i++;
}
}
}
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
$this->listmeths[$i]['rowid'] = $obj->rowid;
$this->listmeths[$i]['code'] = $obj->code;
$label=$langs->trans('SendingMethod'.$obj->code);
$this->listmeths[$i]['libelle'] = ($label != 'SendingMethod'.$obj->code?$label:$obj->libelle);
$this->listmeths[$i]['description'] = $obj->description;
$this->listmeths[$i]['tracking'] = $obj->tracking;
$this->listmeths[$i]['active'] = $obj->active;
$i++;
}
}
}
/**
* Update/create delivery method.
*
* @param string $id id method to activate
*
* @return void
*/
function update_delivery_method($id='')
{
if ($id=='')
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)";
$sql.=" VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')";
$resql = $this->db->query($sql);
}
else
{
$sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET";
$sql.= " code='".$this->db->escape($this->update['code'])."'";
$sql.= ",libelle='".$this->db->escape($this->update['libelle'])."'";
$sql.= ",description='".$this->db->escape($this->update['description'])."'";
$sql.= ",tracking='".$this->db->escape($this->update['tracking'])."'";
$sql.= " WHERE rowid=".$id;
$resql = $this->db->query($sql);
}
if ($resql < 0) dol_print_error($this->db,'');
}
/**
* Update/create delivery method.
*
* @param string $id id method to activate
*
* @return void
*/
function update_delivery_method($id='')
{
if ($id=='')
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)";
$sql.=" VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')";
$resql = $this->db->query($sql);
}
else
{
$sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET";
$sql.= " code='".$this->db->escape($this->update['code'])."'";
$sql.= ",libelle='".$this->db->escape($this->update['libelle'])."'";
$sql.= ",description='".$this->db->escape($this->update['description'])."'";
$sql.= ",tracking='".$this->db->escape($this->update['tracking'])."'";
$sql.= " WHERE rowid=".$id;
$resql = $this->db->query($sql);
}
if ($resql < 0) dol_print_error($this->db,'');
}
/**
* Activate delivery method.
*
* @param id $id id method to activate
*
* @return void
*/
function activ_delivery_method($id)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1';
$sql.= ' WHERE rowid='.$id;
/**
* Activate delivery method.
*
* @param id $id id method to activate
*
* @return void
*/
function activ_delivery_method($id)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1';
$sql.= ' WHERE rowid='.$id;
$resql = $this->db->query($sql);
$resql = $this->db->query($sql);
}
}
/**
* DesActivate delivery method.
*
* @param id $id id method to desactivate
*
* @return void
*/
function disable_delivery_method($id)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0';
$sql.= ' WHERE rowid='.$id;
/**
* DesActivate delivery method.
*
* @param id $id id method to desactivate
*
* @return void
*/
function disable_delivery_method($id)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0';
$sql.= ' WHERE rowid='.$id;
$resql = $this->db->query($sql);
$resql = $this->db->query($sql);
}
}
/**
@ -1959,8 +1959,8 @@ class Expedition extends CommonObject
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr",$numref));
if ($result < 0) {
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
$error++; break;
}
}
@ -1971,9 +1971,9 @@ class Expedition extends CommonObject
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentClassifyClosedInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock);
if ($result < 0) {
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
$error++; break;
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
$error++; break;
}
}
}
@ -1988,27 +1988,27 @@ class Expedition extends CommonObject
// Call trigger
if (! $error)
{
$result=$this->call_trigger('SHIPPING_CLOSED',$user);
if ($result < 0) {
$error++;
}
$result=$this->call_trigger('SHIPPING_CLOSED',$user);
if ($result < 0) {
$error++;
}
}
}
else
{
dol_print_error($this->db);
$error++;
$error++;
}
if (! $error)
{
$this->db->commit();
return 1;
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
return -1;
$this->db->rollback();
return -1;
}
}
@ -2019,7 +2019,7 @@ class Expedition extends CommonObject
*/
function set_billed()
{
global $user;
global $user;
$error=0;
$this->db->begin();
@ -2125,8 +2125,8 @@ class Expedition extends CommonObject
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr",$numref));
if ($result < 0) {
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
$error++; break;
}
}
@ -2137,9 +2137,9 @@ class Expedition extends CommonObject
// We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
$result=$mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ShipmentUnClassifyCloseddInDolibarr",$numref), '', $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, $obj->fk_origin_stock);
if ($result < 0) {
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
$error++; break;
$this->error = $mouvS->error;
$this->errors = $mouvS->errors;
$error++; break;
}
}
}
@ -2153,11 +2153,11 @@ class Expedition extends CommonObject
if (! $error)
{
// Call trigger
$result=$this->call_trigger('SHIPPING_REOPEN',$user);
if ($result < 0) {
$error++;
}
// Call trigger
$result=$this->call_trigger('SHIPPING_REOPEN',$user);
if ($result < 0) {
$error++;
}
}
} else {
@ -2280,11 +2280,11 @@ class ExpeditionLigne extends CommonObjectLine
*/
var $libelle;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db=$db;

View File

@ -38,7 +38,7 @@ class Fichinter extends CommonObject
public $table_element='fichinter';
public $fk_element='fk_fichinter';
public $table_element_line='fichinterdet';
public $picto = 'intervention';
public $picto = 'intervention';
/**
* {@inheritdoc}
@ -83,7 +83,7 @@ class Fichinter extends CommonObject
* Constructor
*
* @param DoliDB $db Database handler
*/
*/
function __construct($db)
{
$this->db = $db;
@ -152,7 +152,7 @@ class Fichinter extends CommonObject
* Create an intervention into data base
*
* @param User $user Objet user that make creation
* @param int $notrigger Disable all triggers
* @param int $notrigger Disable all triggers
* @return int <0 if KO, >0 if OK
*/
function create($user, $notrigger=0)
@ -237,13 +237,13 @@ class Fichinter extends CommonObject
}
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
// Add linked object
if (! $error && $this->origin && $this->origin_id)
@ -253,13 +253,13 @@ class Fichinter extends CommonObject
}
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('FICHINTER_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('FICHINTER_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
{
@ -287,7 +287,7 @@ class Fichinter extends CommonObject
* Update an intervention
*
* @param User $user Objet user that make creation
* @param int $notrigger Disable all triggers
* @param int $notrigger Disable all triggers
* @return int <0 if KO, >0 if OK
*/
function update($user, $notrigger=0)
@ -316,10 +316,10 @@ class Fichinter extends CommonObject
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('FICHINTER_MODIFY',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
// Call trigger
$result=$this->call_trigger('FICHINTER_MODIFY',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
}
$this->db->commit();
@ -446,7 +446,7 @@ class Fichinter extends CommonObject
* Validate a intervention
*
* @param User $user User that validate
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, >0 if OK
*/
function setValid($user, $notrigger=0)
@ -471,7 +471,7 @@ class Fichinter extends CommonObject
{
$num = $this->ref;
}
$this->newref = $num;
$this->newref = $num;
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
$sql.= " SET fk_statut = 1";
@ -492,10 +492,10 @@ class Fichinter extends CommonObject
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('FICHINTER_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('FICHINTER_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
@ -517,17 +517,17 @@ class Fichinter extends CommonObject
if (@rename($dirsource, $dirdest))
{
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles=dol_dir_list($conf->ficheinter->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
foreach($listoffiles as $fileentry)
{
$dirsource=$fileentry['name'];
$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
$dirsource=$fileentry['path'].'/'.$dirsource;
$dirdest=$fileentry['path'].'/'.$dirdest;
@rename($dirsource, $dirdest);
}
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles=dol_dir_list($conf->ficheinter->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
foreach($listoffiles as $fileentry)
{
$dirsource=$fileentry['name'];
$dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
$dirsource=$fileentry['path'].'/'.$dirsource;
$dirdest=$fileentry['path'].'/'.$dirdest;
@rename($dirsource, $dirdest);
}
}
}
}
@ -647,7 +647,7 @@ class Fichinter extends CommonObject
if ($mode == 5)
return '<span class="hideonsmartphone">'.$langs->trans($this->statuts_short[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
if ($mode == 6)
return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
return '<span class="hideonsmartphone">'.$langs->trans($this->statuts[$statut]).' </span>'.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]);
return '';
}
@ -657,8 +657,8 @@ class Fichinter extends CommonObject
*
* @param int $withpicto 0=_No picto, 1=Includes the picto in the linkn, 2=Picto only
* @param string $option Options
* @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL
*/
function getNomUrl($withpicto=0, $option='', $notooltip=0, $save_lastsearch_value=-1)
@ -667,20 +667,20 @@ class Fichinter extends CommonObject
$result='';
$label = '<u>' . $langs->trans("ShowIntervention") . '</u>';
if (! empty($this->ref))
$label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref;
$label = '<u>' . $langs->trans("ShowIntervention") . '</u>';
if (! empty($this->ref))
$label .= '<br><b>' . $langs->trans('Ref') . ':</b> '.$this->ref;
$picto='intervention';
$url = DOL_URL_ROOT.'/fichinter/card.php?id='.$this->id;
$picto='intervention';
$url = DOL_URL_ROOT.'/fichinter/card.php?id='.$this->id;
if ($option !== 'nolink')
{
// Add param to save lastsearch_values or not
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
}
if ($option !== 'nolink')
{
// Add param to save lastsearch_values or not
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
}
$linkclose='';
if (empty($notooltip))
@ -698,7 +698,7 @@ class Fichinter extends CommonObject
$linkstart.=$linkclose.'>';
$linkend='</a>';
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$linkstart.$this->ref.$linkend;
return $result;
@ -833,7 +833,7 @@ class Fichinter extends CommonObject
function delete($user, $notrigger=0)
{
global $conf,$langs;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error=0;
@ -899,10 +899,10 @@ class Fichinter extends CommonObject
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('FICHINTER_DELETE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
// Call trigger
$result=$this->call_trigger('FICHINTER_DELETE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
}
$this->db->commit();
@ -1024,98 +1024,98 @@ class Fichinter extends CommonObject
/**
* Load an object from its id and create a new one in database
*
* @param int $socid Id of thirdparty
* @return int New id of clone
*/
function createFromClone($socid=0)
{
global $user,$hookmanager;
/**
* Load an object from its id and create a new one in database
*
* @param int $socid Id of thirdparty
* @return int New id of clone
*/
function createFromClone($socid=0)
{
global $user,$hookmanager;
$error=0;
$error=0;
$this->context['createfromclone'] = 'createfromclone';
$this->context['createfromclone'] = 'createfromclone';
$this->db->begin();
$this->db->begin();
// get extrafields so they will be clone
foreach($this->lines as $line)
$line->fetch_optionals($line->rowid);
// Load source object
$objFrom = clone $this;
// Load source object
$objFrom = clone $this;
// Change socid if needed
if (! empty($socid) && $socid != $this->socid)
{
$objsoc = new Societe($this->db);
// Change socid if needed
if (! empty($socid) && $socid != $this->socid)
{
$objsoc = new Societe($this->db);
if ($objsoc->fetch($socid)>0)
{
$this->socid = $objsoc->id;
//$this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
//$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
$this->fk_project = '';
$this->fk_delivery_address = '';
}
if ($objsoc->fetch($socid)>0)
{
$this->socid = $objsoc->id;
//$this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
//$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
$this->fk_project = '';
$this->fk_delivery_address = '';
}
// TODO Change product price if multi-prices
}
// TODO Change product price if multi-prices
}
$this->id=0;
$this->id=0;
$this->ref = '';
$this->statut=0;
$this->statut=0;
// Clear fields
$this->user_author_id = $user->id;
$this->user_valid = '';
$this->date_creation = '';
$this->date_validation = '';
$this->ref_client = '';
// Clear fields
$this->user_author_id = $user->id;
$this->user_valid = '';
$this->date_creation = '';
$this->date_validation = '';
$this->ref_client = '';
// Create clone
$result=$this->create($user);
if ($result < 0) $error++;
// Create clone
$result=$this->create($user);
if ($result < 0) $error++;
if (! $error)
{
// Add lines because it is not included into create function
foreach ($this->lines as $line)
{
$this->addline($user, $this->id, $line->desc, $line->datei, $line->duration);
}
if (! $error)
{
// Add lines because it is not included into create function
foreach ($this->lines as $line)
{
$this->addline($user, $this->id, $line->desc, $line->datei, $line->duration);
}
// Hook of thirdparty module
if (is_object($hookmanager))
{
$parameters=array('objFrom'=>$objFrom);
$action='';
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}
// Hook of thirdparty module
if (is_object($hookmanager))
{
$parameters=array('objFrom'=>$objFrom);
$action='';
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}
// Call trigger
$result=$this->call_trigger('INTERVENTION_CLONE',$user);
if ($result < 0) $error++;
// End call triggers
}
// Call trigger
$result=$this->call_trigger('INTERVENTION_CLONE',$user);
if ($result < 0) $error++;
// End call triggers
}
unset($this->context['createfromclone']);
unset($this->context['createfromclone']);
// End
if (! $error)
{
$this->db->commit();
return $this->id;
}
else
{
$this->db->rollback();
return -1;
}
}
// End
if (! $error)
{
$this->db->commit();
return $this->id;
}
else
{
$this->db->rollback();
return -1;
}
}
/**
@ -1338,7 +1338,7 @@ class FichinterLigne extends CommonObjectLine
* Insert the line into database
*
* @param User $user Objet user that make creation
* @param int $notrigger Disable all triggers
* @param int $notrigger Disable all triggers
* @return int <0 if ko, >0 if ok
*/
function insert($user, $notrigger=0)
@ -1386,14 +1386,14 @@ class FichinterLigne extends CommonObjectLine
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$this->id=$this->rowid;
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
{
$this->id=$this->rowid;
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
$result=$this->update_total();
@ -1404,10 +1404,10 @@ class FichinterLigne extends CommonObjectLine
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('LINEFICHINTER_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('LINEFICHINTER_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
}
@ -1434,7 +1434,7 @@ class FichinterLigne extends CommonObjectLine
* Update intervention into database
*
* @param User $user Objet user that make creation
* @param int $notrigger Disable all triggers
* @param int $notrigger Disable all triggers
* @return int <0 if ko, >0 if ok
*/
function update($user,$notrigger=0)
@ -1457,14 +1457,14 @@ class FichinterLigne extends CommonObjectLine
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$this->id=$this->rowid;
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
{
$this->id=$this->rowid;
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
$result=$this->update_total();
if ($result > 0)
@ -1472,10 +1472,10 @@ class FichinterLigne extends CommonObjectLine
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('LINEFICHINTER_UPDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('LINEFICHINTER_UPDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
}
@ -1555,7 +1555,7 @@ class FichinterLigne extends CommonObjectLine
* Delete a intervention line
*
* @param User $user Objet user that make creation
* @param int $notrigger Disable all triggers
* @param int $notrigger Disable all triggers
* @return int >0 if ok, <0 if ko
*/
function deleteline($user,$notrigger=0)
@ -1577,14 +1577,14 @@ class FichinterLigne extends CommonObjectLine
{
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('LINEFICHINTER_DELETE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
// Call trigger
$result=$this->call_trigger('LINEFICHINTER_DELETE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
}
$this->db->commit();
return $result;
$this->db->commit();
return $result;
}
else
{

File diff suppressed because it is too large Load Diff

View File

@ -34,11 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
*/
class PaiementFourn extends Paiement
{
public $element='payment_supplier';
public $table_element='paiementfourn';
public $picto = 'payment';
public $element='payment_supplier';
public $table_element='paiementfourn';
public $picto = 'payment';
var $statut; //Status of payment. 0 = unvalidated; 1 = validated
var $statut; //Status of payment. 0 = unvalidated; 1 = validated
// fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...)
// fk_paiement dans llx_paiement_facture est le rowid du paiement
@ -74,7 +74,7 @@ class PaiementFourn extends Paiement
*/
function fetch($id, $ref='', $fk_bank='')
{
$error=0;
$error=0;
$sql = 'SELECT p.rowid, p.ref, p.entity, p.datep as dp, p.amount, p.statut, p.fk_bank,';
$sql.= ' c.code as paiement_code, c.libelle as paiement_type,';
@ -210,22 +210,22 @@ class PaiementFourn extends Paiement
if ($resql)
{
// If we want to closed payed invoices
if ($closepaidinvoices)
{
$invoice=new FactureFournisseur($this->db);
$invoice->fetch($facid);
$paiement = $invoice->getSommePaiement();
//$creditnotes=$invoice->getSumCreditNotesUsed();
$creditnotes=0;
//$deposits=$invoice->getSumDepositsUsed();
$deposits=0;
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
if ($remaintopay == 0)
{
$result=$invoice->set_paid($user, '', '');
}
else dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing.");
if ($closepaidinvoices)
{
$invoice=new FactureFournisseur($this->db);
$invoice->fetch($facid);
$paiement = $invoice->getSommePaiement();
//$creditnotes=$invoice->getSumCreditNotesUsed();
$creditnotes=0;
//$deposits=$invoice->getSumDepositsUsed();
$deposits=0;
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
if ($remaintopay == 0)
{
$result=$invoice->set_paid($user, '', '');
}
else dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing.");
}
}
else
@ -243,10 +243,10 @@ class PaiementFourn extends Paiement
if (! $error)
{
// Call trigger
$result=$this->call_trigger('PAYMENT_SUPPLIER_CREATE',$user);
if ($result < 0) $error++;
// End call triggers
// Call trigger
$result=$this->call_trigger('PAYMENT_SUPPLIER_CREATE',$user);
if ($result < 0) $error++;
// End call triggers
}
}
else
@ -265,7 +265,7 @@ class PaiementFourn extends Paiement
if ($totalamount <> 0 && $error == 0) // On accepte les montants negatifs
{
$this->amount=$total;
$this->total=$total;
$this->total=$total;
$this->multicurrency_amount=$mtotal;
$this->db->commit();
dol_syslog('PaiementFourn::Create Ok Total = '.$this->total);
@ -289,7 +289,7 @@ class PaiementFourn extends Paiement
*/
function delete($notrigger=0)
{
global $conf, $user, $langs;
global $conf, $user, $langs;
$bank_line_id = $this->bank_line;
@ -346,30 +346,30 @@ class PaiementFourn extends Paiement
// Supprimer l'ecriture bancaire si paiement lie a ecriture
if ($bank_line_id)
{
$accline = new AccountLine($this->db);
$result=$accline->fetch($bank_line_id);
if ($result > 0) // If result = 0, record not found, we don't try to delete
{
$result=$accline->delete($user);
}
if ($result < 0)
{
$this->error=$accline->error;
$this->db->rollback();
return -4;
}
$accline = new AccountLine($this->db);
$result=$accline->fetch($bank_line_id);
if ($result > 0) // If result = 0, record not found, we don't try to delete
{
$result=$accline->delete($user);
}
if ($result < 0)
{
$this->error=$accline->error;
$this->db->rollback();
return -4;
}
}
if (! $notrigger)
{
// Appel des triggers
$result=$this->call_trigger('PAYMENT_SUPPLIER_DELETE', $user);
if ($result < 0)
{
$this->db->rollback();
return -1;
}
// Fin appel triggers
// Appel des triggers
$result=$this->call_trigger('PAYMENT_SUPPLIER_DELETE', $user);
if ($result < 0)
{
$this->db->rollback();
return -1;
}
// Fin appel triggers
}
$this->db->commit();
@ -466,23 +466,23 @@ class PaiementFourn extends Paiement
}
/**
* Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle
*/
* Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle
*/
function getLibStatut($mode=0)
{
return $this->LibStatut($this->statut,$mode);
}
/**
* Renvoi le libelle d'un statut donne
*
* @param int $status Statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut
*/
* Renvoi le libelle d'un statut donne
*
* @param int $status Statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut
*/
function LibStatut($status,$mode=0)
{
global $langs;
@ -540,19 +540,19 @@ class PaiementFourn extends Paiement
global $langs;
$result='';
$text=$this->ref; // Sometimes ref contains label
if (preg_match('/^\((.*)\)$/i',$text,$reg)) {
// Label generique car entre parentheses. On l'affiche en le traduisant
if ($reg[1]=='paiement') $reg[1]='Payment';
$text=$langs->trans($reg[1]);
}
$label = $langs->trans("ShowPayment").': '.$text;
$text=$this->ref; // Sometimes ref contains label
if (preg_match('/^\((.*)\)$/i',$text,$reg)) {
// Label generique car entre parentheses. On l'affiche en le traduisant
if ($reg[1]=='paiement') $reg[1]='Payment';
$text=$langs->trans($reg[1]);
}
$label = $langs->trans("ShowPayment").': '.$text;
$link = '<a href="'.DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
$link = '<a href="'.DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment"), 'payment', 'class="classfortooltip"').$linkend);
if ($withpicto) $result.=($link.img_object($langs->trans("ShowPayment"), 'payment', 'class="classfortooltip"').$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$link.$text.$linkend;
return $result;
@ -699,13 +699,13 @@ class PaiementFourn extends Paiement
if (empty($modele))
{
return 0;
return 0;
}
else
{
$modelpath = "core/modules/supplier_payment/doc/";
$modelpath = "core/modules/supplier_payment/doc/";
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -54,20 +54,20 @@ $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($co
if ($action == 'setnote' && $user->rights->fournisseur->facture->creer)
{
$db->begin();
$db->begin();
$object->fetch($id);
$result = $object->update_note(GETPOST('note','none'));
if ($result > 0)
{
$db->commit();
$action='';
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$db->rollback();
}
$object->fetch($id);
$result = $object->update_note(GETPOST('note','none'));
if ($result > 0)
{
$db->commit();
$action='';
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$db->rollback();
}
}
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->facture->supprimer)
@ -90,8 +90,8 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisse
}
if ($action == 'confirm_valide' && $confirm == 'yes' &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
)
{
$db->begin();
@ -113,7 +113,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' &&
if ($action == 'setnum_paiement' && ! empty($_POST['num_paiement']))
{
$object->fetch($id);
$res = $object->update_num($_POST['num_paiement']);
$res = $object->update_num($_POST['num_paiement']);
if ($res === 0)
{
setEventMessages($langs->trans('PaymentNumberUpdateSucceeded'), null, 'mesgs');
@ -127,7 +127,7 @@ if ($action == 'setnum_paiement' && ! empty($_POST['num_paiement']))
if ($action == 'setdatep' && ! empty($_POST['datepday']))
{
$object->fetch($id);
$datepaye = dol_mktime(12, 0, 0, $_POST['datepmonth'], $_POST['datepday'], $_POST['datepyear']);
$datepaye = dol_mktime(12, 0, 0, $_POST['datepmonth'], $_POST['datepday'], $_POST['datepyear']);
$res = $object->update_date($datepaye);
if ($res === 0)
{
@ -197,18 +197,18 @@ if ($result > 0)
print '</td></tr>';*/
// Date payment
print '<tr><td class="titlefield" colspan="2">'.$form->editfieldkey("Date",'datep',$object->date,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Date",'datep',$object->date,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'datepicker','',null,$langs->trans('PaymentDateUpdateSucceeded'));
print '</td></tr>';
print '<tr><td class="titlefield" colspan="2">'.$form->editfieldkey("Date",'datep',$object->date,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Date",'datep',$object->date,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'datepicker','',null,$langs->trans('PaymentDateUpdateSucceeded'));
print '</td></tr>';
// Payment mode
$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->type_libelle;
print '<tr><td colspan="2">'.$langs->trans('PaymentMode').'</td><td colspan="3">'.$labeltype.'</td></tr>';
// Payment numero
print '<tr><td colspan="2">'.$form->editfieldkey("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded'));
print '</td></tr>';
print '<tr><td colspan="2">'.$form->editfieldkey("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Numero",'num_paiement',$object->numero,$object,$object->statut == 0 && $user->rights->fournisseur->facture->creer,'string','',null,$langs->trans('PaymentNumberUpdateSucceeded'));
print '</td></tr>';
// Amount
print '<tr><td colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant,'',$langs,0,0,-1,$conf->currency).'</td></tr>';
@ -219,41 +219,41 @@ if ($result > 0)
}
// Note
print '<tr><td colspan="2">'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer,'textarea');
print '</td></tr>';
print '<tr><td colspan="2">'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer).'</td><td colspan="3">';
print $form->editfieldval("Note",'note',$object->note,$object,$user->rights->fournisseur->facture->creer,'textarea');
print '</td></tr>';
$allow_delete = 1 ;
// Bank account
// Bank account
if (! empty($conf->banque->enabled))
{
if ($object->bank_account)
{
$bankline=new AccountLine($db);
$bankline->fetch($object->bank_line);
if ($bankline->rappro)
{
$allow_delete=0;
$title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment"));
}
$bankline=new AccountLine($db);
$bankline->fetch($object->bank_line);
if ($bankline->rappro)
{
$allow_delete=0;
$title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment"));
}
print '<tr>';
print '<td colspan="2">'.$langs->trans('BankTransactionLine').'</td>';
print '<td colspan="3">';
print $bankline->getNomUrl(1,0,'showconciliated');
print '</td>';
print '</tr>';
print '<tr>';
print '<td colspan="2">'.$langs->trans('BankTransactionLine').'</td>';
print '<td colspan="3">';
print $bankline->getNomUrl(1,0,'showconciliated');
print '</td>';
print '</tr>';
print '<tr>';
print '<td colspan="2">'.$langs->trans('BankAccount').'</td>';
print '<tr>';
print '<td colspan="2">'.$langs->trans('BankAccount').'</td>';
print '<td colspan="3">';
$accountstatic=new Account($db);
$accountstatic->fetch($bankline->fk_account);
print $accountstatic->getNomUrl(1);
print '</td>';
print '</tr>';
}
}
print $accountstatic->getNomUrl(1);
print '</td>';
print '</tr>';
}
}
print '</table>';
@ -315,7 +315,7 @@ if ($result > 0)
if ($objp->paye == 1)
{
$allow_delete = 0;
$title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemovePaymentWithOneInvoicePaid"));
$title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemovePaymentWithOneInvoicePaid"));
}
$total = $total + $objp->amount;
$i++;
@ -343,8 +343,8 @@ if ($result > 0)
{
if ($user->societe_id == 0 && $object->statut == 0 && $action == '')
{
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=valide">'.$langs->trans('Valid').'</a>';
@ -355,14 +355,14 @@ if ($result > 0)
{
if ($user->rights->fournisseur->facture->supprimer)
{
if ($allow_delete)
{
if ($allow_delete)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
}
else
{
print '<a class="butActionRefused" href="#" title="'.$title_button.'">'.$langs->trans('Delete').'</a>';
}
}
else
{
print '<a class="butActionRefused" href="#" title="'.$title_button.'">'.$langs->trans('Delete').'</a>';
}
}
}
print '</div>';
@ -372,27 +372,27 @@ if ($result > 0)
/*
* Documents generes
*/
$ref=dol_sanitizeFileName($object->ref);
$filedir = $conf->fournisseur->payment->dir_output.'/'.dol_sanitizeFileName($object->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id;
$genallowed=$user->rights->fournisseur->facture->creer;
$delallowed=$user->rights->fournisseur->facture->supprimer;
$modelpdf=(! empty($object->modelpdf)?$object->modelpdf:(empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF)?'':$conf->global->SUPPLIER_PAYMENT_ADDON_PDF));
$ref=dol_sanitizeFileName($object->ref);
$filedir = $conf->fournisseur->payment->dir_output.'/'.dol_sanitizeFileName($object->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id;
$genallowed=$user->rights->fournisseur->facture->creer;
$delallowed=$user->rights->fournisseur->facture->supprimer;
$modelpdf=(! empty($object->modelpdf)?$object->modelpdf:(empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF)?'':$conf->global->SUPPLIER_PAYMENT_ADDON_PDF));
print $formfile->showdocuments('supplier_payment',$ref,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,40,0,'','','',$societe->default_lang);
$somethingshown=$formfile->numoffiles;
print $formfile->showdocuments('supplier_payment',$ref,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,40,0,'','','',$societe->default_lang);
$somethingshown=$formfile->numoffiles;
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
//print '</td><td valign="top" width="50%">';
//print '<br>';
//print '</td><td valign="top" width="50%">';
//print '<br>';
// List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions=new FormActions($db);
$somethingshown = $formactions->showactions($object,'supplier_payment',$socid,1,'listaction'.($genallowed?'largetitle':''));
// List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions=new FormActions($db);
$somethingshown = $formactions->showactions($object,'supplier_payment',$socid,1,'listaction'.($genallowed?'largetitle':''));
print '</div></div></div>';
//print '</td></tr></table>';
//print '</td></tr></table>';
}
else

File diff suppressed because it is too large Load Diff

View File

@ -82,13 +82,13 @@ else if ($year && $month && $day) $daytoparse=dol_mktime(0, 0, 0, $month, $day,
if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id)
{
$usertoprocess=$user;
$usertoprocess=$user;
$search_usertoprocessid=$usertoprocess->id;
}
elseif ($search_usertoprocessid > 0)
{
$usertoprocess=new User($db);
$usertoprocess->fetch($search_usertoprocessid);
$usertoprocess=new User($db);
$usertoprocess->fetch($search_usertoprocessid);
$search_usertoprocessid=$usertoprocess->id;
}
else
@ -106,17 +106,17 @@ $object=new Task($db);
// Purge criteria
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{
$action = '';
$search_categ='';
$search_usertoprocessid = $user->id;
$search_task_ref = '';
$search_task_label = '';
$search_project_ref = '';
$search_thirdparty = '';
$action = '';
$search_categ='';
$search_usertoprocessid = $user->id;
$search_task_ref = '';
$search_task_label = '';
$search_project_ref = '';
$search_thirdparty = '';
}
if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha'))
{
$action = '';
$action = '';
}
if (GETPOST('submitdateselect'))
@ -129,57 +129,57 @@ if (GETPOST('submitdateselect'))
if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask'))
{
$action = 'assigntask';
$action = 'assigntask';
if ($taskid > 0)
{
if ($taskid > 0)
{
$result = $object->fetch($taskid, $ref);
if ($result < 0) $error++;
}
else
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors');
$error++;
}
if (! GETPOST('type'))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
$error++;
}
if (! $error)
{
$idfortaskuser=$usertoprocess->id;
}
else
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors');
$error++;
}
if (! GETPOST('type'))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
$error++;
}
if (! $error)
{
$idfortaskuser=$usertoprocess->id;
$result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
if ($result >= 0 || $result == -2) // Contact add ok or already contact of task
{
if ($result >= 0 || $result == -2) // Contact add ok or already contact of task
{
// Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project)
$sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact';
$sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'";
$resql=$db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
if (! $obj) // User is not already linked to project, so we will create link to first type
{
$project = new Project($db);
$project->fetch($object->fk_project);
// Get type
$listofprojcontact=$project->liste_type_contact('internal');
$sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact';
$sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'";
$resql=$db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
if (! $obj) // User is not already linked to project, so we will create link to first type
{
$project = new Project($db);
$project->fetch($object->fk_project);
// Get type
$listofprojcontact=$project->liste_type_contact('internal');
if (count($listofprojcontact))
{
$typeforprojectcontact=reset(array_keys($listofprojcontact));
$result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal');
}
}
}
else
{
dol_print_error($db);
}
}
}
if (count($listofprojcontact))
{
$typeforprojectcontact=reset(array_keys($listofprojcontact));
$result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal');
}
}
}
else
{
dol_print_error($db);
}
}
}
if ($result < 0)
{
@ -206,48 +206,48 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
if ($action == 'addtime' && $user->rights->projet->lire)
{
$timespent_duration=array();
$timespent_duration=array();
if (is_array($_POST))
{
foreach($_POST as $key => $time)
{
if (intval($time) > 0)
{
// Hours or minutes of duration
if (preg_match("/([0-9]+)duration(hour|min)/",$key,$matches))
{
$id = $matches[1];
if ($id > 0)
{
// We store HOURS in seconds
if($matches[2]=='hour') $timespent_duration[$id] += $time*60*60;
// We store MINUTES in seconds
if($matches[2]=='min') $timespent_duration[$id] += $time*60;
}
}
}
}
}
if (count($timespent_duration) > 0)
{
foreach($timespent_duration as $key => $val)
{
$object->fetch($key);
$object->progress = GETPOST($key.'progress', 'int');
$object->timespent_duration = $val;
$object->timespent_fk_user = $user->id;
$object->timespent_note = GETPOST($key.'note');
if (GETPOST($key."hour") != '' && GETPOST($key."hour") >= 0) // If hour was entered
{
$object->timespent_datehour = dol_mktime(GETPOST($key."hour"),GETPOST($key."min"),0,$monthofday,$dayofday,$yearofday);
$object->timespent_withhour = 1;
}
else
if (is_array($_POST))
{
foreach($_POST as $key => $time)
{
if (intval($time) > 0)
{
$object->timespent_datehour = dol_mktime(12,0,0,$monthofday,$dayofday,$yearofday);
// Hours or minutes of duration
if (preg_match("/([0-9]+)duration(hour|min)/",$key,$matches))
{
$id = $matches[1];
if ($id > 0)
{
// We store HOURS in seconds
if($matches[2]=='hour') $timespent_duration[$id] += $time*60*60;
// We store MINUTES in seconds
if($matches[2]=='min') $timespent_duration[$id] += $time*60;
}
}
}
}
}
if (count($timespent_duration) > 0)
{
foreach($timespent_duration as $key => $val)
{
$object->fetch($key);
$object->progress = GETPOST($key.'progress', 'int');
$object->timespent_duration = $val;
$object->timespent_fk_user = $user->id;
$object->timespent_note = GETPOST($key.'note');
if (GETPOST($key."hour") != '' && GETPOST($key."hour") >= 0) // If hour was entered
{
$object->timespent_datehour = dol_mktime(GETPOST($key."hour"),GETPOST($key."min"),0,$monthofday,$dayofday,$yearofday);
$object->timespent_withhour = 1;
}
else
{
$object->timespent_datehour = dol_mktime(12,0,0,$monthofday,$dayofday,$yearofday);
}
$object->timespent_date = $object->timespent_datehour;
@ -268,21 +268,21 @@ if ($action == 'addtime' && $user->rights->projet->lire)
$error++;
break;
}
}
}
if (! $error)
{
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
if (! $error)
{
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
// Redirect to avoid submit twice on back
header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday);
exit;
}
}
else
{
setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors');
}
// Redirect to avoid submit twice on back
header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').'&year='.$yearofday.'&month='.$monthofday.'&day='.$dayofday);
exit;
}
}
else
{
setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors');
}
}
@ -318,8 +318,8 @@ $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,(e
if ($id)
{
$project->fetch($id);
$project->fetch_thirdparty();
$project->fetch($id);
$project->fetch_thirdparty();
}
$onlyopenedproject=1; // or -1
@ -465,7 +465,7 @@ print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ProjectRef").'</td>';
if (! empty($conf->global->PROJECT_LINES_PERDAY_SHOW_THIRDPARTY))
{
print '<td>'.$langs->trans("ThirdParty").'</td>';
print '<td>'.$langs->trans("ThirdParty").'</td>';
}
print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';

View File

@ -95,13 +95,13 @@ $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd');
if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id)
{
$usertoprocess=$user;
$usertoprocess=$user;
$search_usertoprocessid=$usertoprocess->id;
}
elseif ($search_usertoprocessid > 0)
{
$usertoprocess=new User($db);
$usertoprocess->fetch($search_usertoprocessid);
$usertoprocess=new User($db);
$usertoprocess->fetch($search_usertoprocessid);
$search_usertoprocessid=$usertoprocess->id;
}
else
@ -119,17 +119,17 @@ $object=new Task($db);
// Purge criteria
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{
$action = '';
$search_categ='';
$search_usertoprocessid = $user->id;
$search_task_ref = '';
$search_task_label = '';
$search_project_ref = '';
$search_thirdparty = '';
$action = '';
$search_categ='';
$search_usertoprocessid = $user->id;
$search_task_ref = '';
$search_task_label = '';
$search_project_ref = '';
$search_thirdparty = '';
}
if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha'))
{
$action = '';
$action = '';
}
if (GETPOST('submitdateselect'))
@ -141,58 +141,58 @@ if (GETPOST('submitdateselect'))
if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask'))
{
$action = 'assigntask';
$action = 'assigntask';
if ($taskid > 0)
{
if ($taskid > 0)
{
$result = $object->fetch($taskid, $ref);
if ($result < 0) $error++;
}
else
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors');
$error++;
}
if (! GETPOST('type'))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
$error++;
}
}
else
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), '', 'errors');
$error++;
}
if (! GETPOST('type'))
{
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), '', 'errors');
$error++;
}
if (! $error)
{
$idfortaskuser=$usertoprocess->id;
$result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
if (! $error)
{
$idfortaskuser=$usertoprocess->id;
$result = $object->add_contact($idfortaskuser, GETPOST("type"), 'internal');
if ($result >= 0 || $result == -2) // Contact add ok or already contact of task
{
// Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project)
$sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact';
$sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'";
$resql=$db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
if (! $obj) // User is not already linked to project, so we will create link to first type
{
$project = new Project($db);
$project->fetch($object->fk_project);
// Get type
$listofprojcontact=$project->liste_type_contact('internal');
if ($result >= 0 || $result == -2) // Contact add ok or already contact of task
{
// Test if we are already contact of the project (should be rare but sometimes we can add as task contact without being contact of project, like when admin user has been removed from contact of project)
$sql='SELECT ec.rowid FROM '.MAIN_DB_PREFIX.'element_contact as ec, '.MAIN_DB_PREFIX.'c_type_contact as tc WHERE tc.rowid = ec.fk_c_type_contact';
$sql.=' AND ec.fk_socpeople = '.$idfortaskuser." AND ec.element_id = '.$object->fk_project.' AND tc.element = 'project' AND source = 'internal'";
$resql=$db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
if (! $obj) // User is not already linked to project, so we will create link to first type
{
$project = new Project($db);
$project->fetch($object->fk_project);
// Get type
$listofprojcontact=$project->liste_type_contact('internal');
if (count($listofprojcontact))
{
$typeforprojectcontact=reset(array_keys($listofprojcontact));
$result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal');
}
}
}
else
{
dol_print_error($db);
}
}
}
if (count($listofprojcontact))
{
$typeforprojectcontact=reset(array_keys($listofprojcontact));
$result = $project->add_contact($idfortaskuser, $typeforprojectcontact, 'internal');
}
}
}
else
{
dol_print_error($db);
}
}
}
if ($result < 0)
{
@ -219,35 +219,35 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')
if ($action == 'addtime' && $user->rights->projet->lire)
{
$timetoadd=$_POST['task'];
$timetoadd=$_POST['task'];
if (empty($timetoadd))
{
setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors');
}
setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors');
}
else
{
foreach($timetoadd as $taskid => $value) // Loop on each task
{
$updateoftaskdone=0;
{
$updateoftaskdone=0;
foreach($value as $key => $val) // Loop on each day
{
$amountoadd=$timetoadd[$taskid][$key];
if (! empty($amountoadd))
{
$tmpduration=explode(':',$amountoadd);
$newduration=0;
if (! empty($amountoadd))
{
$tmpduration=explode(':',$amountoadd);
$newduration=0;
if (! empty($tmpduration[0])) $newduration+=($tmpduration[0] * 3600);
if (! empty($tmpduration[1])) $newduration+=($tmpduration[1] * 60);
if (! empty($tmpduration[2])) $newduration+=($tmpduration[2]);
if ($newduration > 0)
{
$object->fetch($taskid);
$object->progress = GETPOST($taskid . 'progress', 'int');
$object->timespent_duration = $newduration;
$object->timespent_fk_user = $usertoprocess->id;
$object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd');
$object->timespent_datehour = $object->timespent_date;
if ($newduration > 0)
{
$object->fetch($taskid);
$object->progress = GETPOST($taskid . 'progress', 'int');
$object->timespent_duration = $newduration;
$object->timespent_fk_user = $usertoprocess->id;
$object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd');
$object->timespent_datehour = $object->timespent_date;
$result=$object->addTimeSpent($user);
if ($result < 0)
@ -258,35 +258,35 @@ if ($action == 'addtime' && $user->rights->projet->lire)
}
$updateoftaskdone++;
}
}
}
}
}
if (! $updateoftaskdone) // Check to update progress if no update were done on task.
{
$object->fetch($taskid);
//var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit;
if ($object->progress != GETPOST($taskid . 'progress', 'int'))
{
$object->progress = GETPOST($taskid . 'progress', 'int');
$result=$object->update($user);
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
break;
}
}
$object->fetch($taskid);
//var_dump($object->progress);var_dump(GETPOST($taskid . 'progress', 'int')); exit;
if ($object->progress != GETPOST($taskid . 'progress', 'int'))
{
$object->progress = GETPOST($taskid . 'progress', 'int');
$result=$object->update($user);
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
$error++;
break;
}
}
}
}
}
if (! $error)
{
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
// Redirect to avoid submit twice on back
header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:''));
exit;
// Redirect to avoid submit twice on back
header('Location: '.$_SERVER["PHP_SELF"].'?'.($projectid?'id='.$projectid:'').($search_usertoprocessid?'&search_usertoprocessid='.$search_usertoprocessid:'').($mode?'&mode='.$mode:'').($day?'&day='.$day:'').($month?'&month='.$month:'').($year?'&year='.$year:''));
exit;
}
}
}
@ -313,8 +313,8 @@ $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,(e
//var_dump($projectsListId);
if ($id)
{
$project->fetch($id);
$project->fetch_thirdparty();
$project->fetch($id);
$project->fetch_thirdparty();
}
$onlyopenedproject=1; // or -1
@ -449,7 +449,7 @@ print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
for($i=0;$i<7;$i++)
{
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
}
// Action column
print '<td class="liste_titre nowrap" align="right">';
@ -462,7 +462,7 @@ print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ProjectRef").'</td>';
if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY))
{
print '<td>'.$langs->trans("ThirdParty").'</td>';
print '<td>'.$langs->trans("ThirdParty").'</td>';
}
print '<td>'.$langs->trans("RefTask").'</td>';
print '<td>'.$langs->trans("LabelTask").'</td>';
@ -504,8 +504,8 @@ $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED
if (count($tasksarray) > 0)
{
//var_dump($tasksarray);
//var_dump($tasksrole);
//var_dump($tasksarray);
//var_dump($tasksrole);
$j=0;
$level=0;
@ -516,9 +516,9 @@ if (count($tasksarray) > 0)
print '<tr class="liste_total">
<td class="liste_total" colspan="'.$colspan.'">';
print $langs->trans("Total");
print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
print '</td>
print $langs->trans("Total");
print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
print '</td>
<td class="liste_total hide0" align="center"><div id="totalDay[0]">&nbsp;</div></td>
<td class="liste_total hide1" align="center"><div id="totalDay[1]">&nbsp;</div></td>
<td class="liste_total hide2" align="center"><div id="totalDay[2]">&nbsp;</div></td>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -112,32 +112,32 @@ $fieldstosearchall = array(
'p.ref'=>"Ref",
'p.title'=>"Label",
's.nom'=>"ThirdPartyName",
"p.note_public"=>"NotePublic"
"p.note_public"=>"NotePublic"
);
if (empty($user->socid)) $fieldstosearchall["p.note_private"]="NotePrivate";
$arrayfields=array(
'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'p.title'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>$conf->societe->enabled),
'commercial'=>array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0),
'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'p.title'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>$conf->societe->enabled),
'commercial'=>array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0),
'p.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100),
'p.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101),
'p.public'=>array('label'=>$langs->trans("Visibility"), 'checked'=>1, 'position'=>102),
'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103),
'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>104),
'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>105),
'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110),
'p.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
'p.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101),
'p.public'=>array('label'=>$langs->trans("Visibility"), 'checked'=>1, 'position'=>102),
'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103),
'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>104),
'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>1, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>105),
'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110),
'p.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
}
@ -157,44 +157,44 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{
$search_all='';
$search_categ='';
$search_ref="";
$search_label="";
$search_societe="";
$search_year="";
$search_status=-1;
$search_opp_status=-1;
$search_opp_amount='';
$search_opp_percent='';
$search_budget_amount='';
$search_public="";
$search_sale="";
$search_project_user='';
$search_sday="";
$search_smonth="";
$search_syear="";
$search_eday="";
$search_emonth="";
$search_eyear="";
$toselect='';
$search_array_options=array();
}
// Purge search criteria
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{
$search_all='';
$search_categ='';
$search_ref="";
$search_label="";
$search_societe="";
$search_year="";
$search_status=-1;
$search_opp_status=-1;
$search_opp_amount='';
$search_opp_percent='';
$search_budget_amount='';
$search_public="";
$search_sale="";
$search_project_user='';
$search_sday="";
$search_smonth="";
$search_syear="";
$search_eday="";
$search_emonth="";
$search_eyear="";
$toselect='';
$search_array_options=array();
}
// Mass actions
$objectclass='Project';
$objectlabel='Project';
$permtoread = $user->rights->projet->lire;
$permtodelete = $user->rights->projet->supprimer;
$uploaddir = $conf->projet->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Mass actions
$objectclass='Project';
$objectlabel='Project';
$permtoread = $user->rights->projet->lire;
$permtodelete = $user->rights->projet->supprimer;
$uploaddir = $conf->projet->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -223,10 +223,10 @@ $sql.= " AND ctc.source = 'internal'";
$resql = $db->query($sql);
if ($resql)
{
while($obj = $db->fetch_object($resql))
{
$listofprojectcontacttype[$obj->rowid]=$obj->code;
}
while($obj = $db->fetch_object($resql))
{
$listofprojectcontacttype[$obj->rowid]=$obj->code;
}
}
else dol_print_error($db);
if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found
@ -272,42 +272,42 @@ if ($search_opp_amount) $sql .= natural_search('p.opp_amount', $search_opp_amoun
if ($search_opp_percent) $sql .= natural_search('p.opp_percent', $search_opp_percent, 1);
if ($search_smonth > 0)
{
if ($search_syear > 0 && empty($search_sday))
$sql.= " AND p.dateo BETWEEN '".$db->idate(dol_get_first_day($search_syear,$search_smonth,false))."' AND '".$db->idate(dol_get_last_day($search_syear,$search_smonth,false))."'";
else if ($search_syear > 0 && ! empty($search_sday))
$sql.= " AND p.dateo BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_smonth, $search_sday, $search_syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_smonth, $search_sday, $search_syear))."'";
else
$sql.= " AND date_format(p.dateo, '%m') = '".$search_smonth."'";
if ($search_syear > 0 && empty($search_sday))
$sql.= " AND p.dateo BETWEEN '".$db->idate(dol_get_first_day($search_syear,$search_smonth,false))."' AND '".$db->idate(dol_get_last_day($search_syear,$search_smonth,false))."'";
else if ($search_syear > 0 && ! empty($search_sday))
$sql.= " AND p.dateo BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_smonth, $search_sday, $search_syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_smonth, $search_sday, $search_syear))."'";
else
$sql.= " AND date_format(p.dateo, '%m') = '".$search_smonth."'";
}
else if ($search_syear > 0)
{
$sql.= " AND p.dateo BETWEEN '".$db->idate(dol_get_first_day($search_syear,1,false))."' AND '".$db->idate(dol_get_last_day($search_syear,12,false))."'";
$sql.= " AND p.dateo BETWEEN '".$db->idate(dol_get_first_day($search_syear,1,false))."' AND '".$db->idate(dol_get_last_day($search_syear,12,false))."'";
}
if ($search_emonth > 0)
{
if ($search_eyear > 0 && empty($search_eday))
$sql.= " AND p.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,$search_emonth,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,$search_emonth,false))."'";
else if ($search_eyear > 0 && ! empty($search_eday))
$sql.= " AND p.datee BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_emonth, $search_eday, $search_eyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_emonth, $search_eday, $search_eyear))."'";
else
$sql.= " AND date_format(p.datee, '%m') = '".$search_emonth."'";
if ($search_eyear > 0 && empty($search_eday))
$sql.= " AND p.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,$search_emonth,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,$search_emonth,false))."'";
else if ($search_eyear > 0 && ! empty($search_eday))
$sql.= " AND p.datee BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_emonth, $search_eday, $search_eyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_emonth, $search_eday, $search_eyear))."'";
else
$sql.= " AND date_format(p.datee, '%m') = '".$search_emonth."'";
}
else if ($search_eyear > 0)
{
$sql.= " AND p.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,12,false))."'";
$sql.= " AND p.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,12,false))."'";
}
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
if ($search_status >= 0)
{
if ($search_status == 99) $sql .= " AND p.fk_statut <> 2";
else $sql .= " AND p.fk_statut = ".$db->escape($search_status);
if ($search_status == 99) $sql .= " AND p.fk_statut <> 2";
else $sql .= " AND p.fk_statut = ".$db->escape($search_status);
}
if ($search_opp_status)
{
if (is_numeric($search_opp_status) && $search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status);
if ($search_opp_status == 'all') $sql .= " AND p.fk_opp_status IS NOT NULL";
if ($search_opp_status == 'openedopp') $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))";
if ($search_opp_status == 'none') $sql .= " AND p.fk_opp_status IS NULL";
if (is_numeric($search_opp_status) && $search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status);
if ($search_opp_status == 'all') $sql .= " AND p.fk_opp_status IS NOT NULL";
if ($search_opp_status == 'openedopp') $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status NOT IN (SELECT rowid FROM ".MAIN_DB_PREFIX."c_lead_status WHERE code IN ('WON','LOST'))";
if ($search_opp_status == 'none') $sql .= " AND p.fk_opp_status IS NULL";
}
if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public);
if ($search_sale > 0) $sql.= " AND sc.fk_user = " .$search_sale;
@ -319,16 +319,16 @@ if ($search_budget_amount != '') $sql .= natural_search('p.budget_amount', $sear
// Add where from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$typ=$extrafields->attribute_type[$tmpkey];
$mode=0;
if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric
if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int
if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0'))
{
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
}
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$typ=$extrafields->attribute_type[$tmpkey];
$mode=0;
if (in_array($typ, array('int','double','real'))) $mode=1; // Search on a numeric
if (in_array($typ, array('sellist')) && $crit != '0' && $crit != '-1') $mode=2; // Search on a foreign key int
if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0'))
{
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode);
}
}
// Add where from hooks
$parameters=array();
@ -339,8 +339,8 @@ $sql.= $db->order($sortfield,$sortorder);
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= $db->plimit($limit + 1,$offset);
@ -351,8 +351,8 @@ dol_syslog("list allowed project", LOG_DEBUG);
$resql = $db->query($sql);
if (! $resql)
{
dol_print_error($db);
exit;
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
@ -361,9 +361,9 @@ $arrayofselected=is_array($toselect)?$toselect:array();
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
{
$obj = $db->fetch_object($resql);
header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id);
exit;
$obj = $db->fetch_object($resql);
header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$obj->id);
exit;
}
$help_url="EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
@ -395,9 +395,9 @@ if ($optioncss != '') $param.='&optioncss='.$optioncss;
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
// List of mass actions available
@ -433,8 +433,8 @@ else
if ($search_all)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall);
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall);
}
$moreforfilter='';
@ -442,11 +442,11 @@ $moreforfilter='';
// Filter on categories
if (! empty($conf->categorie->enabled))
{
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ProjectCategories'). ': ';
$moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300');
$moreforfilter.='</div>';
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.=$langs->trans('ProjectCategories'). ': ';
$moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300');
$moreforfilter.='</div>';
}
// If the user can view user other than himself
@ -536,14 +536,14 @@ if (! empty($arrayfields['p.public']['checked']))
{
print '<td class="liste_titre">';
$array=array(''=>'',0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject"));
print $form->selectarray('search_public',$array,$search_public);
print '</td>';
print $form->selectarray('search_public',$array,$search_public);
print '</td>';
}
if (! empty($arrayfields['p.fk_opp_status']['checked']))
{
print '<td class="liste_titre nowrap center">';
print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 1, 1, 0, 'maxwidth100');
print '</td>';
print '</td>';
}
if (! empty($arrayfields['p.opp_amount']['checked']))
{
@ -561,30 +561,30 @@ if (! empty($arrayfields['p.budget_amount']['checked']))
{
print '<td class="liste_titre nowrap" align="right">';
print '<input type="text" class="flat" name="search_budget_amount" size="4" value="'.$search_budget_amount.'">';
print '</td>';
print '</td>';
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attribute_type[$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$typeofextrafield=$extrafields->attribute_type[$key];
print '<td class="liste_titre'.($align?' '.$align:'').'">';
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key]))
{
$crit=$val;
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
$searchclass='';
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
}
print '</td>';
}
}
print '</td>';
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields);
@ -592,24 +592,24 @@ $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // N
print $hookmanager->resPrint;
if (! empty($arrayfields['p.datec']['checked']))
{
// Date creation
print '<td class="liste_titre">';
print '</td>';
// Date creation
print '<td class="liste_titre">';
print '</td>';
}
if (! empty($arrayfields['p.tms']['checked']))
{
// Date modification
print '<td class="liste_titre">';
print '</td>';
// Date modification
print '<td class="liste_titre">';
print '</td>';
}
if (! empty($arrayfields['p.fk_statut']['checked']))
{
print '<td class="liste_titre nowrap" align="right">';
$arrayofstatus = array();
foreach($object->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val);
$arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')';
$arrayofstatus = array();
foreach($object->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val);
$arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')';
print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
print '</td>';
print '</td>';
}
// Action column
print '<td class="liste_titre" align="right">';
@ -634,16 +634,16 @@ if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$sortonfield = "ef.".$key;
if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
}
}
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$sortonfield = "ef.".$key;
if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
}
}
}
// Hook fields
$parameters=array('arrayfields'=>$arrayfields);
@ -675,168 +675,168 @@ while ($i < min($num,$limit))
print '<tr class="oddeven">';
// Project url
if (! empty($arrayfields['p.ref']['checked']))
{
print '<td class="nowrap">';
print $object->getNomUrl(1);
if ($object->hasDelay()) print img_warning($langs->trans('Late'));
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['p.ref']['checked']))
{
print '<td class="nowrap">';
print $object->getNomUrl(1);
if ($object->hasDelay()) print img_warning($langs->trans('Late'));
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Title
if (! empty($arrayfields['p.title']['checked']))
{
print '<td class="tdoverflowmax100">';
print dol_trunc($obj->title,80);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['p.title']['checked']))
{
print '<td class="tdoverflowmax100">';
print dol_trunc($obj->title,80);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Company
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="tdoverflowmax100">';
if ($obj->socid)
{
$socstatic->id=$obj->socid;
$socstatic->name=$obj->name;
print $socstatic->getNomUrl(1);
}
else
{
print '&nbsp;';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="tdoverflowmax100">';
if ($obj->socid)
{
$socstatic->id=$obj->socid;
$socstatic->name=$obj->name;
print $socstatic->getNomUrl(1);
}
else
{
print '&nbsp;';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Sales Representatives
if (! empty($arrayfields['commercial']['checked']))
{
print '<td>';
if ($obj->socid)
{
$socstatic->id=$obj->socid;
$socstatic->name=$obj->name;
$listsalesrepresentatives=$socstatic->getSalesRepresentatives($user);
$nbofsalesrepresentative=count($listsalesrepresentatives);
if ($nbofsalesrepresentative > 3) // We print only number
{
print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$socstatic->id.'">';
print $nbofsalesrepresentative;
print '</a>';
}
else if ($nbofsalesrepresentative > 0)
{
$userstatic=new User($db);
$j=0;
foreach($listsalesrepresentatives as $val)
{
$userstatic->id=$val['id'];
$userstatic->lastname=$val['lastname'];
$userstatic->firstname=$val['firstname'];
$userstatic->email=$val['email'];
$userstatic->statut=$val['statut'];
$userstatic->entity=$val['entity'];
$userstatic->photo=$val['photo'];
//print $userstatic->getNomUrl(1, '', 0, 0, 12);
print $userstatic->getNomUrl(-2);
$j++;
if ($j < $nbofsalesrepresentative) print ' ';
}
}
//else print $langs->trans("NoSalesRepresentativeAffected");
}
else
{
print '&nbsp';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['commercial']['checked']))
{
print '<td>';
if ($obj->socid)
{
$socstatic->id=$obj->socid;
$socstatic->name=$obj->name;
$listsalesrepresentatives=$socstatic->getSalesRepresentatives($user);
$nbofsalesrepresentative=count($listsalesrepresentatives);
if ($nbofsalesrepresentative > 3) // We print only number
{
print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$socstatic->id.'">';
print $nbofsalesrepresentative;
print '</a>';
}
else if ($nbofsalesrepresentative > 0)
{
$userstatic=new User($db);
$j=0;
foreach($listsalesrepresentatives as $val)
{
$userstatic->id=$val['id'];
$userstatic->lastname=$val['lastname'];
$userstatic->firstname=$val['firstname'];
$userstatic->email=$val['email'];
$userstatic->statut=$val['statut'];
$userstatic->entity=$val['entity'];
$userstatic->photo=$val['photo'];
//print $userstatic->getNomUrl(1, '', 0, 0, 12);
print $userstatic->getNomUrl(-2);
$j++;
if ($j < $nbofsalesrepresentative) print ' ';
}
}
//else print $langs->trans("NoSalesRepresentativeAffected");
}
else
{
print '&nbsp';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date start
if (! empty($arrayfields['p.dateo']['checked']))
{
if (! empty($arrayfields['p.dateo']['checked']))
{
print '<td class="center">';
print dol_print_date($db->jdate($obj->date_start),'day');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
print dol_print_date($db->jdate($obj->date_start),'day');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date end
if (! empty($arrayfields['p.datee']['checked']))
{
if (! empty($arrayfields['p.datee']['checked']))
{
print '<td class="center">';
print dol_print_date($db->jdate($obj->date_end),'day');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
print dol_print_date($db->jdate($obj->date_end),'day');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Visibility
if (! empty($arrayfields['p.public']['checked']))
{
print '<td align="left">';
if ($obj->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Opp Status
if (! empty($arrayfields['p.fk_opp_status']['checked']))
{
print '<td class="center">';
if (! empty($arrayfields['p.public']['checked']))
{
print '<td align="left">';
if ($obj->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Opp Status
if (! empty($arrayfields['p.fk_opp_status']['checked']))
{
print '<td class="center">';
if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Opp Amount
if (! empty($arrayfields['p.opp_amount']['checked']))
{
if (! $i) $totalarray['nbfield']++;
}
// Opp Amount
if (! empty($arrayfields['p.opp_amount']['checked']))
{
print '<td align="right">';
//if ($obj->opp_status_code)
if (strcmp($obj->opp_amount,''))
{
print price($obj->opp_amount, 1, $langs, 1, -1, -1, '');
$totalarray['totalopp'] += $obj->opp_amount;
print price($obj->opp_amount, 1, $langs, 1, -1, -1, '');
$totalarray['totalopp'] += $obj->opp_amount;
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield'];
}
// Opp percent
if (! empty($arrayfields['p.opp_percent']['checked']))
{
}
// Opp percent
if (! empty($arrayfields['p.opp_percent']['checked']))
{
print '<td align="right">';
if ($obj->opp_percent) print price($obj->opp_percent, 1, $langs, 1, 0).'%';
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Budget
if (! empty($arrayfields['p.budget_amount']['checked']))
{
if (! $i) $totalarray['nbfield']++;
}
// Budget
if (! empty($arrayfields['p.budget_amount']['checked']))
{
print '<td align="right">';
if ($obj->budget_amount != '')
{
print price($obj->budget_amount, 1, $langs, 1, -1, -1);
$totalarray['totalbudget'] += $obj->budget_amount;
print price($obj->budget_amount, 1, $langs, 1, -1, -1);
$totalarray['totalbudget'] += $obj->budget_amount;
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalbudgetfield']=$totalarray['nbfield'];
}
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
print '<td';
$align=$extrafields->getAlignFlag($key);
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
print '<td';
$align=$extrafields->getAlignFlag($key);
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
@ -845,34 +845,34 @@ while ($i < min($num,$limit))
// Date creation
if (! empty($arrayfields['p.datec']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
print '</td>';
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date modification
if (! empty($arrayfields['p.tms']['checked']))
{
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_update), 'dayhour');
print '</td>';
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_update), 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Status
if (! empty($arrayfields['p.fk_statut']['checked']))
{
print '<td align="right">'.$object->getLibStatut(5).'</td>';
print '<td align="right">'.$object->getLibStatut(5).'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Action column
print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected=0;
if (in_array($obj->id, $arrayofselected)) $selected=1;
print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected?' checked="checked"':'').'>';
}
print '</td>';
// Action column
print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected=0;
if (in_array($obj->id, $arrayofselected)) $selected=1;
print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected?' checked="checked"':'').'>';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
print "</tr>\n";
@ -885,21 +885,21 @@ while ($i < min($num,$limit))
// Show total line
if (isset($totalarray['totaloppfield']) || isset($totalarray['totalbudgetfield']))
{
print '<tr class="liste_total">';
$i=0;
while ($i < $totalarray['nbfield'])
{
$i++;
if ($i == 1)
{
if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
}
elseif ($totalarray['totaloppfield'] == $i) print '<td align="right">'.price($totalarray['totalopp'], 1, $langs, 1, -1, -1).'</td>';
elseif ($totalarray['totalbudgetfield'] == $i) print '<td align="right">'.price($totalarray['totalbudget'], 1, $langs, 1, -1, -1).'</td>';
else print '<td></td>';
}
print '</tr>';
print '<tr class="liste_total">';
$i=0;
while ($i < $totalarray['nbfield'])
{
$i++;
if ($i == 1)
{
if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
}
elseif ($totalarray['totaloppfield'] == $i) print '<td align="right">'.price($totalarray['totalopp'], 1, $langs, 1, -1, -1).'</td>';
elseif ($totalarray['totalbudgetfield'] == $i) print '<td align="right">'.price($totalarray['totalbudget'], 1, $langs, 1, -1, -1).'</td>';
else print '<td></td>';
}
print '</tr>';
}
$db->free($resql);

View File

@ -115,11 +115,11 @@ if (! isset($conf->global->THEME_ELDY_TEXTLINK)) $conf->global->THEME_ELDY_TEXTL
// Case of option editable only if option THEME_ELDY_ENABLE_PERSONALIZED is on
if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED))
{
$conf->global->THEME_ELDY_BACKTABCARD1='255,255,255'; // card
$conf->global->THEME_ELDY_BACKTABACTIVE='234,234,234';
$conf->global->THEME_ELDY_TEXT='0,0,0';
$conf->global->THEME_ELDY_FONT_SIZE1='13';
$conf->global->THEME_ELDY_FONT_SIZE2='12';
$conf->global->THEME_ELDY_BACKTABCARD1='255,255,255'; // card
$conf->global->THEME_ELDY_BACKTABACTIVE='234,234,234';
$conf->global->THEME_ELDY_TEXT='0,0,0';
$conf->global->THEME_ELDY_FONT_SIZE1='13';
$conf->global->THEME_ELDY_FONT_SIZE2='12';
}
// Case of option availables only if THEME_ELDY_ENABLE_PERSONALIZED is on
@ -145,7 +145,7 @@ $fontsizesmaller =empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED)?(empty(
$colorbacklinepairhover=((! isset($conf->global->THEME_ELDY_USE_HOVER) || (string) $conf->global->THEME_ELDY_USE_HOVER === '0')?'':($conf->global->THEME_ELDY_USE_HOVER === '1'?'edf4fb':$conf->global->THEME_ELDY_USE_HOVER));
if (! empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED))
{
$colorbacklinepairhover=((! isset($user->conf->THEME_ELDY_USE_HOVER) || $user->conf->THEME_ELDY_USE_HOVER === '0')?'':($user->conf->THEME_ELDY_USE_HOVER === '1'?'edf4fb':$user->conf->THEME_ELDY_USE_HOVER));
$colorbacklinepairhover=((! isset($user->conf->THEME_ELDY_USE_HOVER) || $user->conf->THEME_ELDY_USE_HOVER === '0')?'':($user->conf->THEME_ELDY_USE_HOVER === '1'?'edf4fb':$user->conf->THEME_ELDY_USE_HOVER));
}
//$colortopbordertitle1=$colorbackhmenu1;
@ -167,9 +167,9 @@ $colorbacktitle1=join(',',colorStringToArray($colorbacktitle1)); // Normalize
$tmppart=explode(',',$colorbacktitle1);
if ($colortexttitle == '')
{
$tmpval=(! empty($tmppart[0]) ? $tmppart[0] : 0)+(! empty($tmppart[1]) ? $tmppart[1] : 0)+(! empty($tmppart[2]) ? $tmppart[2] : 0);
if ($tmpval <= 460) { $colortexttitle='FFFFFF'; $colorshadowtitle='888888'; }
else { $colortexttitle='000000'; $colorshadowtitle='FFFFFF'; }
$tmpval=(! empty($tmppart[0]) ? $tmppart[0] : 0)+(! empty($tmppart[1]) ? $tmppart[1] : 0)+(! empty($tmppart[2]) ? $tmppart[2] : 0);
if ($tmpval <= 460) { $colortexttitle='FFFFFF'; $colorshadowtitle='888888'; }
else { $colortexttitle='000000'; $colorshadowtitle='FFFFFF'; }
}
$colorbacktabcard1=join(',',colorStringToArray($colorbacktabcard1)); // Normalize value to 'x,y,z'

File diff suppressed because it is too large Load Diff

View File

@ -53,17 +53,17 @@ class User extends CommonObject
public $job;
public $signature;
public $address;
public $zip;
public $town;
public $state_id;
public $state_code;
public $state;
public $zip;
public $town;
public $state_id;
public $state_code;
public $state;
public $office_phone;
public $office_fax;
public $user_mobile;
public $admin;
public $login;
public $api_key;
public $api_key;
public $entity;
//! Clear password in memory
@ -202,22 +202,22 @@ class User extends CommonObject
$sql.= " u.dateemployment,";
$sql.= " u.ref_int, u.ref_ext,";
$sql.= " u.default_range, u.default_c_exp_tax_cat,";
$sql.= " c.code as country_code, c.label as country,";
$sql.= " d.code_departement as state_code, d.nom as state";
$sql.= " c.code as country_code, c.label as country,";
$sql.= " d.code_departement as state_code, d.nom as state";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON u.fk_country = c.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON u.fk_state = d.rowid";
if ($entity < 0)
{
if ((empty($conf->multicompany->enabled) || empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) && (! empty($user->entity)))
{
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
}
else
{
$sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
}
if ((empty($conf->multicompany->enabled) || empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) && (! empty($user->entity)))
{
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
}
else
{
$sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
}
}
else // The fetch was forced on an entity
{
@ -266,19 +266,19 @@ class User extends CommonObject
$this->pass_indatabase_crypted = $obj->pass_crypted;
$this->pass = $obj->pass;
$this->pass_temp = $obj->pass_temp;
$this->api_key = $obj->api_key;
$this->api_key = $obj->api_key;
$this->address = $obj->address;
$this->zip = $obj->zip;
$this->town = $obj->town;
$this->address = $obj->address;
$this->zip = $obj->zip;
$this->town = $obj->town;
$this->country_id = $obj->country_id;
$this->country_code = $obj->country_id?$obj->country_code:'';
//$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):'';
$this->country_id = $obj->country_id;
$this->country_code = $obj->country_id?$obj->country_code:'';
//$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):'';
$this->state_id = $obj->state_id;
$this->state_code = $obj->state_code;
$this->state = ($obj->state!='-'?$obj->state:'');
$this->state_id = $obj->state_id;
$this->state_code = $obj->state_code;
$this->state = ($obj->state!='-'?$obj->state:'');
$this->office_phone = $obj->office_phone;
$this->office_fax = $obj->office_fax;
@ -349,7 +349,7 @@ class User extends CommonObject
// To get back the global configuration unique to the user
if ($loadpersonalconf)
{
// Load user->conf for user
// Load user->conf for user
$sql = "SELECT param, value FROM ".MAIN_DB_PREFIX."user_param";
$sql.= " WHERE fk_user = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
@ -382,35 +382,35 @@ class User extends CommonObject
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
if (! empty($obj->page) && ! empty($obj->type) && ! empty($obj->param))
{
// $obj->page is relative URL with or without params
// $obj->type can be 'filters', 'sortorder', 'createform', ...
// $obj->param is key or param
$pagewithoutquerystring=$obj->page;
$pagequeries='';
if (preg_match('/^([^\?]+)\?(.*)$/', $pagewithoutquerystring, $reg)) // There is query param
{
$pagewithoutquerystring=$reg[1];
$pagequeries=$reg[2];
}
$this->default_values[$pagewithoutquerystring][$obj->type][$pagequeries?$pagequeries:'_noquery_'][$obj->param]=$obj->value;
//if ($pagequeries) $this->default_values[$pagewithoutquerystring][$obj->type.'_queries']=$pagequeries;
}
}
// Sort by key, so _noquery_ is last
if(!empty($this->default_values)) {
foreach($this->default_values as $a => $b)
{
foreach($b as $c => $d)
{
krsort($this->default_values[$a][$c]);
}
}
}
$this->db->free($resql);
while ($obj = $this->db->fetch_object($resql))
{
if (! empty($obj->page) && ! empty($obj->type) && ! empty($obj->param))
{
// $obj->page is relative URL with or without params
// $obj->type can be 'filters', 'sortorder', 'createform', ...
// $obj->param is key or param
$pagewithoutquerystring=$obj->page;
$pagequeries='';
if (preg_match('/^([^\?]+)\?(.*)$/', $pagewithoutquerystring, $reg)) // There is query param
{
$pagewithoutquerystring=$reg[1];
$pagequeries=$reg[2];
}
$this->default_values[$pagewithoutquerystring][$obj->type][$pagequeries?$pagequeries:'_noquery_'][$obj->param]=$obj->value;
//if ($pagequeries) $this->default_values[$pagewithoutquerystring][$obj->type.'_queries']=$pagequeries;
}
}
// Sort by key, so _noquery_ is last
if(!empty($this->default_values)) {
foreach($this->default_values as $a => $b)
{
foreach($b as $c => $d)
{
krsort($this->default_values[$a][$c]);
}
}
}
$this->db->free($resql);
}
else
{
@ -429,7 +429,7 @@ class User extends CommonObject
* @param string $allmodule Ajouter tous les droits du module allmodule
* @param string $allperms Ajouter tous les droits du module allmodule, perms allperms
* @param int $entity Entity to use
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
* @return int > 0 if OK, < 0 if KO
*/
function addrights($rid, $allmodule='', $allperms='', $entity=0, $notrigger=0)
@ -515,12 +515,12 @@ class User extends CommonObject
if (! $error && ! $notrigger)
{
$this->context = array('audit'=>$langs->trans("PermissionsAdd"));
$this->context = array('audit'=>$langs->trans("PermissionsAdd"));
// Call trigger
$result=$this->call_trigger('USER_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('USER_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if ($error) {
@ -542,7 +542,7 @@ class User extends CommonObject
* @param string $allmodule Retirer tous les droits du module allmodule
* @param string $allperms Retirer tous les droits du module allmodule, perms allperms
* @param int $entity Entity to use
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
* @return int > 0 if OK, < 0 if OK
*/
function delrights($rid, $allmodule='', $allperms='', $entity=0, $notrigger=0)
@ -625,12 +625,12 @@ class User extends CommonObject
if (! $error && ! $notrigger)
{
$this->context = array('audit'=>$langs->trans("PermissionsDelete"));
$this->context = array('audit'=>$langs->trans("PermissionsDelete"));
// Call trigger
$result=$this->call_trigger('USER_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('USER_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if ($error) {
@ -840,10 +840,10 @@ class User extends CommonObject
dol_syslog(get_class($this)."::setstatus", LOG_DEBUG);
if ($result)
{
// Call trigger
$result=$this->call_trigger('USER_ENABLEDISABLE',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('USER_ENABLEDISABLE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if ($error)
@ -926,7 +926,7 @@ class User extends CommonObject
if (! $error && ! $this->db->query($sql))
{
$error++;
$this->error = $this->db->lasterror();
$this->error = $this->db->lasterror();
}
// Remove group
@ -934,7 +934,7 @@ class User extends CommonObject
if (! $error && ! $this->db->query($sql))
{
$error++;
$this->error = $this->db->lasterror();
$this->error = $this->db->lasterror();
}
// If contact, remove link
@ -944,44 +944,44 @@ class User extends CommonObject
if (! $error && ! $this->db->query($sql))
{
$error++;
$this->error = $this->db->lasterror();
$this->error = $this->db->lasterror();
}
}
// Remove extrafields
if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
{
{
$result=$this->deleteExtraFields();
if ($result < 0)
{
$error++;
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
}
}
$error++;
dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
}
}
// Remove user
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if (! $this->db->query($sql))
{
$error++;
$this->error = $this->db->lasterror();
}
}
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if (! $this->db->query($sql))
{
$error++;
$this->error = $this->db->lasterror();
}
}
if (! $error)
{
// Call trigger
$result=$this->call_trigger('USER_DELETE',$user);
if ($result < 0)
{
$error++;
$this->db->rollback();
return -1;
}
// End call triggers
// Call trigger
$result=$this->call_trigger('USER_DELETE',$user);
if ($result < 0)
{
$error++;
$this->db->rollback();
return -1;
}
// End call triggers
$this->db->commit();
return 1;
@ -1089,10 +1089,10 @@ class User extends CommonObject
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('USER_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('USER_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
@ -1145,7 +1145,7 @@ class User extends CommonObject
$this->firstname = $contact->firstname;
$this->gender = $contact->gender;
$this->email = $contact->email;
$this->skype = $contact->skype;
$this->skype = $contact->skype;
$this->office_phone = $contact->phone_pro;
$this->office_fax = $contact->fax;
$this->user_mobile = $contact->phone_mobile;
@ -1154,7 +1154,7 @@ class User extends CommonObject
$this->town = $contact->town;
$this->state_id = $contact->state_id;
$this->country_id = $contact->country_id;
$this->employee = 0;
$this->employee = 0;
if (empty($login)) $login=strtolower(substr($contact->firstname, 0, 4)) . strtolower(substr($contact->lastname, 0, 4));
$this->login = $login;
@ -1176,10 +1176,10 @@ class User extends CommonObject
{
$this->context['createfromcontact']='createfromcontact';
// Call trigger
$result=$this->call_trigger('USER_CREATE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
// Call trigger
$result=$this->call_trigger('USER_CREATE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
$this->db->commit();
return $this->id;
@ -1345,12 +1345,12 @@ class User extends CommonObject
$this->gender = trim($this->gender);
$this->birth = trim($this->birth);
$this->pass = trim($this->pass);
$this->api_key = trim($this->api_key);
$this->api_key = trim($this->api_key);
$this->address = $this->address?trim($this->address):trim($this->address);
$this->zip = $this->zip?trim($this->zip):trim($this->zip);
$this->town = $this->town?trim($this->town):trim($this->town);
$this->state_id = trim($this->state_id);
$this->country_id = ($this->country_id > 0)?$this->country_id:0;
$this->zip = $this->zip?trim($this->zip):trim($this->zip);
$this->town = $this->town?trim($this->town):trim($this->town);
$this->state_id = trim($this->state_id);
$this->country_id = ($this->country_id > 0)?$this->country_id:0;
$this->office_phone = trim($this->office_phone);
$this->office_fax = trim($this->office_fax);
$this->user_mobile = trim($this->user_mobile);
@ -1390,7 +1390,7 @@ class User extends CommonObject
$sql.= ", firstname = '".$this->db->escape($this->firstname)."'";
$sql.= ", employee = ".$this->employee;
$sql.= ", login = '".$this->db->escape($this->login)."'";
$sql.= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null");
$sql.= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null");
$sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'
$sql.= ", birth=".(strval($this->birth)!='' ? "'".$this->db->idate($this->birth)."'" : 'null');
if (! empty($user->admin)) $sql.= ", admin = ".$this->admin; // admin flag can be set/unset only by an admin user
@ -1445,7 +1445,7 @@ class User extends CommonObject
if ($this->fk_member > 0)
{
dol_syslog(get_class($this)."::update remove link with member. We will recreate it later", LOG_DEBUG);
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL where fk_member = ".$this->fk_member;
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL where fk_member = ".$this->fk_member;
$resql = $this->db->query($sql);
if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; }
}
@ -1459,7 +1459,7 @@ class User extends CommonObject
{
if ($this->fk_member > 0 && ! $nosyncmember)
{
dol_syslog(get_class($this)."::update user is linked with a member. We try to update member too.", LOG_DEBUG);
dol_syslog(get_class($this)."::update user is linked with a member. We try to update member too.", LOG_DEBUG);
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
@ -1491,10 +1491,10 @@ class User extends CommonObject
$adh->user_login=$this->login;
$result=$adh->update($user,0,1,0);
if ($result < 0)
if ($result < 0)
{
$this->error=$adh->error;
$this->errors=$adh->errors;
$this->error=$adh->error;
$this->errors=$adh->errors;
dol_syslog(get_class($this)."::update error after calling adh->update to sync it with user: ".$this->error, LOG_ERR);
$error++;
}
@ -1522,10 +1522,10 @@ class User extends CommonObject
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('USER_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('USER_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
@ -1612,11 +1612,11 @@ class User extends CommonObject
// Mise a jour
if (! $changelater)
{
if (! is_object($this->oldcopy)) $this->oldcopy = clone $this;
if (! is_object($this->oldcopy)) $this->oldcopy = clone $this;
$this->db->begin();
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
$sql.= " SET pass_crypted = '".$this->db->escape($password_crypted)."',";
$sql.= " pass_temp = null";
if (! empty($conf->global->DATABASE_PWD_ENCRYPTED))
@ -1669,10 +1669,10 @@ class User extends CommonObject
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('USER_NEW_PASSWORD',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
// Call trigger
$result=$this->call_trigger('USER_NEW_PASSWORD',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
}
$this->db->commit();
@ -1680,13 +1680,13 @@ class User extends CommonObject
}
else
{
$this->db->rollback();
$this->db->rollback();
return 0;
}
}
else
{
$this->db->rollback();
$this->db->rollback();
dol_print_error($this->db);
return -1;
}
@ -1791,19 +1791,19 @@ class User extends CommonObject
dol_syslog(get_class($this)."::send_password changelater is on, url=".$url);
}
$mailfile = new CMailFile(
$subject,
$this->email,
$conf->notification->email_from,
$mesg,
array(),
array(),
array(),
'',
'',
0,
$msgishtml
);
$mailfile = new CMailFile(
$subject,
$this->email,
$conf->notification->email_from,
$mesg,
array(),
array(),
array(),
'',
'',
0,
$msgishtml
);
if ($mailfile->sendfile())
{
@ -1934,13 +1934,13 @@ class User extends CommonObject
{
if (! $error && ! $notrigger)
{
$this->newgroupid=$group; // deprecated. Remove this.
$this->context = array('audit'=>$langs->trans("UserSetInGroup"), 'newgroupid'=>$group);
$this->newgroupid=$group; // deprecated. Remove this.
$this->context = array('audit'=>$langs->trans("UserSetInGroup"), 'newgroupid'=>$group);
// Call trigger
$result=$this->call_trigger('USER_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('USER_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
@ -1989,13 +1989,13 @@ class User extends CommonObject
{
if (! $error && ! $notrigger)
{
$this->oldgroupid=$group; // deprecated. Remove this.
$this->context = array('audit'=>$langs->trans("UserRemovedFromGroup"), 'oldgroupid'=>$group);
$this->oldgroupid=$group; // deprecated. Remove this.
$this->context = array('audit'=>$langs->trans("UserRemovedFromGroup"), 'oldgroupid'=>$group);
// Call trigger
$result=$this->call_trigger('USER_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
// Call trigger
$result=$this->call_trigger('USER_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
@ -2027,7 +2027,7 @@ class User extends CommonObject
* @param int $width Width of image
* @param int $height Height of image
* @param string $cssclass Force a css class
* @param string $imagesize 'mini', 'small' or '' (original)
* @param string $imagesize 'mini', 'small' or '' (original)
* @return string String with URL link
*/
function getPhotoUrl($width, $height, $cssclass='', $imagesize='')
@ -2035,10 +2035,10 @@ class User extends CommonObject
$result='';
$result.='<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'">';
$result.=Form::showphoto('userphoto', $this, $width, $height, 0, $cssclass, $imagesize);
$result.='</a>';
$result.=Form::showphoto('userphoto', $this, $width, $height, 0, $cssclass, $imagesize);
$result.='</a>';
return $result;
return $result;
}
/**
@ -2047,13 +2047,13 @@ class User extends CommonObject
*
* @param int $withpictoimg Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small)
* @param string $option On what the link point to
* @param integer $infologin Add complete info tooltip
* @param integer $notooltip 1=Disable tooltip on picto and name
* @param int $maxlen Max length of visible user name
* @param int $hidethirdpartylogo Hide logo of thirdparty if user is external user
* @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'login'=Show login
* @param string $morecss Add more css on link
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @param integer $infologin Add complete info tooltip
* @param integer $notooltip 1=Disable tooltip on picto and name
* @param int $maxlen Max length of visible user name
* @param int $hidethirdpartylogo Hide logo of thirdparty if user is external user
* @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'login'=Show login
* @param string $morecss Add more css on link
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL
*/
function getNomUrl($withpictoimg=0, $option='', $infologin=0, $notooltip=0, $maxlen=24, $hidethirdpartylogo=0, $mode='',$morecss='', $save_lastsearch_value=-1)
@ -2064,14 +2064,14 @@ class User extends CommonObject
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0;
$result=''; $label='';
$link=''; $linkstart=''; $linkend='';
$result=''; $label='';
$link=''; $linkstart=''; $linkend='';
if (! empty($this->photo))
{
$label.= '<div class="photointooltip">';
$label.= Form::showphoto('userphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1);
$label.= '</div><div style="clear: both;"></div>';
$label.= '<div class="photointooltip">';
$label.= Form::showphoto('userphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1);
$label.= '</div><div style="clear: both;"></div>';
}
$label.= '<div class="centpercent">';
@ -2148,20 +2148,20 @@ class User extends CommonObject
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint;
$link.=$linkclose.'>';
$link.=$linkclose.'>';
$linkend='</a>';
//if ($withpictoimg == -1) $result.='<div class="nowrap">';
//if ($withpictoimg == -1) $result.='<div class="nowrap">';
$result.=$link;
if ($withpictoimg)
{
$paddafterimage='';
if ($withpictoimg)
{
$paddafterimage='';
if (abs($withpictoimg) == 1) $paddafterimage='style="margin-right: 3px;"';
// Only picto
// Only picto
if ($withpictoimg > 0) $picto='<!-- picto user --><div class="inline-block nopadding '.($morecss?' userimg'.$morecss:'').'">'.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).'</div>';
// Picto must be a photo
// Picto must be a photo
else $picto='<!-- picto photo user --><div class="inline-block nopadding '.($morecss?' userimg'.$morecss:'').'"'.($paddafterimage?' '.$paddafterimage:'').'>'.Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1).'</div>';
$result.=$picto;
$result.=$picto;
}
if ($withpictoimg > -2 && $withpictoimg != 2)
{
@ -2421,7 +2421,7 @@ class User extends CommonObject
$this->gender='man';
$this->note='This is a note';
$this->email='email@specimen.com';
$this->skype='tom.hanson';
$this->skype='tom.hanson';
$this->office_phone='0999999999';
$this->office_fax='0999999998';
$this->user_mobile='0999999997';
@ -2722,8 +2722,8 @@ class User extends CommonObject
$result = $this->build_path_from_id_user($key,0); // Process a branch from the root user key (this user has no parent)
if ($result < 0)
{
$this->error='ErrorLoopInHierarchy';
return -1;
$this->error='ErrorLoopInHierarchy';
return -1;
}
}
@ -2763,26 +2763,26 @@ class User extends CommonObject
*/
function getAllChildIds($addcurrentuser=0)
{
$childids=array();
$childids=array();
if (isset($this->cache_childids[$this->id]))
{
$childids = $this->cache_childids[$this->id];
}
else
{
// Init this->users
$this->get_full_tree();
if (isset($this->cache_childids[$this->id]))
{
$childids = $this->cache_childids[$this->id];
}
else
{
// Init this->users
$this->get_full_tree();
$idtoscan=$this->id;
$idtoscan=$this->id;
dol_syslog("Build childid for id = ".$idtoscan);
foreach($this->users as $id => $val)
{
//var_dump($val['fullpath']);
if (preg_match('/_'.$idtoscan.'_/', $val['fullpath'])) $childids[$val['id']]=$val['id'];
}
}
dol_syslog("Build childid for id = ".$idtoscan);
foreach($this->users as $id => $val)
{
//var_dump($val['fullpath']);
if (preg_match('/_'.$idtoscan.'_/', $val['fullpath'])) $childids[$val['id']]=$val['id'];
}
}
$this->cache_childids[$this->id] = $childids;
if ($addcurrentuser) $childids[$this->id]=$this->id;
@ -2823,7 +2823,7 @@ class User extends CommonObject
return -1; // Should not happen. Protection against looping hierarchy
}
$useridfound[]=$this->parentof[$cursor_user];
$this->users[$id_user]['fullpath'] = '_'.$this->parentof[$cursor_user].$this->users[$id_user]['fullpath'];
$this->users[$id_user]['fullpath'] = '_'.$this->parentof[$cursor_user].$this->users[$id_user]['fullpath'];
$this->users[$id_user]['fullname'] = $this->users[$this->parentof[$cursor_user]]['lastname'].' >> '.$this->users[$id_user]['fullname'];
$i++; $cursor_user=$this->parentof[$cursor_user];
}
@ -2853,39 +2853,39 @@ class User extends CommonObject
/**
* Charge indicateurs this->nb pour le tableau de bord
*
* @return int <0 if KO, >0 if OK
*/
function load_state_board()
{
global $conf;
* Charge indicateurs this->nb pour le tableau de bord
*
* @return int <0 if KO, >0 if OK
*/
function load_state_board()
{
global $conf;
$this->nb=array();
$this->nb=array();
$sql = "SELECT count(u.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.statut > 0";
//$sql.= " AND employee != 0";
$sql.= " AND u.entity IN (".getEntity('user').")";
$sql = "SELECT count(u.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.statut > 0";
//$sql.= " AND employee != 0";
$sql.= " AND u.entity IN (".getEntity('user').")";
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["users"]=$obj->nb;
}
$this->db->free($resql);
return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
$resql=$this->db->query($sql);
if ($resql)
{
while ($obj=$this->db->fetch_object($resql))
{
$this->nb["users"]=$obj->nb;
}
$this->db->free($resql);
return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
/**
* Create a document onto disk according to template module.

View File

@ -112,25 +112,25 @@ print '<table class="border" width="100%">';
print '<tr><td class="titlefield">'.$langs->trans("Login").'</td>';
if ($object->ldap_sid)
{
print '<td class="warning">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>';
print '<td class="warning">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>';
}
else
{
print '<td>'.$object->login.'</td>';
print '<td>'.$object->login.'</td>';
}
print '</tr>';
if ($conf->global->LDAP_SERVER_TYPE == "activedirectory")
{
$ldap = new Ldap();
$result = $ldap->connect_bind();
if ($result > 0)
{
$userSID = $ldap->getObjectSid($object->login);
}
print '<tr><td class="valigntop">'.$langs->trans("SID").'</td>';
print '<td>'.$userSID.'</td>';
print "</tr>\n";
$ldap = new Ldap();
$result = $ldap->connect_bind();
if ($result > 0)
{
$userSID = $ldap->getObjectSid($object->login);
}
print '<tr><td class="valigntop">'.$langs->trans("SID").'</td>';
print '<td>'.$userSID.'</td>';
print "</tr>\n";
}
// LDAP DN
@ -160,7 +160,7 @@ print '<div class="tabsAction">';
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
}
print "</div>\n";
@ -184,32 +184,32 @@ $ldap=new Ldap();
$result=$ldap->connect_bind();
if ($result > 0)
{
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info,1);
$search = "(".$object->_load_ldap_dn($info,2).")";
$records = $ldap->getAttribute($dn,$search);
$info=$object->_load_ldap_info();
$dn=$object->_load_ldap_dn($info,1);
$search = "(".$object->_load_ldap_dn($info,2).")";
$records = $ldap->getAttribute($dn,$search);
//print_r($records);
//print_r($records);
// Affichage arbre
if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
{
if (! is_array($records))
{
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
}
else
{
$result=show_ldap_content($records,0,$records['count'],true);
}
}
else
{
print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
}
// Affichage arbre
if ((! is_numeric($records) || $records != 0) && (! isset($records['count']) || $records['count'] > 0))
{
if (! is_array($records))
{
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
}
else
{
$result=show_ldap_content($records,0,$records['count'],true);
}
}
else
{
print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
}
$ldap->unbind();
$ldap->close();
$ldap->unbind();
$ldap->close();
}
else
{

File diff suppressed because it is too large Load Diff