Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into develop
This commit is contained in:
commit
8b4b270720
1
dev/resources/iso-normes/code_nace.txt
Normal file
1
dev/resources/iso-normes/code_nace.txt
Normal file
@ -0,0 +1 @@
|
||||
http://ec.europa.eu/eurostat/ramon/nomenclatures/index.cfm?TargetUrl=LST_CLS_DLD&StrNom=NACE_REV2&StrLanguageCode=FR&StrLayoutCode=#
|
||||
@ -129,7 +129,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -269,12 +269,12 @@ if ($mode != 'focus')
|
||||
{
|
||||
if ($mode != 'sortorder')
|
||||
{
|
||||
$substitutionarray=getCommonSubstitutionArray($langs, 0, array('object')); // Must match list into GETPOST
|
||||
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
|
||||
$substitutionarray=getCommonSubstitutionArray($langs, 2, array('object','objectamount')); // Must match list into GETPOST
|
||||
unset($substitutionarray['__USER_SIGNATURE__']);
|
||||
$texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
|
||||
foreach($substitutionarray as $key => $val)
|
||||
{
|
||||
$texthelp.=$key.'<br>';
|
||||
$texthelp.=$key.' -> '.$val.'<br>';
|
||||
}
|
||||
$textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); // No tooltip on click, this also triggers the sort click
|
||||
}
|
||||
|
||||
@ -137,7 +137,17 @@ if ($action == 'update')
|
||||
}
|
||||
}
|
||||
|
||||
dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity);
|
||||
dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE",GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"),'chaine',0,'',$conf->entity);
|
||||
|
||||
// For update value with percentage
|
||||
$plus='';
|
||||
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
|
||||
// Update values
|
||||
for($i=0;$i<4;$i++) {
|
||||
if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'),'chaine',0,'',$conf->entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -196,13 +206,6 @@ if ($action == 'edit')
|
||||
print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td class="center">' .$form->selectyesno('MAIN_DISABLE_METEO',(empty($conf->global->MAIN_DISABLE_METEO)?0:1),1) . '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
|
||||
print '<br>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -244,21 +247,30 @@ else
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Boutons d'action
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a>';
|
||||
print '</div>';
|
||||
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
// Show logo for weather
|
||||
print $langs->trans("DescWeather").'<br>';
|
||||
|
||||
if($action == 'edit') {
|
||||
|
||||
$str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoPercentageMod'));
|
||||
$str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->trans('MeteoStdMod'));
|
||||
if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std;
|
||||
else $str_mode_enabled = $str_mode_percentage;
|
||||
print '<a href="#" onclick="return false;" id="change_mode">'.$str_mode_enabled.'</a>';
|
||||
print '<input type="hidden" id="MAIN_USE_METEO_WITH_PERCENTAGE" name="MAIN_USE_METEO_WITH_PERCENTAGE" value="'.$conf->global->MAIN_USE_METEO_WITH_PERCENTAGE.'" />';
|
||||
|
||||
print '<br><br>';
|
||||
|
||||
} else {
|
||||
if(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled');
|
||||
else print $langs->trans('MeteoPercentageModEnabled');
|
||||
print '<br><br>';
|
||||
}
|
||||
|
||||
$offset=0;
|
||||
$cursor=10; // By default
|
||||
//if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
|
||||
@ -267,36 +279,143 @@ $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level
|
||||
$level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
|
||||
$level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
|
||||
$level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
|
||||
$text=''; $options='height="60px"';
|
||||
print '<table>';
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
print img_weather($text,'weather-clear.png',$options);
|
||||
print '</td><td>= '.$level0.'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td>';
|
||||
print img_weather($text,'weather-few-clouds.png',$options);
|
||||
print '</td><td><= '.$level1.'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td>';
|
||||
print img_weather($text,'weather-clouds.png',$options);
|
||||
print '</td><td><= '.$level2.'</td>';
|
||||
print '</tr>';
|
||||
$text=''; $options='class="valignmiddle" height="60px"';
|
||||
|
||||
print '<tr><td>';
|
||||
print img_weather($text,'weather-many-clouds.png',$options);
|
||||
print '</td><td><= '.$level3.'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td>';
|
||||
print img_weather($text,'weather-storm.png',$options);
|
||||
print '</td><td>> '.$level3.'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
if ($action == 'edit') {
|
||||
|
||||
|
||||
print '<div id="standard" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>';
|
||||
|
||||
print '<div>';
|
||||
print '<div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clear.png', $options);
|
||||
print '= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-few-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-many-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<div id="percentage" '.(empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
|
||||
|
||||
print '<div>';
|
||||
print '<div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clear.png',$options);
|
||||
print '= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/> %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-few-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/> %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/> %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-many-clouds.png',$options);
|
||||
print '<= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/> %</td>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#change_mode").click(function() {
|
||||
var use_percent = $("#MAIN_USE_METEO_WITH_PERCENTAGE");
|
||||
var str_mode_std = "<?php print $str_mode_std; ?>";
|
||||
var str_mode_percentage = "<?php print $str_mode_percentage; ?>";
|
||||
|
||||
if(use_percent.val() == 1) {
|
||||
use_percent.val(0);
|
||||
$("#standard").show();
|
||||
$("#percentage").hide();
|
||||
$(this).html(str_mode_std);
|
||||
} else {
|
||||
use_percent.val(1);
|
||||
$("#standard").hide();
|
||||
$("#percentage").show();
|
||||
$(this).html(str_mode_percentage);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
} else {
|
||||
|
||||
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
|
||||
|
||||
print '<div>';
|
||||
print '<div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clear.png',$options);
|
||||
print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.' %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-few-clouds.png',$options);
|
||||
print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.' %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clouds.png',$options);
|
||||
print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.' %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-many-clouds.png',$options);
|
||||
print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %</td>';
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-storm.png',$options);
|
||||
print '> '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %</td>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
} else {
|
||||
|
||||
print '<div>';
|
||||
print '<div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clear.png',$options);
|
||||
print '= '.$level0;
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-few-clouds.png',$options);
|
||||
print '<= '.$level1;
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-clouds.png',$options);
|
||||
print '<= '.$level2;
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-many-clouds.png',$options);
|
||||
print '<= '.$level3;
|
||||
print '</div><div class="inline-block" style="padding-right: 20px">';
|
||||
print img_weather($text,'weather-storm.png',$options);
|
||||
print '> '.$level3;
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
if($action == 'edit') {
|
||||
|
||||
print '<br><div class="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></div>';
|
||||
print '<br></form>';
|
||||
|
||||
} else {
|
||||
|
||||
// Boutons d'action
|
||||
print '<br><div class="tabsAction">';
|
||||
print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a></div>';
|
||||
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -56,9 +56,14 @@ class DolibarrApi
|
||||
$this->db = $db;
|
||||
$production_mode = ( empty($conf->global->API_PRODUCTION_MODE) ? false : true );
|
||||
$this->r = new Restler($production_mode, $refreshCache);
|
||||
|
||||
$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
|
||||
$this->r->setBaseUrls(DOL_MAIN_URL_ROOT, $urlwithroot);
|
||||
|
||||
$urlwithouturlrootautodetect=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim(DOL_MAIN_URL_ROOT));
|
||||
$urlwithrootautodetect=$urlwithouturlroot.DOL_URL_ROOT; // This is to use local domain autodetected by dolibarr from url
|
||||
|
||||
$this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect);
|
||||
$this->r->setAPIVersion(1);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Neil Orley <neil.orley@oeris.fr>
|
||||
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
|
||||
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2017 Neil Orley <neil.orley@oeris.fr>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -21,7 +25,7 @@ require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php';
|
||||
|
||||
/**
|
||||
* API class for payment type (content of the paiement dictionary)
|
||||
* API class for dictionaries
|
||||
*
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
@ -47,13 +51,14 @@ class Dictionary extends DolibarrApi
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number {@min 0}
|
||||
* @param int $active Payment type is active or not {@min 0} {@max 1}
|
||||
* @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')"
|
||||
* @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'CHQ')"
|
||||
*
|
||||
* @url GET payments
|
||||
* @url GET payment/types
|
||||
*
|
||||
* @return List of payment types
|
||||
*
|
||||
* @throws RestException
|
||||
* @return array [List of payment types]
|
||||
*
|
||||
* @throws 400 RestException
|
||||
* @throws 200 OK
|
||||
*/
|
||||
function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
|
||||
{
|
||||
@ -67,9 +72,9 @@ class Dictionary extends DolibarrApi
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
@ -94,7 +99,7 @@ class Dictionary extends DolibarrApi
|
||||
$list[] = $this->db->fetch_object($result);
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieving list of payment types : '.$this->db->lasterror());
|
||||
throw new RestException(400, $this->db->lasterror());
|
||||
}
|
||||
|
||||
return $list;
|
||||
@ -447,6 +452,68 @@ class Dictionary extends DolibarrApi
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of payments terms.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number {@min 0}
|
||||
* @param int $active Payment term is active or not {@min 0} {@max 1}
|
||||
* @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')"
|
||||
*
|
||||
* @url GET payment/terms
|
||||
*
|
||||
* @return array List of payment terms
|
||||
*
|
||||
* @throws 400 RestException
|
||||
* @throws 200 OK
|
||||
*/
|
||||
function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
$sql = "SELECT rowid as id, code, sortorder, libelle as label, libelle_facture as descr, type_cdr, nbjour, decalage, module";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_payment_term as t";
|
||||
$sql.= " WHERE t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
for ($i = 0; $i < $min; $i++) {
|
||||
$list[] = $this->db->fetch_object($result);
|
||||
}
|
||||
} else {
|
||||
throw new RestException(400, $this->db->lasterror());
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ use Luracast\Restler\Format\UploadFormat;
|
||||
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
/**
|
||||
* API class for receive files
|
||||
@ -54,13 +55,57 @@ class Documents extends DolibarrApi
|
||||
*
|
||||
* @param string $module_part Name of module or area concerned by file download ('facture', ...)
|
||||
* @param string $ref Reference of object (This will define subdir automatically)
|
||||
* @param string $subdir Subdirectory (Only if ref not provided)
|
||||
* @param string $subdir NOT YET AVAILABLE : Subdirectory (Only if ref not provided)
|
||||
* @return array List of documents
|
||||
*
|
||||
* @throws RestException
|
||||
* @throws 400
|
||||
* @throws 401
|
||||
* @throws 200 OK
|
||||
*/
|
||||
public function index($module_part, $ref='', $subdir='') {
|
||||
return array('note'=>'FeatureNotYetAvailable');
|
||||
global $conf;
|
||||
|
||||
if (empty($module_part)) {
|
||||
throw new RestException(400, 'bad value for parameter modulepart');
|
||||
}
|
||||
if (empty($ref) && empty($subdir)) {
|
||||
throw new RestException(400, 'bad value for parameter ref or subdir');
|
||||
}
|
||||
if (empty($ref)) {
|
||||
throw new RestException(404, 'FeatureNotYetAvailable');
|
||||
}
|
||||
if (!DolibarrApiAccess::$user->rights->ecm->read) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$original_file = str_replace("../","/", $ref.'/'.$ref.'.pdf');
|
||||
$refname=basename(dirname($original_file)."/");
|
||||
$entity=$conf->entity;
|
||||
|
||||
$check_access = dol_check_secure_access_document($module_part,$original_file,$entity,DolibarrApiAccess::$user);
|
||||
$accessallowed = $check_access['accessallowed'];
|
||||
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
|
||||
$original_file = $check_access['original_file'];
|
||||
|
||||
if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
|
||||
{
|
||||
throw new RestException(401);
|
||||
}
|
||||
if (!$accessallowed) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
$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)' );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1202,14 +1202,13 @@ if ($id > 0)
|
||||
|
||||
// Link to other agenda views
|
||||
$out='';
|
||||
$out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>';
|
||||
$out.='<br>';
|
||||
$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>';
|
||||
$out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>';
|
||||
$out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
|
||||
$linkback.=$out;
|
||||
|
||||
|
||||
@ -907,59 +907,66 @@ class ActionComm extends CommonObject
|
||||
return $db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
|
||||
*
|
||||
* @param User $user Objet user
|
||||
* @param User $user Objet user
|
||||
* @param int $load_state_board Charge indicateurs this->nb de tableau de bord
|
||||
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
|
||||
*/
|
||||
function load_board($user)
|
||||
function load_board($user, $load_state_board=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$sql = "SELECT a.id, a.datep as dp";
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql.= ")";
|
||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
|
||||
$sql.= " WHERE a.percent >= 0 AND a.percent < 100";
|
||||
$sql.= " AND a.entity IN (".getEntity('agenda').")";
|
||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
|
||||
if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
|
||||
if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$agenda_static = new ActionComm($this->db);
|
||||
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay = $conf->agenda->warning_delay/60/60/24;
|
||||
$response->label = $langs->trans("ActionsToDo");
|
||||
$response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda';
|
||||
if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1';
|
||||
$response->img = img_object('',"action",'class="inline-block valigntextmiddle"');
|
||||
|
||||
// This assignment in condition is not a bug. It allows walking the results.
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$response->nbtodo++;
|
||||
|
||||
$agenda_static->datep = $this->db->jdate($obj->dp);
|
||||
|
||||
if ($agenda_static->hasDelay()) {
|
||||
$response->nbtodolate++;
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
global $conf, $langs;
|
||||
|
||||
if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp";
|
||||
else {
|
||||
$this->nb=array();
|
||||
$sql = "SELECT count(a.id) as nb";
|
||||
}
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql.= ")";
|
||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
|
||||
$sql.= " WHERE 1";
|
||||
if(empty($load_state_board)) $sql.= " AND a.percent >= 0 AND a.percent < 100";
|
||||
$sql.= " AND a.entity IN (".getEntity('agenda').")";
|
||||
if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
|
||||
if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
|
||||
if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if(empty($load_state_board)) {
|
||||
$agenda_static = new ActionComm($this->db);
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay = $conf->agenda->warning_delay/60/60/24;
|
||||
$response->label = $langs->trans("ActionsToDo");
|
||||
$response->url = DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda';
|
||||
if ($user->rights->agenda->allactions->read) $response->url.='&filtert=-1';
|
||||
$response->img = img_object('',"action",'class="inline-block valigntextmiddle"');
|
||||
}
|
||||
// This assignment in condition is not a bug. It allows walking the results.
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
if(empty($load_state_board)) {
|
||||
$response->nbtodo++;
|
||||
$agenda_static->datep = $this->db->jdate($obj->dp);
|
||||
if ($agenda_static->hasDelay()) $response->nbtodolate++;
|
||||
} else $this->nb["actionscomm"]=$obj->nb;
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
if(empty($load_state_board)) return $response;
|
||||
else return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -128,14 +128,13 @@ if ($object->id > 0)
|
||||
|
||||
// Link to other agenda views
|
||||
$out='';
|
||||
$out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>';
|
||||
$out.='<br>';
|
||||
$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>';
|
||||
$out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>';
|
||||
$out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
|
||||
|
||||
$linkback.=$out;
|
||||
|
||||
@ -51,6 +51,8 @@ $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|
|
||||
* View
|
||||
*/
|
||||
|
||||
$form=new Form($db);
|
||||
|
||||
$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
|
||||
llxHeader('',$langs->trans("Agenda"),$help_url);
|
||||
|
||||
@ -66,14 +68,13 @@ $linkback.= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php">'.$langs->trans("B
|
||||
|
||||
// Link to other agenda views
|
||||
$out='';
|
||||
$out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>';
|
||||
$out.='<br>';
|
||||
$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>';
|
||||
$out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>';
|
||||
$out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
|
||||
|
||||
$linkback.=$out;
|
||||
|
||||
@ -1530,13 +1530,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;
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
|
||||
print $object->showOptionals($extrafields, 'edit');
|
||||
}
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
|
||||
|
||||
// Lines from source
|
||||
if (! empty($origin) && ! empty($originid) && is_object($objectsrc))
|
||||
|
||||
@ -158,7 +158,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -142,7 +142,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -151,7 +151,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1151,7 +1151,7 @@ class Account extends CommonObject
|
||||
return $solde;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
|
||||
*
|
||||
@ -1161,50 +1161,88 @@ class Account extends CommonObject
|
||||
*/
|
||||
function load_board(User $user, $filteraccountid = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
|
||||
|
||||
$sql = "SELECT b.rowid, b.datev as datefin";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= " WHERE b.rappro=0";
|
||||
$sql.= " AND b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
|
||||
$sql.= " AND clos = 0";
|
||||
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$langs->load("banks");
|
||||
$now=dol_now();
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
|
||||
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24;
|
||||
$response->label=$langs->trans("TransactionsToConciliate");
|
||||
$response->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&mainmenu=bank';
|
||||
$response->img=img_object('',"payment");
|
||||
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$response->nbtodo++;
|
||||
if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) {
|
||||
$response->nbtodolate++;
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
global $conf, $langs;
|
||||
|
||||
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
|
||||
|
||||
$sql = "SELECT b.rowid, b.datev as datefin";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= " WHERE b.rappro=0";
|
||||
$sql.= " AND b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
|
||||
$sql.= " AND clos = 0";
|
||||
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$langs->load("banks");
|
||||
$now=dol_now();
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
|
||||
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay=$conf->bank->rappro->warning_delay/60/60/24;
|
||||
$response->label=$langs->trans("TransactionsToConciliate");
|
||||
$response->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&mainmenu=bank';
|
||||
$response->img=img_object('',"payment");
|
||||
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$response->nbtodo++;
|
||||
if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) {
|
||||
$response->nbtodolate++;
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge indicateurs this->nb de tableau de bord
|
||||
* @param int $filteraccountid To get info for a particular account id
|
||||
* @return int <0 if ko, >0 if ok
|
||||
*/
|
||||
function load_state_board($filteraccountid = 0)
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
|
||||
|
||||
$sql = "SELECT count(b.rowid) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||
$sql.= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable
|
||||
$sql.= " AND clos = 0";
|
||||
if ($filteraccountid) $sql.=" AND ba.rowid = ".$filteraccountid;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$this->nb["banklines"]=$obj->nb;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1737,7 +1737,7 @@ class Facture extends CommonInvoice
|
||||
* @param User $user User making the deletion.
|
||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||
* @param int $idwarehouse Id warehouse to use for stock change.
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @return int <0 if KO, 0=Refused, >0 if OK
|
||||
*/
|
||||
function delete($user, $notrigger=0, $idwarehouse=-1)
|
||||
{
|
||||
@ -1748,9 +1748,13 @@ class Facture extends CommonInvoice
|
||||
|
||||
dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG);
|
||||
|
||||
// TODO Test if there is at least one payment. If yes, refuse to delete.
|
||||
// Test to avoid invoice deletion (allowed if draft)
|
||||
$test = $this->is_erasable();
|
||||
|
||||
if ($test <= 0) return $test;
|
||||
|
||||
$error=0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (! $error && ! $notrigger)
|
||||
@ -3356,9 +3360,9 @@ class Facture extends CommonInvoice
|
||||
/**
|
||||
* Return if an invoice can be deleted
|
||||
* Rule is:
|
||||
* If hidden option INVOICE_CAN_ALWAYS_BE_REMOVED is on, we can
|
||||
* If invoice has a definitive ref, is last, without payment and not dipatched into accountancy -> yes end of rule
|
||||
* If invoice is draft and ha a temporary ref -> yes
|
||||
* If hidden option INVOICE_CAN_ALWAYS_BE_REMOVED is on, we can. If hidden option INVOICE_CAN_NEVER_BE_REMOVED is on, we can't.
|
||||
* If invoice has a definitive ref, is last, without payment and not dipatched into accountancy -> yes end of rule
|
||||
*
|
||||
* @return int <0 if KO, 0=no, 1=yes
|
||||
*/
|
||||
@ -3366,30 +3370,36 @@ class Facture extends CommonInvoice
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// on verifie si la facture est en numerotation provisoire
|
||||
$facref = substr($this->ref, 1, 4);
|
||||
|
||||
if ($this->statut == self::STATUS_DRAFT && $facref == 'PROV') // If draft invoice and ref not yet defined
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (! empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) return 1;
|
||||
if (! empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0;
|
||||
|
||||
// on verifie si la facture est en numerotation provisoire
|
||||
$facref = substr($this->ref, 1, 4);
|
||||
// TODO Test if there is at least one payment. If yes, refuse to delete.
|
||||
// ...
|
||||
|
||||
// If not a draft invoice and not temporary invoice
|
||||
if ($facref != 'PROV')
|
||||
{
|
||||
$maxfacnumber = $this->getNextNumRef($this->thirdparty,'last');
|
||||
$ventilExportCompta = $this->getVentilExportCompta();
|
||||
|
||||
// If there is no invoice into the reset range and not already dispatched, we can delete
|
||||
if ($maxfacnumber == '' && $ventilExportCompta == 0) return 1;
|
||||
// If invoice to delete is last one and not already dispatched, we can delete
|
||||
if ($maxfacnumber == $this->ref && $ventilExportCompta == 0) return 1;
|
||||
|
||||
if ($this->situation_cycle_ref) {
|
||||
$last = $this->is_last_in_cycle();
|
||||
return $last;
|
||||
}
|
||||
}
|
||||
else if ($this->statut == self::STATUS_DRAFT && $facref == 'PROV') // Si facture brouillon et provisoire
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -174,7 +174,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -478,20 +478,20 @@ class RemiseCheque extends CommonObject
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
|
||||
*
|
||||
* @param User $user Objet user
|
||||
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
|
||||
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
|
||||
*
|
||||
* @param User $user Objet user
|
||||
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
|
||||
*/
|
||||
function load_board($user)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
|
||||
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
|
||||
|
||||
|
||||
$sql = "SELECT b.rowid, b.datev as datefin";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
@ -500,28 +500,28 @@ class RemiseCheque extends CommonObject
|
||||
$sql.= " AND b.fk_type = 'CHQ'";
|
||||
$sql.= " AND b.fk_bordereau = 0";
|
||||
$sql.= " AND b.amount > 0";
|
||||
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$langs->load("banks");
|
||||
$now=dol_now();
|
||||
|
||||
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay=$conf->bank->cheque->warning_delay/60/60/24;
|
||||
$response->label=$langs->trans("BankChecksToReceipt");
|
||||
$response->url=DOL_URL_ROOT.'/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank';
|
||||
$response->img=img_object('',"payment");
|
||||
|
||||
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$response->nbtodo++;
|
||||
|
||||
|
||||
if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->cheque->warning_delay)) {
|
||||
$response->nbtodolate++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $response;
|
||||
}
|
||||
else
|
||||
@ -531,6 +531,45 @@ class RemiseCheque extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Charge indicateurs this->nb de tableau de bord
|
||||
*
|
||||
* @return int <0 if ko, >0 if ok
|
||||
*/
|
||||
function load_state_board()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
|
||||
|
||||
$sql = "SELECT count(b.rowid) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= " WHERE b.fk_account = ba.rowid";
|
||||
$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
|
||||
$sql.= " AND b.fk_type = 'CHQ'";
|
||||
$sql.= " AND b.amount > 0";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$this->nb["cheques"]=$obj->nb;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -214,6 +214,12 @@ if ($action == 'create')
|
||||
$pastmonthyear--;
|
||||
}
|
||||
|
||||
$datespmonth = GETPOST('datespmonth', 'int');
|
||||
$datespday = GETPOST('datespday', 'int');
|
||||
$datespyear = GETPOST('datespyear', 'int');
|
||||
$dateepmonth = GETPOST('dateepmonth', 'int');
|
||||
$dateepday = GETPOST('dateepday', 'int');
|
||||
$dateepyear = GETPOST('dateepyear', 'int');
|
||||
$datesp=dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
|
||||
$dateep=dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
|
||||
|
||||
@ -253,7 +259,7 @@ if ($action == 'create')
|
||||
// Label
|
||||
print '<tr><td>';
|
||||
print fieldLabel('Label','label',1).'</td><td>';
|
||||
print '<input name="label" id="label" class="minwidth300" value="'.($_POST["label"]?GETPOST("label",'',2):$langs->trans("SalaryPayment")).'">';
|
||||
print '<input name="label" id="label" class="minwidth300" value="'.(GETPOST("label")?GETPOST("label"):$langs->trans("SalaryPayment")).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Date start period
|
||||
|
||||
@ -160,7 +160,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -133,7 +133,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -159,6 +159,7 @@ if ($action == 'add')
|
||||
$params['options'][$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$result=$extrafields->addExtraField(
|
||||
GETPOST('attrname', 'alpha'),
|
||||
GETPOST('label', 'alpha'),
|
||||
@ -172,7 +173,7 @@ if ($action == 'add')
|
||||
$params,
|
||||
(GETPOST('alwayseditable', 'alpha')?1:0),
|
||||
(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
|
||||
(GETPOST('list', 'alpha')?1:0),
|
||||
GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
|
||||
(GETPOST('ishidden', 'alpha')?1:0),
|
||||
GETPOST('computed_value','alpha'),
|
||||
(GETPOST('entitycurrentorall', 'alpha')?0:''),
|
||||
@ -334,7 +335,7 @@ if ($action == 'update')
|
||||
$params,
|
||||
(GETPOST('alwayseditable', 'alpha')?1:0),
|
||||
(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
|
||||
(GETPOST('list', 'alpha')?1:0),
|
||||
GETPOST('list', 'alpha'), // Same as visible -1=not visible by default in list, 1=visible, 0=not visible in list
|
||||
(GETPOST('ishidden', 'alpha')?1:0),
|
||||
GETPOST('default_value','alpha'),
|
||||
GETPOST('computed_value','alpha'),
|
||||
|
||||
@ -30,9 +30,9 @@ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
if ($object->id)
|
||||
{
|
||||
if (! empty($upload_dirold) && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
|
||||
$result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask'));
|
||||
$result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'));
|
||||
else
|
||||
$result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask'));
|
||||
$result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'));
|
||||
}
|
||||
}
|
||||
elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
@ -57,7 +57,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
|
||||
if ($object->id)
|
||||
{
|
||||
$urlfile = GETPOST('urlfile', 'alpha'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
if (GETPOST('section')) $file = $upload_dir . "/" . $urlfile; // For a delete of GED module urlfile contains full path from upload_dir
|
||||
if (GETPOST('section', 'alpha')) $file = $upload_dir . "/" . $urlfile; // For a delete of GED module urlfile contains full path from upload_dir
|
||||
else // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
|
||||
{
|
||||
$urlfile=basename($urlfile);
|
||||
@ -116,7 +116,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
|
||||
exit;
|
||||
}
|
||||
}
|
||||
elseif ($action == 'confirm_updateline' && GETPOST('save') && GETPOST('link', 'alpha'))
|
||||
elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('link', 'alpha'))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
|
||||
$langs->load('link');
|
||||
@ -150,8 +150,8 @@ elseif ($action == 'renamefile' && GETPOST('renamefilesave'))
|
||||
//var_dump($upload_dir);exit;
|
||||
if (! empty($upload_dir))
|
||||
{
|
||||
$filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom'));
|
||||
$filenameto=dol_sanitizeFileName(GETPOST('renamefileto'));
|
||||
$filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'));
|
||||
$filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'));
|
||||
|
||||
// Security:
|
||||
// Disallow file with some extensions. We rename them.
|
||||
|
||||
@ -418,6 +418,21 @@ abstract class CommonDocGenerator
|
||||
$resarray[$array_key.'_total_discount_ht'] = '';
|
||||
}
|
||||
|
||||
// Fetch project information if there is a project assigned to this object
|
||||
if ($object->element != "project" && ! empty($object->fk_project) && $object->fk_project > 0)
|
||||
{
|
||||
if (! is_object($object->project))
|
||||
{
|
||||
$object->fetch_projet();
|
||||
}
|
||||
|
||||
$resarray[$array_key.'_project_ref'] = $object->project->ref;
|
||||
$resarray[$array_key.'_project_title'] = $object->project->title;
|
||||
$resarray[$array_key.'_project_description'] = $object->project->description;
|
||||
$resarray[$array_key.'_project_date_start'] = dol_print_date($object->project->date_start, 'day');
|
||||
$resarray[$array_key.'_project_date_end'] = dol_print_date($object->project->date_end, 'day');
|
||||
}
|
||||
|
||||
// Add vat by rates
|
||||
if (is_array($object->lines) && count($object->lines)>0)
|
||||
{
|
||||
|
||||
@ -4594,23 +4594,28 @@ abstract class CommonObject
|
||||
}else {
|
||||
$colspan='3';
|
||||
}
|
||||
|
||||
switch($mode) {
|
||||
case "view":
|
||||
$value=$this->array_options["options_".$key];
|
||||
break;
|
||||
case "edit":
|
||||
if (isset($_POST["options_" . $key])) {
|
||||
if (is_array($_POST["options_" . $key])) {
|
||||
// $_POST["options"] is an array but following code expects a comma separated string
|
||||
$value = implode(",", $_POST["options_" . $key]);
|
||||
// GETPOST("options_" . $key) can be 'abc' or array(0=>'abc')
|
||||
$getposttemp = GETPOST('options_'.$key, 'none'); // GETPOST can get value from GET, POST or setup of default values.
|
||||
if (isset($getposttemp)) {
|
||||
if (is_array($getposttemp)) {
|
||||
// $getposttemp is an array but following code expects a comma separated string
|
||||
$value = implode(",", $getposttemp);
|
||||
} else {
|
||||
$value = $_POST["options_" . $key];
|
||||
$value = $getposttemp;
|
||||
}
|
||||
} else {
|
||||
$value = $this->array_options["options_" . $key];
|
||||
$value = $this->array_options["options_" . $key]; // No GET, no POST, no default value, so we take value of object.
|
||||
}
|
||||
break;
|
||||
}
|
||||
//var_dump($value);
|
||||
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
$out .= $extrafields->showSeparator($key);
|
||||
|
||||
@ -140,14 +140,14 @@ class ExtraFields
|
||||
* @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
|
||||
* @param int $alwayseditable Is attribute always editable regardless of the document status
|
||||
* @param string $perms Permission to check
|
||||
* @param int $list Into list view by default
|
||||
* @param int $list Into list view by default (-1, 0 or 1)
|
||||
* @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table)
|
||||
* @param string $computed Computed value
|
||||
* @param string $entity Entity of extrafields
|
||||
* @param string $langfile Language file
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=0, $ishidden=0, $computed='', $entity='', $langfile='')
|
||||
function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list=-1, $ishidden=0, $computed='', $entity='', $langfile='')
|
||||
{
|
||||
if (empty($attrname)) return -1;
|
||||
if (empty($label)) return -1;
|
||||
@ -279,7 +279,7 @@ class ExtraFields
|
||||
* @param array|string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
|
||||
* @param int $alwayseditable Is attribute always editable regardless of the document status
|
||||
* @param string $perms Permission to check
|
||||
* @param int $list Into list view by default
|
||||
* @param int $list Into list view by default (-1, 0 or 1)
|
||||
* @param int $ishidden Is hidden extrafield (warning, do not rely on this. If your module need a hidden data, it must use its own table)
|
||||
* @param string $default Default value (in database. use the default_value feature for default value on screen).
|
||||
* @param string $computed Computed value
|
||||
@ -287,7 +287,7 @@ class ExtraFields
|
||||
* @param string $langfile Language file
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=0, $ishidden=0, $default='', $computed='',$entity='', $langfile='')
|
||||
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=-1, $ishidden=0, $default='', $computed='',$entity='', $langfile='')
|
||||
{
|
||||
global $conf,$user;
|
||||
|
||||
@ -893,7 +893,7 @@ class ExtraFields
|
||||
if (! is_object($form)) $form=new Form($this->db);
|
||||
|
||||
// TODO Must also support $moreparam
|
||||
$out = $form->select_date($value, $keysuffix.'options_'.$key.$keyprefix, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1);
|
||||
$out = $form->select_date($value, $keysuffix.'options_'.$key.$keyprefix, $showtime, $showtime, $required, '', 1, ($keysuffix != 'search_' ? 1 : 0), 1, 0, 1);
|
||||
}
|
||||
elseif (in_array($type,array('int')))
|
||||
{
|
||||
@ -1323,7 +1323,8 @@ class ExtraFields
|
||||
}
|
||||
elseif ($type == 'password')
|
||||
{
|
||||
$out='<input type="password" class="flat '.$showsize.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
|
||||
// If prefix is 'search_', field is used as a filter, we use a common text field.
|
||||
$out='<input type="'.($keysuffix=='search_'?'text':'password').'" class="flat '.$showsize.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
|
||||
}
|
||||
if (!empty($hidden)) {
|
||||
$out='<input type="hidden" value="'.$value.'" name="'.$keysuffix.'options_'.$key.$keyprefix.'" id="'.$keysuffix.'options_'.$key.$keyprefix.'"/>';
|
||||
|
||||
@ -5973,7 +5973,7 @@ class Form
|
||||
|
||||
if ($previous_ref || $next_ref || $morehtml)
|
||||
{
|
||||
$ret.='<div class="pagination"><ul>';
|
||||
$ret.='<div class="pagination paginationref"><ul class="right">';
|
||||
}
|
||||
if ($morehtml)
|
||||
{
|
||||
|
||||
@ -57,21 +57,22 @@ class FormFile
|
||||
/**
|
||||
* Show form to upload a new file
|
||||
*
|
||||
* @param string $url Url
|
||||
* @param string $title Title zone (Title or '' or 'none')
|
||||
* @param string $url Url
|
||||
* @param string $title Title zone (Title or '' or 'none')
|
||||
* @param int $addcancel 1=Add 'Cancel' button
|
||||
* @param int $sectionid If upload must be done inside a particular ECM section
|
||||
* @param int $perm Value of permission to allow upload
|
||||
* @param int $size Length of input file area. Deprecated.
|
||||
* @param Object $object Object to use (when attachment is done on an element)
|
||||
* @param string $options Add an option column
|
||||
* @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). 2 should never be used.
|
||||
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
|
||||
* @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files
|
||||
* @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM)
|
||||
* @param int $size Length of input file area. Deprecated.
|
||||
* @param Object $object Object to use (when attachment is done on an element)
|
||||
* @param string $options Add an option column
|
||||
* @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). 2 should never be used.
|
||||
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
|
||||
* @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files
|
||||
* @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM)
|
||||
* @param string $accept Specifies the types of files accepted (This is not a security check but an user interface facility. eg '.pdf,image/*' or '.png,.jpg' or 'video/*')
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile')
|
||||
function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile', $accept='')
|
||||
{
|
||||
global $conf,$langs, $hookmanager;
|
||||
$hookmanager->initHooks(array('formfile'));
|
||||
@ -130,6 +131,7 @@ class FormFile
|
||||
$out .= '<input class="flat minwidth400" type="file"';
|
||||
$out .= ((! empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $conf->browser->layout != 'classic')?' name="userfile"':' name="userfile[]" multiple');
|
||||
$out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled':'');
|
||||
$out .= (!empty($accept)?' accept="'.$accept.'"':'accept=""');
|
||||
$out .= '>';
|
||||
$out .= ' ';
|
||||
$out .= '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"';
|
||||
|
||||
@ -506,26 +506,26 @@ function getDateFromFormat(val,format)
|
||||
if (substr == "MM" ||substr == "M")
|
||||
{
|
||||
month=getIntegerInString(val,d,1,2);
|
||||
d -= 2- month.length;
|
||||
if (month) d -= 2- month.length;
|
||||
}
|
||||
if (substr == "dd")
|
||||
{
|
||||
day=getIntegerInString(val,d,1,2);
|
||||
d -= 2- day.length;
|
||||
if (day) d -= 2- day.length;
|
||||
}
|
||||
if (substr == "HH" ||substr == "hh" )
|
||||
{
|
||||
hour=getIntegerInString(val,d,1,2);
|
||||
d -= 2- hour.length;
|
||||
if (dhouray) d -= 2- hour.length;
|
||||
}
|
||||
if (substr == "mm"){
|
||||
minute=getIntegerInString(val,d,1,2);
|
||||
d -= 2- minute.length;
|
||||
if (minute) d -= 2- minute.length;
|
||||
}
|
||||
if (substr == "ss")
|
||||
{
|
||||
seconde=getIntegerInString(val,d,1,2);
|
||||
d -= 2- seconde.length;
|
||||
if (seconde) d -= 2- seconde.length;
|
||||
}
|
||||
|
||||
i+=substr.length;
|
||||
|
||||
@ -1475,19 +1475,17 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
|
||||
$destfull=$upload_dir . "/" . $TFile['name'][$i];
|
||||
$destfile=$TFile['name'][$i];
|
||||
|
||||
$savingdocmask = dol_sanitizeFileName($savingdocmask);
|
||||
|
||||
if ($savingdocmask)
|
||||
{
|
||||
$destfull=$upload_dir . "/" . preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask);
|
||||
$destfile=preg_replace('/__file__/',$TFile['name'][$i],$savingdocmask);
|
||||
}
|
||||
|
||||
// lowercase extension
|
||||
// dol_sanitizeFileName the file name and lowercase extension
|
||||
$info = pathinfo($destfull);
|
||||
$destfull = $info['dirname'].'/'.$info['filename'].'.'.strtolower($info['extension']);
|
||||
$destfull = $info['dirname'].'/'.dol_sanitizeFileName($info['filename'].'.'.strtolower($info['extension']));
|
||||
$info = pathinfo($destfile);
|
||||
$destfile = $info['filename'].'.'.strtolower($info['extension']);
|
||||
$destfile = dol_sanitizeFileName($info['filename'].'.'.strtolower($info['extension']));
|
||||
|
||||
$resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles);
|
||||
|
||||
|
||||
@ -312,111 +312,126 @@ function GETPOST($paramname, $check='alpha', $method=0, $filter=NULL, $options=N
|
||||
{
|
||||
if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname]))
|
||||
{
|
||||
if (! empty($user->default_values)) // $user->default_values defined from menu default values
|
||||
if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values'
|
||||
{
|
||||
$qualified=1;
|
||||
if (isset($user->default_values[$relativepathstring]['createform_queries'])) // Even if paramname is sortfield, data are stored into ['sortorder...']
|
||||
{
|
||||
$tmpqueryarraytohave=explode('&', $user->default_values[$relativepathstring]['createform_queries']);
|
||||
$tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
||||
foreach($tmpqueryarraytohave as $tmpquerytohave)
|
||||
{
|
||||
if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $qualified=0;
|
||||
}
|
||||
}
|
||||
if ($qualified)
|
||||
if (isset($user->default_values[$relativepathstring]['createform']))
|
||||
{
|
||||
//var_dump($user->default_values[$relativepathstring]['createform']);
|
||||
if (isset($user->default_values[$relativepathstring]['createform'][$paramname])) $out = $user->default_values[$relativepathstring]['createform'][$paramname];
|
||||
foreach($user->default_values[$relativepathstring]['createform'] as $defkey => $defval)
|
||||
{
|
||||
$qualified = 0;
|
||||
if ($defkey != '_noquery_')
|
||||
{
|
||||
$tmpqueryarraytohave=explode('&', $defkey);
|
||||
$tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
||||
$foundintru=0;
|
||||
foreach($tmpqueryarraytohave as $tmpquerytohave)
|
||||
{
|
||||
if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1;
|
||||
}
|
||||
if (! $foundintru) $qualified=1;
|
||||
//var_dump($defkey.'-'.$qualified);
|
||||
}
|
||||
else $qualified = 1;
|
||||
|
||||
if ($qualified)
|
||||
{
|
||||
//var_dump($user->default_values[$relativepathstring][$defkey]['createform']);
|
||||
if (isset($user->default_values[$relativepathstring]['createform'][$defkey][$paramname]))
|
||||
{
|
||||
$out = $user->default_values[$relativepathstring]['createform'][$defkey][$paramname];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Management of default search_filters and sort order
|
||||
//elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname]))
|
||||
elseif (! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname]))
|
||||
{
|
||||
if (! empty($user->default_values)) // $user->default_values defined from menu default values
|
||||
if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values'
|
||||
{
|
||||
//var_dump($user->default_values[$relativepathstring]);
|
||||
if ($paramname == 'sortfield') // Sorted on which fields ?
|
||||
if ($paramname == 'sortfield' || $paramname == 'sortorder') // Sorted on which fields ? ASC or DESC ?
|
||||
{
|
||||
$qualified=1;
|
||||
if (isset($user->default_values[$relativepathstring]['sortorder_queries'])) // Even if paramname is sortfield, data are stored into ['sortorder...']
|
||||
if (isset($user->default_values[$relativepathstring]['sortorder'])) // Even if paramname is sortfield, data are stored into ['sortorder...']
|
||||
{
|
||||
$tmpqueryarraytohave=explode('&', $user->default_values[$relativepathstring]['sortorder_queries']);
|
||||
$tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
||||
foreach($tmpqueryarraytohave as $tmpquerytohave)
|
||||
foreach($user->default_values[$relativepathstring]['sortorder'] as $defkey => $defval)
|
||||
{
|
||||
if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $qualified=0;
|
||||
}
|
||||
}
|
||||
if ($qualified)
|
||||
{
|
||||
if (isset($user->default_values[$relativepathstring]['sortorder'])) // We will use the key of $user->default_values[path][sortorder]
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val)
|
||||
{
|
||||
if ($out) $out.=', ';
|
||||
$out.=dol_string_nospecial($key, '', $forbidden_chars_to_replace);
|
||||
}
|
||||
$qualified = 0;
|
||||
if ($defkey != '_noquery_')
|
||||
{
|
||||
$tmpqueryarraytohave=explode('&', $defkey);
|
||||
$tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
||||
$foundintru=0;
|
||||
foreach($tmpqueryarraytohave as $tmpquerytohave)
|
||||
{
|
||||
if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1;
|
||||
}
|
||||
if (! $foundintru) $qualified=1;
|
||||
//var_dump($defkey.'-'.$qualified);
|
||||
}
|
||||
else $qualified = 1;
|
||||
|
||||
if ($qualified)
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
foreach($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val)
|
||||
{
|
||||
if ($out) $out.=', ';
|
||||
if ($paramname == 'sortfield')
|
||||
{
|
||||
$out.=dol_string_nospecial($key, '', $forbidden_chars_to_replace);
|
||||
}
|
||||
if ($paramname == 'sortorder')
|
||||
{
|
||||
$out.=dol_string_nospecial($val, '', $forbidden_chars_to_replace);
|
||||
}
|
||||
}
|
||||
//break; // No break for sortfield and sortorder so we can cumulate fields (is it realy usefull ?)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($paramname == 'sortorder') // ASC or DESC ?
|
||||
elseif (isset($user->default_values[$relativepathstring]['filters']))
|
||||
{
|
||||
$qualified=1;
|
||||
if (isset($user->default_values[$relativepathstring]['sortorder_queries']))
|
||||
foreach($user->default_values[$relativepathstring]['filters'] as $defkey => $defval)
|
||||
{
|
||||
$tmpqueryarraytohave=explode('&', $user->default_values[$relativepathstring]['sortorder_queries']);
|
||||
$tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
||||
foreach($tmpqueryarraytohave as $tmpquerytohave)
|
||||
{
|
||||
if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $qualified=0;
|
||||
}
|
||||
}
|
||||
if ($qualified)
|
||||
{
|
||||
if (isset($user->default_values[$relativepathstring]['sortorder'])) // We will use the val of $user->default_values[path][sortorder]
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
foreach($user->default_values[$relativepathstring]['sortorder'] as $key => $val)
|
||||
{
|
||||
if ($out) $out.=', ';
|
||||
$out.=dol_string_nospecial($val, '', $forbidden_chars_to_replace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (isset($user->default_values[$relativepathstring]['filters'][$paramname]))
|
||||
{
|
||||
$qualified=1;
|
||||
if (isset($user->default_values[$relativepathstring]['filters_queries']))
|
||||
{
|
||||
$tmpqueryarraytohave=explode('&', $user->default_values[$relativepathstring]['filters_queries']);
|
||||
$tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
||||
foreach($tmpqueryarraytohave as $tmpquerytohave)
|
||||
{
|
||||
if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $qualified=0;
|
||||
}
|
||||
}
|
||||
if ($qualified)
|
||||
{
|
||||
if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all']))
|
||||
$qualified = 0;
|
||||
if ($defkey != '_noquery_')
|
||||
{
|
||||
// We made a search from quick search menu, do we still use default filter ?
|
||||
if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH))
|
||||
$tmpqueryarraytohave=explode('&', $defkey);
|
||||
$tmpqueryarraywehave=explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
||||
$foundintru=0;
|
||||
foreach($tmpqueryarraytohave as $tmpquerytohave)
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
$out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$paramname], '', $forbidden_chars_to_replace);
|
||||
if (! in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru=1;
|
||||
}
|
||||
if (! $foundintru) $qualified=1;
|
||||
//var_dump($defkey.'-'.$qualified);
|
||||
}
|
||||
else
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
$out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$paramname], '', $forbidden_chars_to_replace);
|
||||
}
|
||||
}
|
||||
else $qualified = 1;
|
||||
|
||||
if ($qualified)
|
||||
{
|
||||
if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all']))
|
||||
{
|
||||
// We made a search from quick search menu, do we still use default filter ?
|
||||
if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH))
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
$out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$forbidden_chars_to_replace=array(" ","'","/","\\",":","*","?","\"","<",">","|","[","]",";","="); // we accept _, -, . and ,
|
||||
$out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -424,14 +439,14 @@ function GETPOST($paramname, $check='alpha', $method=0, $filter=NULL, $options=N
|
||||
|
||||
}
|
||||
|
||||
// Substitution variables for GETPOST (used to get final url with variable parameters or final default value with variable paramaters)
|
||||
// Example of variables: __DAY__, __MONTH__, __YEAR__, __MYCOUNTRYID__, __USERID__, __ENTITYID__, ...
|
||||
// We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text.
|
||||
if (! is_array($out) && empty($_POST[$paramname]))
|
||||
// Substitution variables for GETPOST (used to get final url with variable parameters or final default value with variable paramaters)
|
||||
// Example of variables: __DAY__, __MONTH__, __YEAR__, __MYCOUNTRYID__, __USERID__, __ENTITYID__, ...
|
||||
// We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text.
|
||||
if (! is_array($out) && empty($_POST[$paramname]))
|
||||
{
|
||||
$maxloop=20; $loopnb=0; // Protection against infinite loop
|
||||
while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side.
|
||||
{
|
||||
$maxloop=20; $loopnb=0; // Protection against infinite loop
|
||||
while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side.
|
||||
{
|
||||
$loopnb++; $newout = '';
|
||||
|
||||
if ($reg[1] == 'DAY') { $tmp=dol_getdate(dol_now(), true); $newout = $tmp['mday']; }
|
||||
@ -462,57 +477,57 @@ function GETPOST($paramname, $check='alpha', $method=0, $filter=NULL, $options=N
|
||||
else $newout = ''; // Key not found, we replace with empty string
|
||||
//var_dump('__'.$reg[1].'__ -> '.$newout);
|
||||
$out = preg_replace('/__'.preg_quote($reg[1],'/').'__/', $newout, $out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check is done after replacement
|
||||
switch ($check)
|
||||
{
|
||||
case 'none':
|
||||
break;
|
||||
case 'int': // Check param is a numeric value (integer but also float or hexadecimal)
|
||||
if (! is_numeric($out)) { $out=''; }
|
||||
break;
|
||||
case 'intcomma':
|
||||
if (preg_match('/[^0-9,]+/i',$out)) $out='';
|
||||
break;
|
||||
case 'alpha':
|
||||
$out=trim($out);
|
||||
// '"' is dangerous because param in url can close the href= or src= and add javascript functions.
|
||||
// '../' is dangerous because it allows dir transversals
|
||||
if (preg_match('/"/',$out)) $out='';
|
||||
else if (preg_match('/\.\.\//',$out)) $out='';
|
||||
break;
|
||||
case 'san_alpha':
|
||||
$out=filter_var($out,FILTER_SANITIZE_STRING);
|
||||
break;
|
||||
case 'aZ':
|
||||
$out=trim($out);
|
||||
if (preg_match('/[^a-z]+/i',$out)) $out='';
|
||||
break;
|
||||
case 'aZ09':
|
||||
$out=trim($out);
|
||||
if (preg_match('/[^a-z0-9_\-\.]+/i',$out)) $out='';
|
||||
break;
|
||||
case 'array':
|
||||
if (! is_array($out) || empty($out)) $out=array();
|
||||
break;
|
||||
case 'nohtml':
|
||||
$out=dol_string_nohtmltag($out);
|
||||
break;
|
||||
case 'alphanohtml': // Recommended for search params
|
||||
$out=trim($out);
|
||||
// '"' is dangerous because param in url can close the href= or src= and add javascript functions.
|
||||
// '../' is dangerous because it allows dir transversals
|
||||
if (preg_match('/"/',$out)) $out='';
|
||||
else if (preg_match('/\.\.\//',$out)) $out='';
|
||||
$out=dol_string_nohtmltag($out);
|
||||
break;
|
||||
case 'custom':
|
||||
if (empty($filter)) return 'BadFourthParameterForGETPOST';
|
||||
$out=filter_var($out, $filter, $options);
|
||||
break;
|
||||
}
|
||||
// Check is done after replacement
|
||||
switch ($check)
|
||||
{
|
||||
case 'none':
|
||||
break;
|
||||
case 'int': // Check param is a numeric value (integer but also float or hexadecimal)
|
||||
if (! is_numeric($out)) { $out=''; }
|
||||
break;
|
||||
case 'intcomma':
|
||||
if (preg_match('/[^0-9,]+/i',$out)) $out='';
|
||||
break;
|
||||
case 'alpha':
|
||||
$out=trim($out);
|
||||
// '"' is dangerous because param in url can close the href= or src= and add javascript functions.
|
||||
// '../' is dangerous because it allows dir transversals
|
||||
if (preg_match('/"/',$out)) $out='';
|
||||
else if (preg_match('/\.\.\//',$out)) $out='';
|
||||
break;
|
||||
case 'san_alpha':
|
||||
$out=filter_var($out,FILTER_SANITIZE_STRING);
|
||||
break;
|
||||
case 'aZ':
|
||||
$out=trim($out);
|
||||
if (preg_match('/[^a-z]+/i',$out)) $out='';
|
||||
break;
|
||||
case 'aZ09':
|
||||
$out=trim($out);
|
||||
if (preg_match('/[^a-z0-9_\-\.]+/i',$out)) $out='';
|
||||
break;
|
||||
case 'array':
|
||||
if (! is_array($out) || empty($out)) $out=array();
|
||||
break;
|
||||
case 'nohtml':
|
||||
$out=dol_string_nohtmltag($out);
|
||||
break;
|
||||
case 'alphanohtml': // Recommended for search params
|
||||
$out=trim($out);
|
||||
// '"' is dangerous because param in url can close the href= or src= and add javascript functions.
|
||||
// '../' is dangerous because it allows dir transversals
|
||||
if (preg_match('/"/',$out)) $out='';
|
||||
else if (preg_match('/\.\.\//',$out)) $out='';
|
||||
$out=dol_string_nohtmltag($out);
|
||||
break;
|
||||
case 'custom':
|
||||
if (empty($filter)) return 'BadFourthParameterForGETPOST';
|
||||
$out=filter_var($out, $filter, $options);
|
||||
break;
|
||||
}
|
||||
|
||||
// Code for search criteria persistence.
|
||||
// Save data into session if key start with 'search_' or is 'smonth', 'syear', 'month', 'year'
|
||||
@ -745,7 +760,7 @@ function dol_size($size,$type='')
|
||||
*/
|
||||
function dol_sanitizeFileName($str,$newstr='_',$unaccent=1)
|
||||
{
|
||||
$filesystem_forbidden_chars = array('<','>',':','/','\\','?','*','|','"','°');
|
||||
$filesystem_forbidden_chars = array('<','>','/','\\','?','*','|','"','°');
|
||||
return dol_string_nospecial($unaccent?dol_string_unaccent($str):$str, $newstr, $filesystem_forbidden_chars);
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Dolibarr geturl function');
|
||||
|
||||
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, ($followlocation?true:false)); // We use @ here because this may return warning if safe mode is on or open_basedir is on
|
||||
|
||||
|
||||
if (count($addheaders)) curl_setopt($ch, CURLOPT_HTTPHEADER, $addheaders);
|
||||
curl_setopt($ch, CURLINFO_HEADER_OUT, true); // To be able to retrieve request header and log it
|
||||
|
||||
@ -63,7 +63,7 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
// You can force, if supported a version like TLSv1 or TLSv1.2
|
||||
if (! empty($conf->global->MAIN_CURL_SSLVERSION)) curl_setopt($ch, CURLOPT_SSLVERSION, $conf->global->MAIN_CURL_SSLVERSION);
|
||||
//curl_setopt($ch, CURLOPT_SSLVERSION, 6); for tls 1.2
|
||||
|
||||
|
||||
//turning off the server and peer verification(TrustManager Concept).
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
||||
@ -82,12 +82,12 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
{
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); // HTTP request is 'PUT'
|
||||
if (! is_array($param)) parse_str($param, $array_param);
|
||||
else
|
||||
else
|
||||
{
|
||||
dol_syslog("parameter param must be a string", LOG_WARNING);
|
||||
$array_param=$param;
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param)); // Setting param x=a&y=z as PUT fields
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array_param)); // Setting param x=a&y=z as PUT fields
|
||||
}
|
||||
else if ($postorget == 'PUTALREADYFORMATED')
|
||||
{
|
||||
@ -121,7 +121,7 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
$response = curl_exec($ch);
|
||||
|
||||
$request = curl_getinfo($ch, CURLINFO_HEADER_OUT); // Reading of request must be done after sending request
|
||||
|
||||
|
||||
dol_syslog("getURLContent request=".$request);
|
||||
dol_syslog("getURLContent response=".$response);
|
||||
|
||||
@ -130,7 +130,7 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
{
|
||||
// Ad keys to $rep
|
||||
$rep['content']=$response;
|
||||
|
||||
|
||||
// moving to display page to display curl errors
|
||||
$rep['curl_error_no']=curl_errno($ch);
|
||||
$rep['curl_error_msg']=curl_error($ch);
|
||||
@ -146,12 +146,12 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
//$rep['header_size']=$info['header_size'];
|
||||
//$rep['http_code']=$info['http_code'];
|
||||
dol_syslog("getURLContent http_code=".$rep['http_code']);
|
||||
|
||||
|
||||
// Add more keys to $rep
|
||||
$rep['content']=$response;
|
||||
$rep['curl_error_no']='';
|
||||
$rep['curl_error_msg']='';
|
||||
|
||||
|
||||
//closing the curl
|
||||
curl_close($ch);
|
||||
}
|
||||
@ -159,3 +159,19 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea
|
||||
return $rep;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function get second level domain name.
|
||||
* For example: https://www.abc.mydomain.com/dir/page.html return 'mydomain'
|
||||
*
|
||||
* @param string $url Full URL.
|
||||
* @return string Returns domaine name
|
||||
*/
|
||||
function getDomainFromURL($url)
|
||||
{
|
||||
$tmpdomain = preg_replace('/^https?:\/\//i', '', $url); // Remove http(s)://
|
||||
$tmpdomain = preg_replace('/\/.*$/i', '', $tmpdomain); // Remove part after domain
|
||||
$tmpdomain = preg_replace('/\.[^\.]+$/', '', $tmpdomain); // Remove first level domain (.com, .net, ...)
|
||||
$tmpdomain = preg_replace('/^[^\.]+\./', '', $tmpdomain); // Remove part www. before domain name
|
||||
return $tmpdomain;
|
||||
}
|
||||
|
||||
@ -252,7 +252,8 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu
|
||||
{
|
||||
//print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write;
|
||||
if (empty($user->rights->$feature->creer)
|
||||
&& empty($user->rights->$feature->write)) { $createok=0; $nbko++; }
|
||||
&& empty($user->rights->$feature->write)
|
||||
&& empty($user->rights->$feature->create)) { $createok=0; $nbko++; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -122,6 +122,8 @@ class pdf_paiement
|
||||
|
||||
$month = sprintf("%02d",$month);
|
||||
$year = sprintf("%04d",$year);
|
||||
|
||||
$file = $dir . "/payments-".$year."-".$month.".pdf";
|
||||
switch ($this->doc_type) {
|
||||
case "client":
|
||||
$file = $dir . "/payments-".$year."-".$month.".pdf";
|
||||
@ -251,7 +253,7 @@ class pdf_paiement
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
|
||||
|
||||
|
||||
$lines[$i][0] = $objp->facnumber;
|
||||
$lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true);
|
||||
@ -328,9 +330,9 @@ class pdf_paiement
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -170,7 +170,7 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
|
||||
{
|
||||
$fullpath=$dir."/".$original_file;
|
||||
$result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']);
|
||||
|
||||
|
||||
if ($result == $fullpath)
|
||||
{
|
||||
$object->addThumbs($fullpath);
|
||||
@ -178,7 +178,7 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
|
||||
// Update/create database for file $fullpath
|
||||
$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath);
|
||||
$rel_filename = preg_replace('/^[\\/]/','',$rel_filename);
|
||||
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($db);
|
||||
$result = $ecmfile->fetch(0, '', $rel_filename);
|
||||
@ -188,7 +188,7 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
|
||||
$rel_dir = dirname($rel_filename);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
|
||||
|
||||
$ecmfile->label = md5_file(dol_osencode($fullpath));
|
||||
$result = $ecmfile->update($user);
|
||||
}
|
||||
@ -198,7 +198,7 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
|
||||
$rel_dir = dirname($rel_filename);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
|
||||
|
||||
$ecmfile->filepath = $rel_dir;
|
||||
$ecmfile->filename = $filename;
|
||||
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
|
||||
@ -213,7 +213,7 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
|
||||
}
|
||||
$result = $ecmfile->create($user);
|
||||
}
|
||||
|
||||
|
||||
if ($backtourl)
|
||||
{
|
||||
header("Location: ".$backtourl);
|
||||
@ -246,7 +246,7 @@ if ($action == 'confirm_crop')
|
||||
// Update/create database for file $fullpath
|
||||
$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath);
|
||||
$rel_filename = preg_replace('/^[\\/]/','',$rel_filename);
|
||||
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($db);
|
||||
$result = $ecmfile->fetch(0, '', $rel_filename);
|
||||
@ -256,7 +256,7 @@ if ($action == 'confirm_crop')
|
||||
$rel_dir = dirname($rel_filename);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
|
||||
|
||||
$ecmfile->label = md5_file(dol_osencode($fullpath));
|
||||
$result = $ecmfile->update($user);
|
||||
}
|
||||
@ -266,7 +266,7 @@ if ($action == 'confirm_crop')
|
||||
$rel_dir = dirname($rel_filename);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
|
||||
|
||||
$ecmfile->filepath = $rel_dir;
|
||||
$ecmfile->filename = $filename;
|
||||
$ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
|
||||
@ -281,7 +281,7 @@ if ($action == 'confirm_crop')
|
||||
}
|
||||
$result = $ecmfile->create($user);
|
||||
}
|
||||
|
||||
|
||||
if ($backtourl)
|
||||
{
|
||||
header("Location: ".$backtourl);
|
||||
@ -311,7 +311,7 @@ llxHeader($head, $langs->trans("Image"), '', '', 0, 0, array('/includes/jquery/p
|
||||
|
||||
print load_fiche_titre($langs->trans("ImageEditor"));
|
||||
|
||||
$infoarray=dol_getImageSize($dir."/".GETPOST("file"));
|
||||
$infoarray=dol_getImageSize($dir."/".GETPOST("file",'alpha'));
|
||||
$height=$infoarray['height'];
|
||||
$width=$infoarray['width'];
|
||||
print $langs->trans("CurrentInformationOnImage").': ';
|
||||
@ -373,7 +373,7 @@ if (! empty($conf->use_javascript_ajax))
|
||||
print $langs->trans("DefineNewAreaToPick").'...<br>';
|
||||
print '<br><div class="center">';
|
||||
print '<div style="border: 1px solid #888888; width: '.$widthforcrop.'px;">';
|
||||
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.$original_file.'" alt="" id="cropbox" width="'.$widthforcrop.'px"/>';
|
||||
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$object->entity.'&file='.urlencode($original_file).'" alt="" id="cropbox" width="'.$widthforcrop.'px"/>';
|
||||
print '</div>';
|
||||
print '</div><br>';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST">
|
||||
|
||||
@ -26,6 +26,8 @@
|
||||
* $elementtype
|
||||
*/
|
||||
|
||||
$langs->load("modulebuilder");
|
||||
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE admin_extrafields_add.tpl.php -->
|
||||
@ -101,13 +103,13 @@
|
||||
|
||||
if (type == 'separate')
|
||||
{
|
||||
required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true);
|
||||
required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.removeAttr('checked').prop('disabled', true);
|
||||
jQuery('#size, #default_value').val('').prop('disabled', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
default_value.removeAttr('disabled');
|
||||
required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled');
|
||||
required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.removeAttr('disabled');
|
||||
}
|
||||
}
|
||||
init_typeoffields('<?php echo GETPOST('type','alpha'); ?>');
|
||||
@ -178,12 +180,9 @@
|
||||
<?php if ($conf->multicompany->enabled) { ?>
|
||||
<tr><td><?php echo $langs->trans("AllEntities"); ?></td><td class="valeur"><input id="entitycurrentorall" type="checkbox" name="entitycurrentorall"<?php echo (GETPOST('entitycurrentorall','alpha') ? '':' checked'); ?>></td></tr>
|
||||
<?php } ?>
|
||||
<?php if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { ?>
|
||||
<!-- By default visible into list -->
|
||||
<tr><td><?php echo $langs->trans("ByDefaultInList"); ?>
|
||||
<?php echo img_info($langs->trans("FeatureNotYetSupported")); ?>
|
||||
</td><td class="valeur"><input id="list" type="checkbox" name="list" <?php echo (GETPOST('list','alpha')?' checked':''); ?>></td></tr>
|
||||
<?php } ?>
|
||||
<tr><td class="extra_list"><?php echo $form->textwithpicto($langs->trans("ByDefaultInList"), $langs->trans("VisibleDesc")); ?>
|
||||
</td><td class="valeur"><input id="list" size="1" type="text" name="list" value="<?php echo GETPOST('list','int')!='' ? GETPOST('list','int') : '1'; ?>"></td></tr>
|
||||
</table>
|
||||
|
||||
<?php dol_fiche_end(); ?>
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
* $elementtype
|
||||
*/
|
||||
|
||||
$langs->load("modulebuilder");
|
||||
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE admin_extrafields_edit.tpl.php -->
|
||||
@ -96,13 +98,13 @@
|
||||
|
||||
if (type == 'separate')
|
||||
{
|
||||
required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.val('').prop('disabled', true);
|
||||
required.removeAttr('checked').prop('disabled', true); alwayseditable.removeAttr('checked').prop('disabled', true); list.removeAttr('checked').prop('disabled', true);
|
||||
jQuery('#size, #default_value').val('').prop('disabled', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
default_value.removeAttr('disabled');
|
||||
required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.val('').removeAttr('disabled');
|
||||
required.removeAttr('disabled'); alwayseditable.removeAttr('disabled'); list.removeAttr('disabled');
|
||||
}
|
||||
}
|
||||
init_typeoffields(jQuery("#type").val());
|
||||
@ -238,11 +240,8 @@ else
|
||||
<tr><td><?php echo $langs->trans("AllEntities"); ?></td><td class="valeur"><input id="entitycurrentorall" type="checkbox" name="entitycurrentorall"<?php echo (empty($entitycurrentorall) ?' checked':''); ?>></td></tr>
|
||||
<?php } ?>
|
||||
<!-- By default visible into list -->
|
||||
<?php if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { ?>
|
||||
<tr><td><?php echo $langs->trans("ByDefaultInList"); ?>
|
||||
<?php echo img_info($langs->trans("FeatureNotYetSupported")); ?>
|
||||
</td><td class="valeur"><input id="list" type="checkbox" name="list" <?php echo ($list?' checked':''); ?>></td></tr>
|
||||
<?php } ?>
|
||||
<tr><td class="extra_list"><?php echo $form->textwithpicto($langs->trans("ByDefaultInList"), $langs->trans("VisibleDesc")); ?>
|
||||
</td><td class="valeur"><input id="list" size="1" type="text" name="list" value="<?php echo ($list!=''?$list:'1'); ?>"></td></tr>
|
||||
</table>
|
||||
|
||||
<?php dol_fiche_end(); ?>
|
||||
|
||||
@ -22,6 +22,9 @@
|
||||
* $extrafield
|
||||
* $elementtype
|
||||
*/
|
||||
|
||||
$langs->load("modulebuilder");
|
||||
|
||||
?>
|
||||
|
||||
<!-- BEGIN PHP TEMPLATE admin_extrafields_view.tpl.php -->
|
||||
@ -48,6 +51,7 @@ print '<td align="center">'.$langs->trans("Unique").'</td>';
|
||||
print '<td>'.$langs->trans("ComputedFormula").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Required").'</td>';
|
||||
print '<td align="center">'.$langs->trans("AlwaysEditable").'</td>';
|
||||
print '<td align="center">'.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).'</td>';
|
||||
if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print '<td align="center">'.$langs->trans("Hidden").'</td>';
|
||||
if ($conf->multicompany->enabled) {
|
||||
print '<td align="center">'.$langs->trans("Entities").'</td>';
|
||||
@ -59,7 +63,7 @@ if (count($extrafields->attribute_type))
|
||||
{
|
||||
foreach($extrafields->attribute_type as $key => $value)
|
||||
{
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print "<td>".$extrafields->attribute_pos[$key]."</td>\n";
|
||||
print "<td>".$extrafields->attribute_label[$key]."</td>\n";
|
||||
@ -70,7 +74,8 @@ if (count($extrafields->attribute_type))
|
||||
print '<td>'.dol_trunc($extrafields->attribute_computed[$key], 20)."</td>\n";
|
||||
print '<td align="center">'.yn($extrafields->attribute_required[$key])."</td>\n";
|
||||
print '<td align="center">'.yn($extrafields->attribute_alwayseditable[$key])."</td>\n";
|
||||
if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print '<td align="center">'.yn($extrafields->attribute_hidden[$key])."</td>\n"; // Add hidden option on not working feature. Why hide if user can't see it.
|
||||
print '<td align="center">'.$extrafields->attribute_list[$key]."</td>\n";
|
||||
if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) print '<td align="center">'.yn($extrafields->attribute_hidden[$key])."</td>\n"; // Add hidden option on not working feature. Why hide if user can't see it.
|
||||
if ($conf->multicompany->enabled) {
|
||||
print '<td align="center">'.($extrafields->attribute_entityid[$key]==0?$langs->trans("All"):$extrafields->attribute_entitylabel[$key]).'</td>';
|
||||
}
|
||||
@ -83,7 +88,7 @@ else
|
||||
{
|
||||
$colspan=9;
|
||||
if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) $colspan++;
|
||||
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="opacitymedium" colspan="'.$colspan.'">';
|
||||
print $langs->trans("None");
|
||||
|
||||
@ -79,7 +79,7 @@ $formfile->form_attach_new_file(
|
||||
);
|
||||
|
||||
$disablemove=1;
|
||||
if ($modulepart == 'produit') $disablemove=0;
|
||||
if ($modulepart == 'product' || $modulepart == 'produit') $disablemove=0; // Drag and drop for up and down allowed on product
|
||||
|
||||
// List of document
|
||||
$formfile->list_of_documents(
|
||||
|
||||
40
htdocs/core/tpl/extrafields_add.tpl.php
Normal file
40
htdocs/core/tpl/extrafields_add.tpl.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Maxime Kohlhaas <support@atm-consulting.fr>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Need to have following variables defined:
|
||||
* $object (invoice, order, ...)
|
||||
* $action
|
||||
* $conf
|
||||
* $langs
|
||||
*
|
||||
* $parameters
|
||||
* $cols
|
||||
*/
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE extrafields_add.tpl.php -->
|
||||
<?php
|
||||
|
||||
// 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;
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
|
||||
print $object->showOptionals($extrafields, 'edit');
|
||||
}
|
||||
|
||||
?>
|
||||
<!-- END PHP TEMPLATE extrafields_add.tpl.php -->
|
||||
40
htdocs/core/tpl/extrafields_edit.tpl.php
Normal file
40
htdocs/core/tpl/extrafields_edit.tpl.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Maxime Kohlhaas <support@atm-consulting.fr>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Need to have following variables defined:
|
||||
* $object (invoice, order, ...)
|
||||
* $action
|
||||
* $conf
|
||||
* $langs
|
||||
*
|
||||
* $parameters
|
||||
* $cols
|
||||
*/
|
||||
?>
|
||||
<!-- BEGIN PHP TEMPLATE extrafields_edit.tpl.php -->
|
||||
<?php
|
||||
|
||||
// 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;
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
|
||||
print $object->showOptionals($extrafields, 'edit');
|
||||
}
|
||||
|
||||
?>
|
||||
<!-- END PHP TEMPLATE extrafields_edit.tpl.php -->
|
||||
@ -17,15 +17,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $permission must be defined by caller.
|
||||
// $cssclass must be defined by caller. For example cssclass='fieldtitle"
|
||||
// $permissionnote must be defined by caller. For example $permissionnote=$user->rights->module->create
|
||||
// $cssclass must be defined by caller. For example $cssclass='fieldtitle"
|
||||
$module = $object->element;
|
||||
$note_public = 'note_public';
|
||||
$note_private = 'note_private';
|
||||
|
||||
$colwidth=(isset($colwidth)?$colwidth:(empty($cssclass)?'25':''));
|
||||
|
||||
$permission=(isset($permission)?$permission:(isset($user->rights->$module->creer)?$user->rights->$module->creer:0)); // If already defined by caller page
|
||||
// Set $permission from the $permissionnote var defined on calling page
|
||||
$permission=(isset($permissionnote)?$permissionnote:(isset($permission)?$permission:(isset($user->rights->$module->create)?$user->rights->$module->create:(isset($user->rights->$module->creer)?$user->rights->$module->creer:0))));
|
||||
$moreparam=(isset($moreparam)?$moreparam:'');
|
||||
$value_public=$object->note_public;
|
||||
$value_private=$object->note_private;
|
||||
|
||||
@ -110,7 +110,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -561,6 +561,7 @@ if (empty($reshook))
|
||||
if (!$res) dol_print_error($db);
|
||||
}
|
||||
|
||||
$productsupplier = new ProductFournisseur($db);
|
||||
if ($productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid','int')) < 0 )
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings');
|
||||
|
||||
@ -158,7 +158,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -175,7 +175,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -806,7 +806,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
|
||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" onsubmit="return valider()" name="demandeCP">'."\n";
|
||||
print '<input type="hidden" name="action" value="create" />'."\n";
|
||||
|
||||
dol_fiche_head();
|
||||
dol_fiche_head('', '', '', -1);
|
||||
|
||||
$out='';
|
||||
$typeleaves=$object->getTypes(1,1);
|
||||
|
||||
@ -292,7 +292,8 @@ class Holiday extends CommonObject
|
||||
$sql.= " cp.rowid,";
|
||||
|
||||
$sql.= " cp.fk_user,";
|
||||
$sql.= " cp.date_create,";
|
||||
$sql.= " cp.fk_type,";
|
||||
$sql.= " cp.date_create,";
|
||||
$sql.= " cp.description,";
|
||||
$sql.= " cp.date_debut,";
|
||||
$sql.= " cp.date_fin,";
|
||||
@ -322,7 +323,7 @@ class Holiday extends CommonObject
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp, ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua";
|
||||
$sql.= " WHERE cp.entity IN (".getEntity('holiday').")";
|
||||
$sql.= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau
|
||||
$sql.= " AND cp.fk_user = '".$user_id."'";
|
||||
$sql.= " AND cp.fk_user = ".$user_id;
|
||||
|
||||
// Filtre de séléction
|
||||
if(!empty($filter)) {
|
||||
@ -357,6 +358,7 @@ class Holiday extends CommonObject
|
||||
$tab_result[$i]['rowid'] = $obj->rowid;
|
||||
$tab_result[$i]['ref'] = $obj->rowid;
|
||||
$tab_result[$i]['fk_user'] = $obj->fk_user;
|
||||
$tab_result[$i]['fk_type'] = $obj->fk_type;
|
||||
$tab_result[$i]['date_create'] = $this->db->jdate($obj->date_create);
|
||||
$tab_result[$i]['description'] = $obj->description;
|
||||
$tab_result[$i]['date_debut'] = $this->db->jdate($obj->date_debut);
|
||||
@ -1286,7 +1288,7 @@ class Holiday extends CommonObject
|
||||
/**
|
||||
* Get list of Users or list of vacation balance.
|
||||
*
|
||||
* @param boolean $stringlist If true return a string list of id. If false, return an array
|
||||
* @param boolean $stringlist If true return a string list of id. If false, return an array with detail.
|
||||
* @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list.
|
||||
* @param string $filters Filters
|
||||
* @return array|string|int Return an array
|
||||
@ -1297,7 +1299,6 @@ class Holiday extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
|
||||
|
||||
// Si vrai donc pour user Dolibarr
|
||||
if ($stringlist)
|
||||
{
|
||||
if ($type)
|
||||
@ -1356,7 +1357,7 @@ class Holiday extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
// We want only list of user id
|
||||
// We want only list of vacation balance for user ids
|
||||
$sql = "SELECT DISTINCT cpu.fk_user";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE cpu.fk_user = u.user";
|
||||
@ -1397,12 +1398,12 @@ class Holiday extends CommonObject
|
||||
|
||||
}
|
||||
else
|
||||
{ // Si faux donc user Congés Payés
|
||||
{ // Si faux donc return array
|
||||
|
||||
// List for Dolibarr users
|
||||
if ($type)
|
||||
{
|
||||
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut";
|
||||
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
|
||||
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
@ -1440,6 +1441,7 @@ class Holiday extends CommonObject
|
||||
$tab_result[$i]['status'] = $obj->statut;
|
||||
$tab_result[$i]['employee'] = $obj->employee;
|
||||
$tab_result[$i]['photo'] = $obj->photo;
|
||||
$tab_result[$i]['fk_user'] = $obj->fk_user;
|
||||
//$tab_result[$i]['type'] = $obj->type;
|
||||
//$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
||||
|
||||
@ -1458,7 +1460,7 @@ class Holiday extends CommonObject
|
||||
else
|
||||
{
|
||||
// List of vacation balance users
|
||||
$sql = "SELECT cpu.fk_user, cpu.fk_type, cpu.nb_holiday, u.lastname, u.firstname";
|
||||
$sql = "SELECT cpu.fk_user, cpu.fk_type, cpu.nb_holiday, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql.= " WHERE cpu.fk_user = u.rowid";
|
||||
if ($filters) $sql.=$filters;
|
||||
@ -1478,9 +1480,15 @@ class Holiday extends CommonObject
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$tab_result[$i]['rowid'] = $obj->fk_user;
|
||||
$tab_result[$i]['name'] = $obj->lastname;
|
||||
$tab_result[$i]['name'] = $obj->lastname; // deprecated
|
||||
$tab_result[$i]['lastname'] = $obj->lastname;
|
||||
$tab_result[$i]['firstname'] = $obj->firstname;
|
||||
$tab_result[$i]['gender'] = $obj->gender;
|
||||
$tab_result[$i]['status'] = $obj->statut;
|
||||
$tab_result[$i]['employee'] = $obj->employee;
|
||||
$tab_result[$i]['photo'] = $obj->photo;
|
||||
$tab_result[$i]['fk_user'] = $obj->fk_user;
|
||||
|
||||
$tab_result[$i]['type'] = $obj->type;
|
||||
$tab_result[$i]['nb_holiday'] = $obj->nb_holiday;
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ $langs->load('hrm');
|
||||
$action=GETPOST('action','aZ09');
|
||||
|
||||
$search_name=GETPOST('search_name', 'alpha');
|
||||
$search_supervisor=GETPOST('search_supervisor', 'int');
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
@ -54,7 +55,7 @@ if (! $sortorder) $sortorder="ASC";
|
||||
if ($user->societe_id > 0) accessforbidden();
|
||||
|
||||
// If the user does not have perm to read the page
|
||||
if(!$user->rights->holiday->read) accessforbidden();
|
||||
if (!$user->rights->holiday->read) accessforbidden();
|
||||
|
||||
|
||||
// Initialize technical object to manage context to save list fields
|
||||
@ -87,6 +88,7 @@ if (empty($reshook))
|
||||
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_name='';
|
||||
$search_supervisor='';
|
||||
$toselect='';
|
||||
$search_array_options=array();
|
||||
}
|
||||
@ -202,9 +204,20 @@ if ($result < 0)
|
||||
setEventMessages($holiday->error, $holiday->errors, 'errors');
|
||||
}
|
||||
|
||||
$filters=natural_search(array('u.firstname','u.lastname'), $search_name);
|
||||
$filters = '';
|
||||
|
||||
$listUsers = $holiday->fetchUsers(false,true,$filters);
|
||||
// Filter on array of ids of all childs
|
||||
$userchilds=array();
|
||||
if (empty($user->rights->holiday->read_all))
|
||||
{
|
||||
$userchilds=$user->getAllChildIds(1);
|
||||
$filters.=' AND u.rowid IN ('.join(', ',$userchilds).')';
|
||||
}
|
||||
|
||||
$filters.=natural_search(array('u.firstname','u.lastname'), $search_name);
|
||||
if ($search_supervisor > 0) $filters.=natural_search(array('u.fk_user'), $search_supervisor, 2);
|
||||
|
||||
$listUsers = $holiday->fetchUsers(false, true, $filters);
|
||||
if (is_numeric($listUsers) && $listUsers < 0)
|
||||
{
|
||||
setEventMessages($holiday->error, $holiday->errors, 'errors');
|
||||
@ -227,13 +240,6 @@ else
|
||||
$canedit=0;
|
||||
if (! empty($user->rights->holiday->define_holiday)) $canedit=1;
|
||||
|
||||
// Get array of ids of all childs
|
||||
$userchilds=array();
|
||||
if (empty($user->rights->holiday->read_all))
|
||||
{
|
||||
$userchilds=$user->getAllChildIds();
|
||||
}
|
||||
|
||||
print '<input type="hidden" name="action" value="update" />';
|
||||
|
||||
$moreforfilter='';
|
||||
@ -242,7 +248,16 @@ else
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'" id="tablelines3">'."\n";
|
||||
|
||||
print '<tr class="liste_titre_filter">';
|
||||
|
||||
// User
|
||||
print '<td class="liste_titre"><input type="text" name="search_name" value="'.dol_escape_htmltag($search_name).'"></td>';
|
||||
|
||||
// Supervisor
|
||||
print '<td class="liste_titre">';
|
||||
print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, null, 0, null, null, 0, 0, 0, '', 0, '', 'maxwidth200');
|
||||
print '</td>';
|
||||
|
||||
// Type of leave request
|
||||
if (count($typeleaves))
|
||||
{
|
||||
foreach($typeleaves as $key => $val)
|
||||
@ -266,23 +281,23 @@ else
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre('Employee', $_SERVER["PHP_SELF"]);
|
||||
print_liste_field_titre('Supervisor', $_SERVER["PHP_SELF"]);
|
||||
if (count($typeleaves))
|
||||
{
|
||||
foreach($typeleaves as $key => $val)
|
||||
{
|
||||
print '<th style="text-align:center">'.$val['label'].'</th>';
|
||||
print_liste_field_titre($val['label'], $_SERVER["PHP_SELF"], '', '', '', 'align="center"');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<th>'.$langs->trans("NoLeaveWithCounterDefined").'</th>';
|
||||
print_liste_field_titre($langs->trans("NoLeaveWithCounterDefined"), $_SERVER["PHP_SELF"], '', '', '', '');
|
||||
}
|
||||
print '<th style="text-align:center">';
|
||||
if ($canedit) print $langs->trans('Note');
|
||||
print '</th>';
|
||||
print_liste_field_titre((empty($user->rights->holiday->define_holiday) ? '' : $langs->trans('Note')), $_SERVER["PHP_SELF"]);
|
||||
print_liste_field_titre('');
|
||||
print '</tr>';
|
||||
|
||||
$usersupervisor = new User($db);
|
||||
|
||||
foreach($listUsers as $users)
|
||||
{
|
||||
@ -292,10 +307,6 @@ else
|
||||
if (($users['rowid'] != $user->id) && (! in_array($users['rowid'], $userchilds))) continue; // This user is not into hierarchy of current user, we hide it.
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// User
|
||||
print '<td>';
|
||||
$userstatic->id=$users['rowid'];
|
||||
$userstatic->lastname=$users['lastname'];
|
||||
$userstatic->firstname=$users['firstname'];
|
||||
@ -303,9 +314,22 @@ else
|
||||
$userstatic->photo=$users['photo'];
|
||||
$userstatic->statut=$users['status'];
|
||||
$userstatic->employee=$users['employee'];
|
||||
$userstatic->fk_user=$users['fk_user'];
|
||||
|
||||
if ($userstatic->fk_user > 0) $usersupervisor->fetch($userstatic->fk_user);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// User
|
||||
print '<td>';
|
||||
print $userstatic->getNomUrl(-1);
|
||||
print '</td>';
|
||||
|
||||
// Supervisor
|
||||
print '<td>';
|
||||
if ($userstatic->fk_user > 0) print $usersupervisor->getNomUrl(-1);
|
||||
print '</td>';
|
||||
|
||||
// Amount for each type
|
||||
if (count($typeleaves))
|
||||
{
|
||||
@ -313,6 +337,8 @@ else
|
||||
{
|
||||
$nbtoshow='';
|
||||
if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') $nbtoshow=price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5);
|
||||
|
||||
//var_dump($users['rowid'].' - '.$val['rowid']);
|
||||
print '<td style="text-align:center">';
|
||||
if ($canedit) print '<input type="text"'.($canedit?'':' disabled="disabled"').' value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>';
|
||||
else print $nbtoshow;
|
||||
@ -326,7 +352,7 @@ else
|
||||
}
|
||||
|
||||
// Note
|
||||
print '<td style="text-align:center">';
|
||||
print '<td>';
|
||||
if ($canedit) print '<input type="text"'.($canedit?'':' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>';
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
|
||||
@ -97,7 +97,7 @@ if ($object->id)
|
||||
|
||||
$head=holiday_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'documents',$langs->trans("CPTitreMenu"),0,'holiday');
|
||||
dol_fiche_head($head, 'documents', $langs->trans("CPTitreMenu"), -1,'holiday');
|
||||
|
||||
|
||||
// Construit liste des fichiers
|
||||
@ -110,16 +110,16 @@ if ($object->id)
|
||||
|
||||
|
||||
$linkback='<a href="'.DOL_URL_ROOT.'/holiday/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref');
|
||||
|
||||
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
//print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">'.$langs->trans("User").'</td>';
|
||||
print '<td>';
|
||||
@ -212,16 +212,16 @@ if ($object->id)
|
||||
|
||||
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
|
||||
|
||||
|
||||
print '</tbody>';
|
||||
print '</table>'."\n";
|
||||
/*
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
|
||||
// Info workflow
|
||||
print '<table class="border centpercent">'."\n";
|
||||
print '<tbody>';
|
||||
@ -278,11 +278,11 @@ if ($object->id)
|
||||
print '</div>';
|
||||
print '</div>'; */
|
||||
print '</div>';
|
||||
|
||||
|
||||
print '<div class="clearboth"></div>';
|
||||
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
|
||||
|
||||
$modulepart = 'holiday';
|
||||
|
||||
@ -33,26 +33,44 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||
|
||||
$langs->load('users');
|
||||
$langs->load('holidays');
|
||||
$langs->load('hrm');
|
||||
$langs->loadLangs(array('users', 'holidays', 'hrm'));
|
||||
|
||||
// Protection if external user
|
||||
if ($user->societe_id > 0) accessforbidden();
|
||||
|
||||
$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
$page = is_numeric($page) ? $page : 0;
|
||||
$page = $page == -1 ? 0 : $page;
|
||||
$action = GETPOST('action','alpha'); // The action 'add', 'create', 'edit', 'update', 'view', ...
|
||||
$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists)
|
||||
$show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ?
|
||||
$confirm = GETPOST('confirm','alpha'); // Result of a confirmation
|
||||
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
|
||||
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
|
||||
$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; // To manage different context of search
|
||||
$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page
|
||||
$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print')
|
||||
|
||||
if (! $sortfield) $sortfield="cp.rowid";
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield','alpha');
|
||||
$sortorder = GETPOST('sortorder','alpha');
|
||||
$page = GETPOST('page','int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
|
||||
// Initialize technical objects
|
||||
$object=new Holiday($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$diroutputmassaction=$conf->holiday->dir_output . '/temp/massgeneration/'.$user->id;
|
||||
$hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array
|
||||
// Fetch optionals attributes and labels
|
||||
$extralabels = $extrafields->fetch_name_optionals_label('holiday');
|
||||
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
|
||||
|
||||
// Default sort order (if not yet defined by previous GETPOST)
|
||||
if (! $sortfield) $sortfield="cp.rowid";
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
|
||||
$id = GETPOST('id','int');
|
||||
|
||||
$sall = GETPOST('sall', 'alphanohtml');
|
||||
@ -81,27 +99,60 @@ $fieldstosearchall = array(
|
||||
* Actions
|
||||
*/
|
||||
|
||||
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
|
||||
if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
|
||||
if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
|
||||
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
$search_ref="";
|
||||
$month_create="";
|
||||
$year_create="";
|
||||
$month_start="";
|
||||
$year_start="";
|
||||
$month_end="";
|
||||
$year_end="";
|
||||
$search_employee="";
|
||||
$search_valideur="";
|
||||
$search_statut="";
|
||||
$search_type='';
|
||||
// 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_ref="";
|
||||
$month_create="";
|
||||
$year_create="";
|
||||
$month_start="";
|
||||
$year_start="";
|
||||
$month_end="";
|
||||
$year_end="";
|
||||
$search_employee="";
|
||||
$search_valideur="";
|
||||
$search_statut="";
|
||||
$search_type='';
|
||||
$toselect='';
|
||||
$search_array_options=array();
|
||||
}
|
||||
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')
|
||||
|| GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha'))
|
||||
{
|
||||
$massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation
|
||||
}
|
||||
|
||||
// Mass actions
|
||||
$objectclass='Holiday';
|
||||
$objectlabel='Holiday';
|
||||
$permtoread = $user->rights->holiday->read;
|
||||
$permtodelete = $user->rights->holiday->delete;
|
||||
$uploaddir = $conf->holiday->dir_output;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$formother = new FormOther($db);
|
||||
|
||||
$holiday = new Holiday($db);
|
||||
$holidaystatic=new Holiday($db);
|
||||
$fuser = new User($db);
|
||||
@ -231,32 +282,41 @@ if ($result == '-1')
|
||||
|
||||
// Show table of vacations
|
||||
|
||||
$var=true;
|
||||
$num = count($holiday->holiday);
|
||||
$form = new Form($db);
|
||||
$formother = new FormOther($db);
|
||||
|
||||
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
if ($optioncss != '') $param.='&optioncss='.$optioncss;
|
||||
|
||||
print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
// List of mass actions available
|
||||
$arrayofmassactions = array(
|
||||
//'presend'=>$langs->trans("SendByMail"),
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
if ($user->rights->holiday->delete) $arrayofmassactions['delete']=$langs->trans("Delete");
|
||||
//if ($massaction == 'presend') $arrayofmassactions=array();
|
||||
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
if ($id > 0)
|
||||
if ($id > 0) // For user tab
|
||||
{
|
||||
$title = $langs->trans("User");
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
|
||||
$head = user_prepare_head($fuser);
|
||||
|
||||
dol_fiche_head($head, 'paidholidays', $title, 0, 'user');
|
||||
dol_fiche_head($head, 'paidholidays', $title, -1, 'user');
|
||||
|
||||
dol_banner_tab($fuser,'id',$linkback,$user->rights->user->user->lire || $user->admin);
|
||||
|
||||
@ -273,50 +333,21 @@ if ($id > 0)
|
||||
}
|
||||
else
|
||||
{
|
||||
//print $num;
|
||||
$nbtotalofrecords = count($holiday->holiday);
|
||||
//print $num;
|
||||
//print count($holiday->holiday);
|
||||
print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, "", $num, count($holiday->holiday), 'title_hrm.png', 0, '', '', $limit);
|
||||
print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm.png', 0, '', '', $limit);
|
||||
|
||||
if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
|
||||
/*if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
|
||||
{
|
||||
dol_fiche_head('');
|
||||
dol_fiche_head('', '', '', -1);
|
||||
|
||||
showMyBalance($holiday, $user_id);
|
||||
|
||||
dol_fiche_end();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show balance of user
|
||||
*
|
||||
* @param Holiday $holiday Object $holiday
|
||||
* @param int $user_id User id
|
||||
* @return string Html code with balance
|
||||
*/
|
||||
function showMyBalance($holiday, $user_id)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$alltypeleaves=$holiday->getTypes(1,-1); // To have labels
|
||||
|
||||
$out='';
|
||||
$nb_holiday=0;
|
||||
$typeleaves=$holiday->getTypes(1,1);
|
||||
foreach($typeleaves as $key => $val)
|
||||
{
|
||||
$nb_type = $holiday->getCPforUser($user_id, $val['rowid']);
|
||||
$nb_holiday += $nb_type;
|
||||
$out .= ' - '.$val['label'].': <strong>'.($nb_type?price2num($nb_type):0).'</strong><br>';
|
||||
}
|
||||
print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'<br>';
|
||||
print $out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($id > 0) print '<br>';
|
||||
|
||||
if ($sall)
|
||||
@ -325,6 +356,10 @@ if ($sall)
|
||||
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
|
||||
}
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$selectedfields=''; // $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
$selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
|
||||
|
||||
@ -424,7 +459,7 @@ print_liste_field_titre("Duration",$_SERVER["PHP_SELF"],'','',$pram,'align="righ
|
||||
print_liste_field_titre("DateDebCP",$_SERVER["PHP_SELF"],"cp.date_debut","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DateFinCP",$_SERVER["PHP_SELF"],"cp.date_fin","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"cp.statut","",$param,'align="right"',$sortfield,$sortorder);
|
||||
print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'',$param,'',$sortfield,$sortorder,'maxwidthsearch ');
|
||||
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
|
||||
print "</tr>\n";
|
||||
|
||||
// Lines
|
||||
@ -433,6 +468,8 @@ if (! empty($holiday->holiday))
|
||||
$userstatic = new User($db);
|
||||
$approbatorstatic = new User($db);
|
||||
|
||||
$typeleaves=$holiday->getTypes(1,-1);
|
||||
|
||||
foreach($holiday->holiday as $infos_CP)
|
||||
{
|
||||
// User
|
||||
@ -463,8 +500,7 @@ if (! empty($holiday->holiday))
|
||||
print '<td>'.$userstatic->getNomUrl(-1, 'leave').'</td>';
|
||||
print '<td>'.$approbatorstatic->getNomUrl(-1).'</td>';
|
||||
print '<td>';
|
||||
$label=$alltypeleaves[$infos_CP['fk_type']]['label'];
|
||||
print $label?$label:$infos_CP['fk_type'];
|
||||
print empty($typeleaves[$infos_CP['fk_type']]['label']) ? $langs->trans("TypeWasDisabledOrRemoved",$infos_CP['fk_type']) : $typeleaves[$infos_CP['fk_type']]['label'];
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
$nbopenedday=num_open_day($infos_CP['date_debut_gmt'], $infos_CP['date_fin_gmt'], 0, 1, $infos_CP['halfday']);
|
||||
@ -473,7 +509,17 @@ if (! empty($holiday->holiday))
|
||||
print '<td align="center">'.dol_print_date($infos_CP['date_debut'],'day').'</td>';
|
||||
print '<td align="center">'.dol_print_date($infos_CP['date_fin'],'day').'</td>';
|
||||
print '<td align="right">'.$holidaystatic->LibStatut($infos_CP['statut'],5).'</td>';
|
||||
print '<td></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($infos_CP['rowid'], $arrayofselected)) $selected=1;
|
||||
print '<input id="cb'.$infos_CP['rowid'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$infos_CP['rowid'].'"'.($selected?' checked="checked"':'').'>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print '</tr>'."\n";
|
||||
|
||||
}
|
||||
@ -503,3 +549,33 @@ print '</form>';
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show balance of user
|
||||
*
|
||||
* @param Holiday $holiday Object $holiday
|
||||
* @param int $user_id User id
|
||||
* @return string Html code with balance
|
||||
*/
|
||||
function showMyBalance($holiday, $user_id)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$alltypeleaves=$holiday->getTypes(1,-1); // To have labels
|
||||
|
||||
$out='';
|
||||
$nb_holiday=0;
|
||||
$typeleaves=$holiday->getTypes(1,1);
|
||||
foreach($typeleaves as $key => $val)
|
||||
{
|
||||
$nb_type = $holiday->getCPforUser($user_id, $val['rowid']);
|
||||
$nb_holiday += $nb_type;
|
||||
$out .= ' - '.$val['label'].': <strong>'.($nb_type?price2num($nb_type):0).'</strong><br>';
|
||||
}
|
||||
print $langs->trans('SoldeCPUser', round($nb_holiday,5)).'<br>';
|
||||
print $out;
|
||||
}
|
||||
|
||||
124
htdocs/index.php
124
htdocs/index.php
@ -373,135 +373,135 @@ require DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
|
||||
// Number of actions to do (late)
|
||||
if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
$board=new ActionComm($db);
|
||||
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
$board=new ActionComm($db);
|
||||
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
}
|
||||
|
||||
// Number of project opened
|
||||
if (! empty($conf->projet->enabled) && $user->rights->projet->lire)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$board=new Project($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$board=new Project($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
}
|
||||
|
||||
// Number of tasks to do (late)
|
||||
if (! empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
$board=new Task($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
$board=new Task($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
}
|
||||
|
||||
// Number of commercial proposals opened (expired)
|
||||
if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
$board=new Propal($db);
|
||||
$dashboardlines[] = $board->load_board($user,"opened");
|
||||
// Number of commercial proposals CLOSED signed (billed)
|
||||
$dashboardlines[] = $board->load_board($user,"signed");
|
||||
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
$board=new Propal($db);
|
||||
$dashboardlines[] = $board->load_board($user,"opened");
|
||||
// Number of commercial proposals CLOSED signed (billed)
|
||||
$dashboardlines[] = $board->load_board($user,"signed");
|
||||
}
|
||||
|
||||
// Number of commercial proposals opened (expired)
|
||||
if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
|
||||
$board=new SupplierProposal($db);
|
||||
$dashboardlines[] = $board->load_board($user,"opened");
|
||||
// Number of commercial proposals CLOSED signed (billed)
|
||||
$dashboardlines[] = $board->load_board($user,"signed");
|
||||
include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
|
||||
$board=new SupplierProposal($db);
|
||||
$dashboardlines[] = $board->load_board($user,"opened");
|
||||
// Number of commercial proposals CLOSED signed (billed)
|
||||
$dashboardlines[] = $board->load_board($user,"signed");
|
||||
}
|
||||
|
||||
// Number of customer orders a deal
|
||||
if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
$board=new Commande($db);
|
||||
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
$board=new Commande($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
}
|
||||
|
||||
// Number of suppliers orders a deal
|
||||
if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
||||
$board=new CommandeFournisseur($db);
|
||||
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
||||
$board=new CommandeFournisseur($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
}
|
||||
|
||||
// Number of services enabled (delayed)
|
||||
if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
||||
$board=new Contrat($db);
|
||||
$dashboardlines[] = $board->load_board($user,"inactives");
|
||||
include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
||||
$board=new Contrat($db);
|
||||
$dashboardlines[] = $board->load_board($user,"inactives");
|
||||
// Number of active services (expired)
|
||||
$dashboardlines[] = $board->load_board($user,"expired");
|
||||
$dashboardlines[] = $board->load_board($user,"expired");
|
||||
}
|
||||
// Number of invoices customers (has paid)
|
||||
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$board=new Facture($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$board=new Facture($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
}
|
||||
|
||||
// Number of supplier invoices (has paid)
|
||||
if (! empty($conf->supplier_invoice->enabled) && ! empty($user->rights->fournisseur->facture->lire))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
$board=new FactureFournisseur($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
$board=new FactureFournisseur($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
}
|
||||
|
||||
// Number of transactions to conciliate
|
||||
if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
$board=new Account($db);
|
||||
$nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate
|
||||
if ($nb > 0)
|
||||
{
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
}
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
$board=new Account($db);
|
||||
$nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate
|
||||
if ($nb > 0)
|
||||
{
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
}
|
||||
}
|
||||
|
||||
// Number of cheque to send
|
||||
if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
|
||||
$board=new RemiseCheque($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
|
||||
$board=new RemiseCheque($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
}
|
||||
|
||||
// Number of foundation members
|
||||
if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $user->societe_id)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
$board=new Adherent($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
$board=new Adherent($db);
|
||||
$dashboardlines[] = $board->load_board($user);
|
||||
}
|
||||
|
||||
// Number of expense reports to approve
|
||||
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->approve)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
$board=new ExpenseReport($db);
|
||||
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
$board=new ExpenseReport($db);
|
||||
$dashboardlines[] = $board->load_board($user,'toapprove');
|
||||
}
|
||||
|
||||
// Number of expense reports to pay
|
||||
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
$board=new ExpenseReport($db);
|
||||
include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
$board=new ExpenseReport($db);
|
||||
$dashboardlines[] = $board->load_board($user,'topay');
|
||||
}
|
||||
|
||||
// Calculate total nb of late
|
||||
$totallate=0;
|
||||
$totallate=$totaltodo=0;
|
||||
$var=true;
|
||||
|
||||
//Remove any invalid response
|
||||
@ -516,11 +516,13 @@ foreach($dashboardlines as $tmp)
|
||||
foreach($valid_dashboardlines as $board)
|
||||
{
|
||||
if ($board->nbtodolate > 0) {
|
||||
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totaltodo += $board->nbtodo;
|
||||
$totallate += $board->nbtodolate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//var_dump($totallate, $totaltodo);
|
||||
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totallate = round($totallate / $totaltodo * 100, 2);
|
||||
//var_dump($totallate);
|
||||
$boxwork='';
|
||||
$boxwork.='<div class="box">';
|
||||
$boxwork.='<table summary="'.dol_escape_htmltag($langs->trans("WorkingBoard")).'" class="noborder boxtable" width="100%">'."\n";
|
||||
@ -533,7 +535,7 @@ if ($showweather)
|
||||
$boxwork.='<tr class="nohover">';
|
||||
$boxwork.='<td class="nohover hideonsmartphone center valignmiddle">';
|
||||
$text='';
|
||||
if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate).')';
|
||||
if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')';
|
||||
$text.='. '.$langs->trans("LateDesc");
|
||||
//$text.=$form->textwithpicto('',$langs->trans("LateDesc"));
|
||||
$options='height="64px"';
|
||||
@ -686,15 +688,17 @@ $db->close();
|
||||
function showWeather($totallate,$text,$options)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
$out='';
|
||||
$offset=0;
|
||||
$factor=10; // By default
|
||||
|
||||
$level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0;
|
||||
$level1=$offset+1*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
|
||||
$level2=$offset+2*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
|
||||
$level3=$offset+3*$factor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
|
||||
$used_conf = !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_PERCENTAGE_LEVEL' : 'MAIN_METEO_LEVEL';
|
||||
|
||||
$level0=$offset; if (! empty($conf->global->{$used_conf.'0'})) $level0=$conf->global->{$used_conf.'0'};
|
||||
$level1=$offset+1*$factor; if (! empty($conf->global->{$used_conf.'1'})) $level1=$conf->global->{$used_conf.'1'};
|
||||
$level2=$offset+2*$factor; if (! empty($conf->global->{$used_conf.'2'})) $level2=$conf->global->{$used_conf.'2'};
|
||||
$level3=$offset+3*$factor; if (! empty($conf->global->{$used_conf.'3'})) $level3=$conf->global->{$used_conf.'3'};
|
||||
|
||||
if ($totallate <= $level0) $out.=img_weather($text,'weather-clear.png',$options);
|
||||
if ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text,'weather-few-clouds.png',$options);
|
||||
|
||||
@ -41,6 +41,10 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer;
|
||||
|
||||
-- For 7.0
|
||||
|
||||
-- VMYSQL4.1 ALTER TABLE llx_holiday_users DROP PRIMARY KEY;
|
||||
|
||||
ALTER TABLE llx_holiday_users ADD UNIQUE INDEX uk_holiday_users(fk_user, fk_type, nb_holiday);
|
||||
|
||||
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_tx double(6,3) DEFAULT 0;
|
||||
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0';
|
||||
ALTER TABLE llx_product_fournisseur_price ADD COLUMN localtax2_tx double(6,3) DEFAULT 0;
|
||||
@ -103,6 +107,7 @@ ALTER TABLE llx_website_page MODIFY COLUMN pageurl varchar(255);
|
||||
ALTER TABLE llx_website_page ADD COLUMN lang varchar(6);
|
||||
ALTER TABLE llx_website_page ADD COLUMN fk_page integer;
|
||||
ALTER TABLE llx_website_page ADD COLUMN grabbed_from varchar(255);
|
||||
ALTER TABLE llx_website_page ADD COLUMN htmlheader text;
|
||||
|
||||
ALTER TABLE llx_website_page MODIFY COLUMN status INTEGER DEFAULT 1;
|
||||
UPDATE llx_website_page set status = 1 WHERE status IS NULL;
|
||||
@ -261,6 +266,12 @@ ALTER TABLE llx_extrafields ADD COLUMN fk_user_modif integer;
|
||||
ALTER TABLE llx_extrafields ADD COLUMN datec datetime;
|
||||
ALTER TABLE llx_extrafields ADD COLUMN tms timestamp;
|
||||
|
||||
-- We fix value of 'list' fro m0 to 1 for all extrafields created before this migration
|
||||
UPDATE llx_extrafields SET list = 1 WHERE list = 0 AND fk_user_author IS NULL and fk_user_modif IS NULL and datec IS NULL;
|
||||
|
||||
ALTER TABLE llx_extrafields MODIFY COLUMN list integer DEFAULT 1;
|
||||
--VPGSQL8.2 ALTER TABLE llx_extrafields ALTER COLUMN list SET DEFAULT 1;
|
||||
|
||||
ALTER TABLE llx_extrafields MODIFY COLUMN langs varchar(64);
|
||||
|
||||
ALTER TABLE llx_holiday_config MODIFY COLUMN name varchar(128);
|
||||
|
||||
@ -34,7 +34,7 @@ create table llx_extrafields
|
||||
pos integer DEFAULT 0,
|
||||
alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status
|
||||
param text, -- extra parameters to define possible values of field
|
||||
list integer DEFAULT 0, -- list of values for field that are combo lists
|
||||
list integer DEFAULT 1, -- list of values for field that are combo lists
|
||||
langs varchar(64), -- example: fileofmymodule@mymodule
|
||||
ishidden integer DEFAULT 0, -- Can be foreign key of external system
|
||||
fk_user_author integer, -- user making creation
|
||||
|
||||
19
htdocs/install/mysql/tables/llx_holiday_users.key.sql
Normal file
19
htdocs/install/mysql/tables/llx_holiday_users.key.sql
Normal file
@ -0,0 +1,19 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--
|
||||
-- ===================================================================
|
||||
|
||||
ALTER TABLE llx_holiday_users ADD UNIQUE INDEX uk_holiday_users(fk_user, fk_type, nb_holiday);
|
||||
@ -20,5 +20,5 @@ CREATE TABLE llx_holiday_users
|
||||
(
|
||||
fk_user integer NOT NULL,
|
||||
fk_type integer NOT NULL,
|
||||
nb_holiday real NOT NULL DEFAULT '0'
|
||||
nb_holiday real NOT NULL DEFAULT 0
|
||||
) ENGINE=innodb;
|
||||
@ -27,6 +27,7 @@ CREATE TABLE llx_website_page
|
||||
keywords varchar(255),
|
||||
lang varchar(6),
|
||||
fk_page integer,
|
||||
htmlheader text,
|
||||
content mediumtext, -- text is not enough in size
|
||||
status integer DEFAULT 1,
|
||||
grabbed_from varchar(255),
|
||||
|
||||
@ -452,8 +452,8 @@ DependsOn=This module need the module(s)
|
||||
RequiredBy=This module is required by module(s)
|
||||
TheKeyIsTheNameOfHtmlField=This is the name of the HTML field. This need to have technical knowledges to read the content of the HTML page to get the key name of a field.
|
||||
PageUrlForDefaultValues=You must enter here the relative url of the page. If you include parameters in URL, the default values will be effective if all parameters are set to same value. Examples:
|
||||
PageUrlForDefaultValuesCreate=<br>For form to create a new thirdparty, it is <strong>%s</strong>,<br>If we want default only if url has some parameter, we can use <strong>%s</strong>
|
||||
PageUrlForDefaultValuesList=<br>For page that list thirdparties, it is <strong>%s</strong>,<br>If we want default only if url has some parameter, we can use <strong>%s</strong>
|
||||
PageUrlForDefaultValuesCreate=<br>For form to create a new thirdparty, it is <strong>%s</strong>,<br>If you want default value only if url has some parameter, you can use <strong>%s</strong>
|
||||
PageUrlForDefaultValuesList=<br>For page that list thirdparties, it is <strong>%s</strong>,<br>If you want default value only if url has some parameter, you can use <strong>%s</strong>
|
||||
EnableDefaultValues=Enable usage of personalized default values
|
||||
EnableOverwriteTranslation=Enable usage of overwrote translation
|
||||
GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation.
|
||||
@ -1089,6 +1089,11 @@ ShowProfIdInAddress=Show professionnal id with addresses on documents
|
||||
ShowVATIntaInAddress=Hide VAT Intra num with addresses on documents
|
||||
TranslationUncomplete=Partial translation
|
||||
MAIN_DISABLE_METEO=Disable meteo view
|
||||
MeteoStdMod=Standard mode
|
||||
MeteoStdModEnabled=Standard mode enabled
|
||||
MeteoPercentageMod=Percentage mode
|
||||
MeteoPercentageModEnabled=Percentage mode enabled
|
||||
MeteoUseMod=Click to use %s
|
||||
TestLoginToAPI=Test login to API
|
||||
ProxyDesc=Some features of Dolibarr need to have an Internet access to work. Define here parameters for this. If the Dolibarr server is behind a Proxy server, those parameters tells Dolibarr how to access Internet through it.
|
||||
ExternalAccess=External access
|
||||
|
||||
@ -37,7 +37,7 @@ VirtualHostUrlNotDefined=URL of the virtual host served by external web server n
|
||||
NoPageYet=No pages yet
|
||||
SyntaxHelp=Help on specific syntax tips
|
||||
YouCanEditHtmlSourceckeditor=You can edit HTML source code using the "Source" button in editor.
|
||||
YouCanEditHtmlSource=You can include PHP code into this source using tags <strong><?php ?></strong>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.<br><br>You can also include content of another Page/Container with the following syntax: <strong><?php dolIncludeHtmlContent($websitekey.'/contentaliastoinclude.php'); ?></strong><br><br>To include a link to download a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong><a href="/document.php?modulepart=ecm&file=reldir/filename.ext"></strong>.<br>for a file into documents/media (open public access), syntax is:<br><strong><a href="/document.php?modulepart=medias[&hashp=publicsharekey if modulepart != medias]"></strong>.<br><br>To include an image stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper:<br>Example, for an image into documents/media (open access), syntax is:<br><strong><a href="/viewimage.php?modulepart=medias&file=filename.ext"></strong>.
|
||||
YouCanEditHtmlSource=You can include PHP code into this source using tags <strong><?php ?></strong>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.<br><br>You can also include content of another Page/Container with the following syntax:<br><strong><?php dolIncludeHtmlContent($websitekey.'/alias_of_content_to_include.php'); ?></strong><br><br>To include a <strong>link to download</strong> a file stored into the <strong>documents</strong> directory, use the <strong>document.php</strong> wrapper:<br>Example, for a file into documents/ecm (need to be logged), syntax is:<br><strong><a href="/document.php?modulepart=ecm&file=relative_dir/filename.ext"></strong><br>For same file into documents/ecm (open access using the sharing hash key), syntax is:<br><strong><a href="/document.php?modulepart=ecm&file=relative_dir/filename.ext&hashp=publicsharekeyoffile"></strong><br>For a file into documents/media (open directory for public access), syntax is:<br><strong><a href="/document.php?modulepart=medias&file=relative_dir/filename.ext"></strong><br><br>To include an <strong>image</strong> stored into the <strong>documents</strong> directory, use the <strong>viewimage.php</strong> wrapper:<br>Example, for an image into documents/media (open access), syntax is:<br><strong><a href="/viewimage.php?modulepart=medias&file=relative_dir/filename.ext"></strong>
|
||||
ClonePage=Clone page/container
|
||||
CloneSite=Clone site
|
||||
ConfirmClonePage=Please enter code/alias of new page and if it is a translation of the cloned page.
|
||||
@ -49,3 +49,4 @@ CreateByFetchingExternalPage=Create page/container by fetching page from externa
|
||||
OrEnterPageInfoManually=Or create empty page from scratch...
|
||||
FetchAndCreate=Fetch and Create
|
||||
ExportSite=Export site
|
||||
IDOfPage=Id of page
|
||||
@ -81,8 +81,10 @@ class MyObject extends CommonObject
|
||||
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
|
||||
'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
|
||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'index'=>1, 'position'=>20),
|
||||
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1),
|
||||
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200'),
|
||||
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Amount'),
|
||||
'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>45),
|
||||
'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>46),
|
||||
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
|
||||
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
*/
|
||||
function myobjectPrepareHead($object)
|
||||
{
|
||||
global $langs, $conf;
|
||||
global $db, $langs, $conf;
|
||||
|
||||
$langs->load("mymodule@mymodule");
|
||||
|
||||
@ -40,17 +40,30 @@ function myobjectPrepareHead($object)
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$h++;
|
||||
if (isset($object->fields['note_public']) || isset($object->fields['note_pricate']))
|
||||
|
||||
if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
|
||||
{
|
||||
$head[$h][0] = dol_buildpath("/mymodule/myobject_note.php", 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Notes");
|
||||
$nbNote = 0;
|
||||
if(!empty($object->fields['note_private'])) $nbNote++;
|
||||
if(!empty($object->fields['note_public'])) $nbNote++;
|
||||
$head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Notes');
|
||||
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
|
||||
$upload_dir = $conf->mymodule->dir_output . "/myobject/" . dol_sanitizeFileName($object->ref);
|
||||
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
|
||||
$nbLinks=Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
$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_buildpath("/mymodule/myobject_agenda.php", 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Events");
|
||||
$head[$h][2] = 'agenda';
|
||||
|
||||
@ -166,8 +166,9 @@ if (empty($reshook))
|
||||
{
|
||||
foreach ($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
|
||||
|
||||
$object->$key=GETPOST($key,'alpha');
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
if ($val['notnull'] > 0 && $object->$key == '')
|
||||
{
|
||||
$error++;
|
||||
@ -280,6 +281,7 @@ if ($action == 'create')
|
||||
print $langs->trans($val['label']);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$defaultcss='minwidth100';
|
||||
if ($val['type'] == 'text')
|
||||
{
|
||||
print '<textarea class="flat quatrevingtpercent" rows="'.ROWS_4.'" name="'.$key.'">';
|
||||
@ -292,12 +294,16 @@ if ($action == 'create')
|
||||
}
|
||||
else
|
||||
{
|
||||
$cssforinput = 'minwidth100';
|
||||
print '<input class="flat" class="'.$cssforinput.'" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'">';
|
||||
$cssforinput = empty($val['css'])?$defaultcss:$val['css'];
|
||||
print '<input class="flat'.($cssforinput?' '.$cssforinput:'').'" class="'.$cssforinput.'" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'">';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
|
||||
|
||||
print '</table>'."\n";
|
||||
|
||||
dol_fiche_end();
|
||||
@ -307,8 +313,6 @@ if ($action == 'create')
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Part to edit record
|
||||
if (($id || $ref) && $action == 'edit')
|
||||
{
|
||||
@ -325,6 +329,7 @@ if (($id || $ref) && $action == 'edit')
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
|
||||
print '<tr><td';
|
||||
print ' class="titlefieldcreate';
|
||||
if ($val['notnull'] > 0) print ' fieldrequired';
|
||||
@ -332,24 +337,29 @@ if (($id || $ref) && $action == 'edit')
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td>';
|
||||
$defaultcss='minwidth100';
|
||||
if ($val['type'] == 'text')
|
||||
{
|
||||
print '<textarea class="flat quatrevingtpercent" rows="'.ROWS_4.'" name="'.$key.'">';
|
||||
print GETPOST($key,'none');
|
||||
print GETPOST($key,'none')?GETPOST($key,'none'):$object->$key;
|
||||
print '</textarea>';
|
||||
}
|
||||
elseif (is_array($val['arrayofkeyval']))
|
||||
{
|
||||
print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int'));
|
||||
print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')!=''?GETPOST($key, 'int'):$object->$key);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cssforinput = 'minwidth100';
|
||||
print '<input class="flat" class="'.$cssforinput.'" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'">';
|
||||
$cssforinput = empty($val['css'])?$defaultcss:$val['css'];
|
||||
print '<input class="flat'.($cssforinput?' '.$cssforinput:'').'" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):$object->$key).'">';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
|
||||
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
@ -361,9 +371,6 @@ if (($id || $ref) && $action == 'edit')
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Part to show record
|
||||
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
|
||||
{
|
||||
@ -463,18 +470,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue;
|
||||
|
||||
print '<tr><td';
|
||||
print ' class="titlefieldcreate';
|
||||
print ' class="titlefield';
|
||||
if ($val['notnull'] > 0) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td><input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'"></td>';
|
||||
print '<td>';
|
||||
print dol_escape_htmltag($object->$key, 1, 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
//if ($key == 'targetsrcfile3') break; // key used for break on second column
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
@ -483,7 +492,30 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
// ...
|
||||
$alreadyoutput = 1;
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if ($alreadyoutput)
|
||||
{
|
||||
//if ($key == 'targetsrcfile3') $alreadyoutput = 0; // key used for break on second column
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($key, array('rowid', 'ref', 'entity', 'note_public', 'note_private', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key', 'status'))) continue;
|
||||
|
||||
print '<tr><td';
|
||||
print ' class="titlefield';
|
||||
if ($val['notnull'] > 0) print ' fieldrequired';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '<td>';
|
||||
print dol_escape_htmltag($object->$key, 1, 1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
@ -512,6 +544,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
|
||||
}
|
||||
|
||||
/*
|
||||
if ($user->rights->sellyoursaas->create)
|
||||
{
|
||||
if ($object->status == 1)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable">'.$langs->trans("Disable").'</a></div>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable">'.$langs->trans("Enable").'</a></div>'."\n";
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if ($user->rights->mymodule->delete)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
|
||||
|
||||
@ -79,7 +79,9 @@ $extralabels = $extrafields->fetch_name_optionals_label('myobject');
|
||||
|
||||
// Load object
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
|
||||
if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mymodule->multidir_output[$object->entity] . "/" . $object->id;
|
||||
|
||||
//if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/packages/" . dol_sanitizeFileName($object->id);
|
||||
if ($id > 0 || ! empty($ref)) $upload_dir = $conf->sellyoursaas->multidir_output[$object->entity] . "/packages/" . dol_sanitizeFileName($object->ref);
|
||||
|
||||
|
||||
|
||||
@ -167,10 +169,16 @@ if ($object->id)
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
$modulepart = 'societe';
|
||||
$permission = $user->rights->societe->creer;
|
||||
$permtoedit = $user->rights->societe->creer;
|
||||
$modulepart = 'mymodule';
|
||||
//$permission = $user->rights->mymodule->create;
|
||||
$permission = 1;
|
||||
//$permtoedit = $user->rights->mymodule->create;
|
||||
$permtoedit = 1;
|
||||
$param = '&id=' . $object->id;
|
||||
|
||||
//$relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->id).'/';
|
||||
$relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->ref).'/';
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
|
||||
}
|
||||
else
|
||||
|
||||
@ -130,7 +130,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -183,7 +183,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1693,8 +1693,8 @@ class Task extends CommonObject
|
||||
|
||||
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
|
||||
*
|
||||
@ -1703,65 +1703,114 @@ class Task extends CommonObject
|
||||
*/
|
||||
function load_board($user)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$mine=0; $socid=$user->societe_id;
|
||||
|
||||
$projectstatic = new Project($this->db);
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid);
|
||||
|
||||
// List of tasks (does not care about permissions. Filtering will be done later)
|
||||
$sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,";
|
||||
$sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,";
|
||||
$sql.= " t.dateo as date_start, t.datee as datee";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('project', 0).')';
|
||||
$sql.= " AND p.fk_statut = 1";
|
||||
$sql.= " AND t.fk_projet = p.rowid";
|
||||
$sql.= " AND t.progress < 100"; // tasks to do
|
||||
if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
|
||||
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
|
||||
//if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))";
|
||||
//print $sql;
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$task_static = new Task($this->db);
|
||||
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay = $conf->projet->task->warning_delay/60/60/24;
|
||||
$response->label = $langs->trans("OpenedTasks");
|
||||
if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project';
|
||||
else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project';
|
||||
$response->img = img_object('',"task");
|
||||
|
||||
// This assignment in condition is not a bug. It allows walking the results.
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$response->nbtodo++;
|
||||
|
||||
$task_static->projectstatus = $obj->projectstatus;
|
||||
$task_static->progress = $obj->progress;
|
||||
$task_static->fk_statut = $obj->status;
|
||||
$task_static->date_end = $this->db->jdate($obj->datee);
|
||||
|
||||
if ($task_static->hasDelay()) {
|
||||
$response->nbtodolate++;
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
global $conf, $langs;
|
||||
|
||||
$mine=0; $socid=$user->societe_id;
|
||||
|
||||
$projectstatic = new Project($this->db);
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid);
|
||||
|
||||
// List of tasks (does not care about permissions. Filtering will be done later)
|
||||
$sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,";
|
||||
$sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,";
|
||||
$sql.= " t.dateo as date_start, t.datee as datee";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('project', 0).')';
|
||||
$sql.= " AND p.fk_statut = 1";
|
||||
$sql.= " AND t.fk_projet = p.rowid";
|
||||
$sql.= " AND t.progress < 100"; // tasks to do
|
||||
if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
|
||||
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
|
||||
//if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))";
|
||||
//print $sql;
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$task_static = new Task($this->db);
|
||||
|
||||
$response = new WorkboardResponse();
|
||||
$response->warning_delay = $conf->projet->task->warning_delay/60/60/24;
|
||||
$response->label = $langs->trans("OpenedTasks");
|
||||
if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project';
|
||||
else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project';
|
||||
$response->img = img_object('',"task");
|
||||
|
||||
// This assignment in condition is not a bug. It allows walking the results.
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$response->nbtodo++;
|
||||
|
||||
$task_static->projectstatus = $obj->projectstatus;
|
||||
$task_static->progress = $obj->progress;
|
||||
$task_static->fk_statut = $obj->status;
|
||||
$task_static->date_end = $this->db->jdate($obj->datee);
|
||||
|
||||
if ($task_static->hasDelay()) {
|
||||
$response->nbtodolate++;
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Charge indicateurs this->nb de tableau de bord
|
||||
*
|
||||
* @return int <0 if ko, >0 if ok
|
||||
*/
|
||||
function load_state_board()
|
||||
{
|
||||
global $user;
|
||||
|
||||
$mine=0; $socid=$user->societe_id;
|
||||
|
||||
$projectstatic = new Project($this->db);
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid);
|
||||
|
||||
// List of tasks (does not care about permissions. Filtering will be done later)
|
||||
$sql = "SELECT count(p.rowid) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."projet_task as t";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('project', 0).')';
|
||||
$sql.= " AND t.fk_projet = p.rowid"; // tasks to do
|
||||
if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
|
||||
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
|
||||
//if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
||||
// This assignment in condition is not a bug. It allows walking the results.
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$this->nb["tasks"]=$obj->nb;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -137,7 +137,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -622,7 +622,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -205,14 +205,13 @@ else
|
||||
|
||||
// Link to other agenda views
|
||||
$out='';
|
||||
$out.=img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"),'object_calendarperuser','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewPerUser").'</a>';
|
||||
$out.='<br>';
|
||||
$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewCal").'</a>';
|
||||
$out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>';
|
||||
$out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
|
||||
$out.='</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($act->datep,'%Y').'&month='.dol_print_date($act->datep,'%m').'&day='.dol_print_date($act->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
|
||||
|
||||
$linkback.=$out;
|
||||
|
||||
@ -94,8 +94,6 @@ if (! empty($canvas))
|
||||
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
@ -310,159 +308,155 @@ if (empty($reshook))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdPartyName")), null, 'errors');
|
||||
$error++;
|
||||
$action=($action=='add'?'create':'edit');
|
||||
}
|
||||
if (GETPOST('client') < 0)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProspectCustomer")), null, 'errors');
|
||||
$error++;
|
||||
$action=($action=='add'?'create':'edit');
|
||||
}
|
||||
if (GETPOST('fournisseur') < 0)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors');
|
||||
$error++;
|
||||
$action=($action=='add'?'create':'edit');
|
||||
|
||||
}
|
||||
|
||||
if ($action == 'update')
|
||||
if (! $error)
|
||||
{
|
||||
$ret=$object->fetch($socid);
|
||||
$object->oldcopy = clone $object;
|
||||
}
|
||||
else $object->canvas=$canvas;
|
||||
if ($action == 'update')
|
||||
{
|
||||
$ret=$object->fetch($socid);
|
||||
$object->oldcopy = clone $object;
|
||||
}
|
||||
else $object->canvas=$canvas;
|
||||
|
||||
if (GETPOST("private") == 1) // Ask to create a contact
|
||||
{
|
||||
$object->particulier = GETPOST("private");
|
||||
if (GETPOST("private") == 1) // Ask to create a contact
|
||||
{
|
||||
$object->particulier = GETPOST("private");
|
||||
|
||||
$object->name = dolGetFirstLastname(GETPOST('firstname','alpha'),GETPOST('name','alpha'));
|
||||
$object->civility_id = GETPOST('civility_id'); // Note: civility id is a code, not an int
|
||||
// Add non official properties
|
||||
$object->name_bis = GETPOST('name','alpha');
|
||||
$object->firstname = GETPOST('firstname','alpha');
|
||||
}
|
||||
else
|
||||
{
|
||||
$object->name = GETPOST('name', 'alpha');
|
||||
}
|
||||
$object->name_alias = GETPOST('name_alias');
|
||||
$object->address = GETPOST('address');
|
||||
$object->zip = GETPOST('zipcode', 'alpha');
|
||||
$object->town = GETPOST('town', 'alpha');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->state_id = GETPOST('state_id', 'int');
|
||||
$object->skype = GETPOST('skype', 'alpha');
|
||||
$object->phone = GETPOST('phone', 'alpha');
|
||||
$object->fax = GETPOST('fax','alpha');
|
||||
$object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL));
|
||||
$object->url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL));
|
||||
$object->idprof1 = trim(GETPOST('idprof1', 'alpha'));
|
||||
$object->idprof2 = trim(GETPOST('idprof2', 'alpha'));
|
||||
$object->idprof3 = trim(GETPOST('idprof3', 'alpha'));
|
||||
$object->idprof4 = trim(GETPOST('idprof4', 'alpha'));
|
||||
$object->idprof5 = trim(GETPOST('idprof5', 'alpha'));
|
||||
$object->idprof6 = trim(GETPOST('idprof6', 'alpha'));
|
||||
$object->prefix_comm = GETPOST('prefix_comm', 'alpha');
|
||||
$object->code_client = GETPOST('code_client', 'alpha');
|
||||
$object->code_fournisseur = GETPOST('code_fournisseur', 'alpha');
|
||||
$object->capital = GETPOST('capital', 'alpha');
|
||||
$object->barcode = GETPOST('barcode', 'alpha');
|
||||
$object->name = dolGetFirstLastname(GETPOST('firstname','alpha'),GETPOST('name','alpha'));
|
||||
$object->civility_id = GETPOST('civility_id'); // Note: civility id is a code, not an int
|
||||
// Add non official properties
|
||||
$object->name_bis = GETPOST('name','alpha');
|
||||
$object->firstname = GETPOST('firstname','alpha');
|
||||
}
|
||||
else
|
||||
{
|
||||
$object->name = GETPOST('name', 'alpha');
|
||||
}
|
||||
$object->name_alias = GETPOST('name_alias');
|
||||
$object->address = GETPOST('address');
|
||||
$object->zip = GETPOST('zipcode', 'alpha');
|
||||
$object->town = GETPOST('town', 'alpha');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->state_id = GETPOST('state_id', 'int');
|
||||
$object->skype = GETPOST('skype', 'alpha');
|
||||
$object->phone = GETPOST('phone', 'alpha');
|
||||
$object->fax = GETPOST('fax','alpha');
|
||||
$object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL));
|
||||
$object->url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL));
|
||||
$object->idprof1 = trim(GETPOST('idprof1', 'alpha'));
|
||||
$object->idprof2 = trim(GETPOST('idprof2', 'alpha'));
|
||||
$object->idprof3 = trim(GETPOST('idprof3', 'alpha'));
|
||||
$object->idprof4 = trim(GETPOST('idprof4', 'alpha'));
|
||||
$object->idprof5 = trim(GETPOST('idprof5', 'alpha'));
|
||||
$object->idprof6 = trim(GETPOST('idprof6', 'alpha'));
|
||||
$object->prefix_comm = GETPOST('prefix_comm', 'alpha');
|
||||
$object->code_client = GETPOST('code_client', 'alpha');
|
||||
$object->code_fournisseur = GETPOST('code_fournisseur', 'alpha');
|
||||
$object->capital = GETPOST('capital', 'alpha');
|
||||
$object->barcode = GETPOST('barcode', 'alpha');
|
||||
|
||||
$object->tva_intra = GETPOST('tva_intra', 'alpha');
|
||||
$object->tva_assuj = GETPOST('assujtva_value', 'alpha');
|
||||
$object->status = GETPOST('status', 'alpha');
|
||||
$object->tva_intra = GETPOST('tva_intra', 'alpha');
|
||||
$object->tva_assuj = GETPOST('assujtva_value', 'alpha');
|
||||
$object->status = GETPOST('status', 'alpha');
|
||||
|
||||
// Local Taxes
|
||||
$object->localtax1_assuj = GETPOST('localtax1assuj_value', 'alpha');
|
||||
$object->localtax2_assuj = GETPOST('localtax2assuj_value', 'alpha');
|
||||
// Local Taxes
|
||||
$object->localtax1_assuj = GETPOST('localtax1assuj_value', 'alpha');
|
||||
$object->localtax2_assuj = GETPOST('localtax2assuj_value', 'alpha');
|
||||
|
||||
$object->localtax1_value = GETPOST('lt1', 'alpha');
|
||||
$object->localtax2_value = GETPOST('lt2', 'alpha');
|
||||
$object->localtax1_value = GETPOST('lt1', 'alpha');
|
||||
$object->localtax2_value = GETPOST('lt2', 'alpha');
|
||||
|
||||
$object->forme_juridique_code = GETPOST('forme_juridique_code', 'int');
|
||||
$object->effectif_id = GETPOST('effectif_id', 'int');
|
||||
$object->typent_id = GETPOST('typent_id','int');
|
||||
$object->forme_juridique_code = GETPOST('forme_juridique_code', 'int');
|
||||
$object->effectif_id = GETPOST('effectif_id', 'int');
|
||||
$object->typent_id = GETPOST('typent_id','int');
|
||||
|
||||
$object->typent_code = dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code'); // Force typent_code too so check in verify() will be done on new type
|
||||
$object->typent_code = dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code'); // Force typent_code too so check in verify() will be done on new type
|
||||
|
||||
$object->client = GETPOST('client', 'int');
|
||||
$object->fournisseur = GETPOST('fournisseur', 'int');
|
||||
$object->client = GETPOST('client', 'int');
|
||||
$object->fournisseur = GETPOST('fournisseur', 'int');
|
||||
|
||||
$object->commercial_id = GETPOST('commercial_id', 'int');
|
||||
$object->default_lang = GETPOST('default_lang');
|
||||
$object->commercial_id = GETPOST('commercial_id', 'int');
|
||||
$object->default_lang = GETPOST('default_lang');
|
||||
|
||||
// Webservices url/key
|
||||
$object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
|
||||
$object->webservices_key = GETPOST('webservices_key', 'san_alpha');
|
||||
// Webservices url/key
|
||||
$object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
|
||||
$object->webservices_key = GETPOST('webservices_key', 'san_alpha');
|
||||
|
||||
// Incoterms
|
||||
if (!empty($conf->incoterm->enabled))
|
||||
{
|
||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
}
|
||||
// Incoterms
|
||||
if (!empty($conf->incoterm->enabled))
|
||||
{
|
||||
$object->fk_incoterms = GETPOST('incoterm_id', 'int');
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
}
|
||||
|
||||
// Multicurrency
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||
}
|
||||
// Multicurrency
|
||||
if (!empty($conf->multicurrency->enabled))
|
||||
{
|
||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||
}
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0)
|
||||
{
|
||||
$error++;
|
||||
$action = ($action=='add'?'create':'edit');
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
if ($ret < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (GETPOST('deletephoto')) $object->logo = '';
|
||||
else if (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
if (GETPOST('deletephoto')) $object->logo = '';
|
||||
else if (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
|
||||
// Check parameters
|
||||
if (! GETPOST('cancel','alpha'))
|
||||
{
|
||||
if (! empty($object->email) && ! isValidEMail($object->email))
|
||||
{
|
||||
$langs->load("errors");
|
||||
$error++;
|
||||
setEventMessages('', $langs->trans("ErrorBadEMail",$object->email), 'errors');
|
||||
$action = ($action=='add'?'create':'edit');
|
||||
}
|
||||
if (! empty($object->url) && ! isValidUrl($object->url))
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages('', $langs->trans("ErrorBadUrl",$object->url), 'errors');
|
||||
$action = ($action=='add'?'create':'edit');
|
||||
}
|
||||
if ($object->fournisseur && ! $conf->fournisseur->enabled)
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages('', $langs->trans("ErrorSupplierModuleNotEnabled"), 'errors');
|
||||
$action = ($action=='add'?'create':'edit');
|
||||
}
|
||||
if (! empty($object->webservices_url)) {
|
||||
//Check if has transport, without any the soap client will give error
|
||||
if (strpos($object->webservices_url, "http") === false)
|
||||
{
|
||||
$object->webservices_url = "http://".$object->webservices_url;
|
||||
}
|
||||
if (! isValidUrl($object->webservices_url)) {
|
||||
$langs->load("errors");
|
||||
$error++; $errors[] = $langs->trans("ErrorBadUrl",$object->webservices_url);
|
||||
$action = ($action=='add'?'create':'edit');
|
||||
}
|
||||
}
|
||||
// Check parameters
|
||||
if (! GETPOST('cancel','alpha'))
|
||||
{
|
||||
if (! empty($object->email) && ! isValidEMail($object->email))
|
||||
{
|
||||
$langs->load("errors");
|
||||
$error++;
|
||||
setEventMessages('', $langs->trans("ErrorBadEMail",$object->email), 'errors');
|
||||
}
|
||||
if (! empty($object->url) && ! isValidUrl($object->url))
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages('', $langs->trans("ErrorBadUrl",$object->url), 'errors');
|
||||
}
|
||||
if ($object->fournisseur && ! $conf->fournisseur->enabled)
|
||||
{
|
||||
$langs->load("errors");
|
||||
setEventMessages('', $langs->trans("ErrorSupplierModuleNotEnabled"), 'errors');
|
||||
}
|
||||
if (! empty($object->webservices_url)) {
|
||||
//Check if has transport, without any the soap client will give error
|
||||
if (strpos($object->webservices_url, "http") === false)
|
||||
{
|
||||
$object->webservices_url = "http://".$object->webservices_url;
|
||||
}
|
||||
if (! isValidUrl($object->webservices_url)) {
|
||||
$langs->load("errors");
|
||||
$error++; $errors[] = $langs->trans("ErrorBadUrl",$object->webservices_url);
|
||||
}
|
||||
}
|
||||
|
||||
// We set country_id, country_code and country for the selected country
|
||||
$object->country_id=GETPOST('country_id')!=''?GETPOST('country_id'):$mysoc->country_id;
|
||||
if ($object->country_id)
|
||||
{
|
||||
$tmparray=getCountry($object->country_id,'all');
|
||||
$object->country_code=$tmparray['code'];
|
||||
$object->country=$tmparray['label'];
|
||||
}
|
||||
// We set country_id, country_code and country for the selected country
|
||||
$object->country_id=GETPOST('country_id')!=''?GETPOST('country_id'):$mysoc->country_id;
|
||||
if ($object->country_id)
|
||||
{
|
||||
$tmparray=getCountry($object->country_id,'all');
|
||||
$object->country_code=$tmparray['code'];
|
||||
$object->country=$tmparray['label'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
@ -992,7 +986,7 @@ else
|
||||
|
||||
dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error');
|
||||
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
|
||||
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc" autocomplete="off">'; // Chrome ignor autocomplete
|
||||
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
|
||||
@ -197,7 +197,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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,7 +157,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1233,6 +1233,9 @@ div.heightref {
|
||||
div.divphotoref {
|
||||
padding-right: 20px;
|
||||
}
|
||||
div.paginationref {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
div.statusref {
|
||||
float: right;
|
||||
padding-left: 12px;
|
||||
@ -2933,13 +2936,11 @@ span.dashboardlineko {
|
||||
float: right;
|
||||
position: relative;
|
||||
text-align: right;
|
||||
top: -24px;
|
||||
padding: 1px 2px 1px 2px;
|
||||
top: -26px;
|
||||
padding: 0px 5px 0px 5px;
|
||||
border-radius: .25em;
|
||||
|
||||
background-color: #9f4705;
|
||||
padding: 0px 5px 0px 5px;
|
||||
top: -26px;
|
||||
}
|
||||
.imglatecoin {
|
||||
padding: 1px 3px 1px 1px;
|
||||
|
||||
@ -1273,6 +1273,9 @@ div.heightref {
|
||||
div.divphotoref {
|
||||
padding-right: 20px;
|
||||
}
|
||||
div.paginationref {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
div.statusref {
|
||||
float: right;
|
||||
padding-left: 12px;
|
||||
|
||||
@ -384,7 +384,9 @@ class User extends CommonObject
|
||||
{
|
||||
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->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
|
||||
@ -392,10 +394,20 @@ class User extends CommonObject
|
||||
$pagewithoutquerystring=$reg[1];
|
||||
$pagequeries=$reg[2];
|
||||
}
|
||||
$this->default_values[$pagewithoutquerystring][$obj->type][$obj->param]=$obj->value;
|
||||
if ($pagequeries) $this->default_values[$pagewithoutquerystring][$obj->type.'_queries']=$pagequeries;
|
||||
$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
|
||||
@ -2058,7 +2070,7 @@ class User extends CommonObject
|
||||
|
||||
$label.= '<div class="centpercent">';
|
||||
$label.= '<u>' . $langs->trans("User") . '</u><br>';
|
||||
$label.= '<b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs,'','');
|
||||
$label.= '<b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs,'');
|
||||
if (! empty($this->login))
|
||||
$label.= '<br><b>' . $langs->trans('Login') . ':</b> ' . $this->login;
|
||||
$label.= '<br><b>' . $langs->trans("EMail").':</b> '.$this->email;
|
||||
|
||||
@ -105,7 +105,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key => $val)
|
||||
{
|
||||
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], '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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -52,6 +52,7 @@ class WebsitePage extends CommonObject
|
||||
public $title;
|
||||
public $description;
|
||||
public $keywords;
|
||||
public $htmlheader;
|
||||
public $content;
|
||||
public $status;
|
||||
public $date_creation;
|
||||
@ -67,11 +68,12 @@ class WebsitePage extends CommonObject
|
||||
'title' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1),
|
||||
'description' =>array('type'=>'varchar(255)', 'label'=>'Description', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1),
|
||||
'keywords' =>array('type'=>'varchar(255)', 'label'=>'Keywords', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0),
|
||||
'content' =>array('type'=>'mediumtext', 'label'=>'Content', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0),
|
||||
'lang' =>array('type'=>'varchar(6)', 'label'=>'Lang', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0),
|
||||
'lang' =>array('type'=>'varchar(6)', 'label'=>'Lang', 'enabled'=>1, 'visible'=>1, 'position'=>45, 'searchall'=>0),
|
||||
//'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000),
|
||||
'fk_website' =>array('type'=>'integer', 'label'=>'WebsiteId', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>40, 'searchall'=>0, 'foreignkey'=>'websitepage.rowid'),
|
||||
'fk_page' =>array('type'=>'integer', 'label'=>'ParentPageId', 'enabled'=>1, 'visible'=>1, 'notnull'=>-1, 'position'=>45, 'searchall'=>0, 'foreignkey'=>'website.rowid'),
|
||||
'htmlheader' =>array('type'=>'text', 'label'=>'HtmlHeader', 'enabled'=>1, 'visible'=>0, 'position'=>50, 'searchall'=>0),
|
||||
'content' =>array('type'=>'mediumtext', 'label'=>'Content', 'enabled'=>1, 'visible'=>0, 'position'=>51, 'searchall'=>0),
|
||||
'grabbed_from' =>array('type'=>'varchar(255)', 'label'=>'GrabbedFrom', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>400, 'comment'=>'URL page content was grabbed from'),
|
||||
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
|
||||
@ -126,6 +128,7 @@ class WebsitePage extends CommonObject
|
||||
$sql .= " t.title,";
|
||||
$sql .= " t.description,";
|
||||
$sql .= " t.keywords,";
|
||||
$sql .= " t.htmlheader,";
|
||||
$sql .= " t.content,";
|
||||
$sql .= " t.lang,";
|
||||
$sql .= " t.fk_page,";
|
||||
@ -162,6 +165,7 @@ class WebsitePage extends CommonObject
|
||||
$this->title = $obj->title;
|
||||
$this->description = $obj->description;
|
||||
$this->keywords = $obj->keywords;
|
||||
$this->htmlheader = $obj->htmlheader;
|
||||
$this->content = $obj->content;
|
||||
$this->lang = $obj->lang;
|
||||
$this->fk_page = $obj->fk_page;
|
||||
@ -210,6 +214,7 @@ class WebsitePage extends CommonObject
|
||||
$sql .= " t.title,";
|
||||
$sql .= " t.description,";
|
||||
$sql .= " t.keywords,";
|
||||
$sql .= " t.htmlheader,";
|
||||
$sql .= " t.content,";
|
||||
$sql .= " t.lang,";
|
||||
$sql .= " t.fk_page,";
|
||||
@ -255,6 +260,7 @@ class WebsitePage extends CommonObject
|
||||
$record->title = $obj->title;
|
||||
$record->description = $obj->description;
|
||||
$record->keywords = $obj->keywords;
|
||||
$record->htmlheader = $obj->htmlheader;
|
||||
$record->content = $obj->content;
|
||||
$record->lang = $obj->lang;
|
||||
$record->fk_page = $obj->fk_page;
|
||||
@ -469,6 +475,7 @@ class WebsitePage extends CommonObject
|
||||
$this->title = 'My Page';
|
||||
$this->description = 'This is my page';
|
||||
$this->keywords = 'keyword1, keyword2';
|
||||
$this->htmlheader = '';
|
||||
$this->content = '<html><body>This is a html content</body></html>';
|
||||
$this->status = '';
|
||||
$this->grabbed_from = '';
|
||||
|
||||
@ -94,6 +94,7 @@ $pageid=GETPOST('pageid', 'int');
|
||||
$pageref=GETPOST('pageref', 'aZ09');
|
||||
$action=GETPOST('action','alpha');
|
||||
|
||||
|
||||
if (GETPOST('delete')) { $action='delete'; }
|
||||
if (GETPOST('preview')) $action='preview';
|
||||
if (GETPOST('createsite')) { $action='createsite'; }
|
||||
@ -246,7 +247,11 @@ if ($action == 'add')
|
||||
|
||||
$urltograbwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\/?/i', '', $urltograbwithoutdomain);
|
||||
$objectpage->pageurl = basename($urltograbwithoutdomain);
|
||||
if (empty($objectpage->pageurl)) $objectpage->pageurl='home';
|
||||
if (empty($objectpage->pageurl))
|
||||
{
|
||||
$tmpdomain = getDomainFromURL($urltograb);
|
||||
$objectpage->pageurl='home'.$tmpdomain;
|
||||
}
|
||||
|
||||
if (preg_match('/<title>(.*)<\/title>/ims', $head, $regtmp))
|
||||
{
|
||||
@ -270,6 +275,52 @@ if ($action == 'add')
|
||||
$objectpage->content = preg_replace('/^.*<body[^>]*>/ims', '', $objectpage->content);
|
||||
$objectpage->content = preg_replace('/<\/body[^>]*>.*$/ims', '', $objectpage->content);
|
||||
|
||||
|
||||
// Now loop to fetch all css files. Include them inline into header of page
|
||||
// TODO...
|
||||
|
||||
|
||||
$tmp = $objectpage->content;
|
||||
|
||||
// Now loop to fetch all images
|
||||
preg_match_all('/<img([^\.\/]+)src="([^>"]+)"([^>]*)>/i', $objectpage->content, $regs);
|
||||
foreach ($regs[0] as $key => $val)
|
||||
{
|
||||
$urltograbbis = $urltograb.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
|
||||
$linkwithoutdomain = $regs[2][$key];
|
||||
$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key];
|
||||
if (preg_match('/^http/', $regs[2][$key]))
|
||||
{
|
||||
$urltograbbis = $regs[2][$key];
|
||||
$linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]);
|
||||
$filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
|
||||
}
|
||||
|
||||
$tmpgeturl = getURLContent($urltograbbis);
|
||||
if ($tmpgeturl['curl_error_no'])
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($tmpgeturl['curl_error_msg'], null, 'errors');
|
||||
$action='create';
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_mkdir(dirname($filetosave));
|
||||
|
||||
$fp = fopen($filetosave, "w");
|
||||
fputs($fp, $tmpgeturl['content']);
|
||||
fclose($fp);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
|
||||
$filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain;
|
||||
$tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', '<img'.$regs[1][$key].'src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'"'.$regs[3][$key].'>', $tmp);
|
||||
}
|
||||
|
||||
//print dol_escape_htmltag($tmp);exit;
|
||||
$objectpage->content = $tmp;
|
||||
|
||||
$objectpage->grabbed_from = $urltograb;
|
||||
}
|
||||
}
|
||||
@ -312,6 +363,33 @@ if ($action == 'add')
|
||||
$error++;
|
||||
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
|
||||
}
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
if (! empty($objectpage->content))
|
||||
{
|
||||
$filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php';
|
||||
$filetpl=$pathofwebsite.'/page'.$objectpage->id.'.tpl.php';
|
||||
|
||||
// Save page alias
|
||||
$result=dolSavePageAlias($filealias, $object, $objectpage);
|
||||
if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors');
|
||||
|
||||
// Save page of content
|
||||
$result=dolSavePageContent($filetpl, $object, $objectpage);
|
||||
if ($result)
|
||||
{
|
||||
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
||||
//header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
|
||||
//exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filetpl, null, 'errors');
|
||||
//header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
|
||||
//exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
@ -326,8 +404,36 @@ if ($action == 'add')
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$action = 'preview';
|
||||
$pageid = $objectpage->id;
|
||||
$pageid = $objectpage->id;
|
||||
|
||||
// To generate the CSS, robot and htmlheader file.
|
||||
|
||||
if (! dol_is_file($filehtmlheader))
|
||||
{
|
||||
// TODO use header of page for common header ?
|
||||
$htmlheadercontent = "<!-- HTML header content (common for all pages) -->";
|
||||
$result=dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
|
||||
}
|
||||
|
||||
if (! dol_is_file($filecss))
|
||||
{
|
||||
$csscontent = "/* CSS content (all pages) */\nbody.bodywebsite { margin: 0; }'";
|
||||
$result=dolSaveCssFile($filecss, $csscontent);
|
||||
}
|
||||
|
||||
if (! dol_is_file($filerobot))
|
||||
{
|
||||
$robotcontent = "# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
|
||||
$result=dolSaveRobotFile($filerobot, $robotcontent);
|
||||
}
|
||||
|
||||
if (! dol_is_file($filehtaccess))
|
||||
{
|
||||
$htaccesscontent = "# Order allow,deny\n# Deny from all";
|
||||
$result=dolSaveHtaccessFile($filehtaccess, $htaccesscontent);
|
||||
}
|
||||
|
||||
$action = 'preview';
|
||||
}
|
||||
}
|
||||
|
||||
@ -400,18 +506,8 @@ if ($action == 'updatecss')
|
||||
|
||||
$htmlheadercontent = trim($htmlheadercontent)."\n";
|
||||
|
||||
dol_syslog("Save html header into ".$filehtmlheader);
|
||||
dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filehtmlheader, $htmlheadercontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
|
||||
}
|
||||
|
||||
// Css file
|
||||
$csscontent ='';
|
||||
@ -1446,6 +1542,12 @@ if ($action == 'editmeta' || $action == 'create')
|
||||
|
||||
if ($action != 'create')
|
||||
{
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('IDOfPage');
|
||||
print '</td><td>';
|
||||
print $pageid;
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td class="titlefield">';
|
||||
print $langs->trans('WEBSITE_PAGEURL');
|
||||
print '</td><td>';
|
||||
@ -1737,3 +1839,117 @@ function dolSavePageContent($filetpl, $object, $objectpage)
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filehtmlheader Full path of filename to generate
|
||||
* @param string $htmlheadercontent Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save html header into ".$filehtmlheader);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filehtmlheader, $htmlheadercontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filecss Full path of filename to generate
|
||||
* @param string $csscontent Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveCssFile($filecss, $csscontent)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save html header into ".$filecss);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filecss, $csscontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filecss, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filerobot Full path of filename to generate
|
||||
* @param string $robotcontent Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveRobotFile($filerobot, $robotcontent)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save html header into ".$filerobot);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filerobot, $robotcontent);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filerobot, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save content of a page on disk
|
||||
*
|
||||
* @param string $filehtaccess Full path of filename to generate
|
||||
* @param string $htaccess Content of file
|
||||
* @return boolean True if OK
|
||||
*/
|
||||
function dolSaveHtaccessFile($filehtaccess, $htaccess)
|
||||
{
|
||||
global $conf, $pathofwebsite;
|
||||
|
||||
dol_syslog("Save html header into ".$filehtaccess);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
$result = file_put_contents($filehtaccess, $htaccess);
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -272,12 +272,41 @@ class FactureTest extends PHPUnit_Framework_TestCase
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
// Force default setup
|
||||
unset($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED);
|
||||
unset($conf->global->INVOICE_CAN_NEVER_BE_REMOVED);
|
||||
|
||||
$localobject=new Facture($this->savdb);
|
||||
$result=$localobject->fetch($id);
|
||||
$result=$localobject->delete($user);
|
||||
|
||||
// Create another invoice and validate it after $localobject
|
||||
$localobject2=new Facture($this->savdb);
|
||||
$result=$localobject2->initAsSpecimen();
|
||||
$result=$localobject2->create($user);
|
||||
$result=$localobject2->validate($user);
|
||||
print 'Invoice localobject ref = '.$localobject->ref."\n";
|
||||
print 'Invoice $localobject2 created with ref = '.$localobject2->ref."\n";
|
||||
|
||||
$conf->global->INVOICE_CAN_NEVER_BE_REMOVED = 1;
|
||||
|
||||
$result=$localobject2->delete($user); // Deletion is KO, option INVOICE_CAN_NEVER_BE_REMOVED is on
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThanOrEqual(0, $result);
|
||||
$this->assertEquals(0, $result, 'Deletion should fail, option INVOICE_CAN_NEVER_BE_REMOVED is on');
|
||||
|
||||
unset($conf->global->INVOICE_CAN_NEVER_BE_REMOVED);
|
||||
|
||||
$result=$localobject->delete($user); // Deletion is KO, it is not last invoice
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertEquals(0, $result, 'Deletion should fail, it is not last invoice');
|
||||
|
||||
$result=$localobject2->delete($user); // Deletion is OK, it is last invoice
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Deletion should work, it is last invoice');
|
||||
|
||||
$result=$localobject->delete($user); // Deletion is KO, it is not last invoice
|
||||
print __METHOD__." id=".$id." result=".$result."\n";
|
||||
$this->assertGreaterThan(0, $result, 'Deletion should work, it is again last invoice');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user