';
if ($picto) $return .= ''.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).' ';
$return .= '';
$return .= ''.$titre.'
';
@@ -4217,8 +4283,9 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
print ''; // maring bottom must be same than into load_fiche_tire
// Left
+
+ if ($picto && $titre) print ''.img_picto('', $picto, 'class="valignmiddle pictotitle widthpictotitle"', $pictoisfullpath).' ';
print '';
- if ($picto && $titre) print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
print ''.$titre;
if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') print ' ('.$totalnboflines.')';
print '
';
@@ -5294,10 +5361,10 @@ function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $id
/**
* Return yes or no in current language
*
- * @param string $yesno Value to test (1, 'yes', 'true' or 0, 'no', 'false')
- * @param integer $case 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No
- * @param int $color 0=texte only, 1=Text is formated with a color font style ('ok' or 'error'), 2=Text is formated with 'ok' color.
- * @return string HTML string
+ * @param string|int $yesno Value to test (1, 'yes', 'true' or 0, 'no', 'false')
+ * @param integer $case 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No
+ * @param int $color 0=texte only, 1=Text is formated with a color font style ('ok' or 'error'), 2=Text is formated with 'ok' color.
+ * @return string HTML string
*/
function yn($yesno, $case = 1, $color = 0)
{
@@ -5509,22 +5576,27 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
/**
* Clean a string to keep only desirable HTML tags.
*
- * @param string $stringtoclean String to clean
- * @return string String cleaned
+ * @param string $stringtoclean String to clean
+ * @param string $cleanalsosomestyles Clean also some tags
+ * @return string String cleaned
*
* @see dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_neverthesehtmltags()
*/
-function dol_string_onlythesehtmltags($stringtoclean)
+function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1)
{
$allowed_tags = array(
- "html", "head", "meta", "body", "article", "a", "b", "br", "div", "em", "font", "img", "ins", "hr", "i", "li", "link",
- "ol", "p", "s", "section", "span", "strong", "title",
+ "html", "head", "meta", "body", "article", "a", "abbr", "b", "blockquote", "br", "cite", "div", "dl", "dd", "dt", "em", "font", "img", "ins", "hr", "i", "li", "link",
+ "ol", "p", "q", "s", "section", "span", "strike", "strong", "title",
"table", "tr", "th", "td", "u", "ul"
);
-
$allowed_tags_string = join("><", $allowed_tags);
$allowed_tags_string = preg_replace('/^>/', '', $allowed_tags_string);
$allowed_tags_string = preg_replace('/<$/', '', $allowed_tags_string);
+ $allowed_tags_string = '<'.$allowed_tags_string.'>';
+
+ if ($cleanalsosomestyles) {
+ $stringtoclean = preg_replace('/position\s*:\s*(absolute|fixed)\s*!\s*important/', '', $stringtoclean); // Note: If hacker try to introduce css comment into string to avoid this, string should be encoded by the dol_htmlentitiesbr so be harmless
+ }
$temp = strip_tags($stringtoclean, $allowed_tags_string);
@@ -5533,14 +5605,16 @@ function dol_string_onlythesehtmltags($stringtoclean)
/**
* Clean a string from some undesirable HTML tags.
+ * Note. Not enough secured as dol_string_onlythesehtmltags().
*
- * @param string $stringtoclean String to clean
- * @param array $disallowed_tags Array of tags not allowed
- * @return string String cleaned
+ * @param string $stringtoclean String to clean
+ * @param array $disallowed_tags Array of tags not allowed
+ * @param string $cleanalsosomestyles Clean also some tags
+ * @return string String cleaned
*
* @see dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_onlythesehtmltags()
*/
-function dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags = array('textarea'))
+function dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags = array('textarea'), $cleanalsosomestyles = 0)
{
$temp = $stringtoclean;
foreach ($disallowed_tags as $tagtoremove)
@@ -5548,6 +5622,11 @@ function dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags = array(
$temp = preg_replace('/<\/?'.$tagtoremove.'>/', '', $temp);
$temp = preg_replace('/<\/?'.$tagtoremove.'\s+[^>]*>/', '', $temp);
}
+
+ if ($cleanalsosomestyles) {
+ $temp = preg_replace('/position\s*:\s*(absolute|fixed)\s*!\s*important/', '', $temp); // Note: If hacker try to introduce css comment into string to avoid this, string should be encoded by the dol_htmlentitiesbr so be harmless
+ }
+
return $temp;
}
@@ -5946,7 +6025,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
'__MYCOMPANY_TOWN__' => $mysoc->town,
'__MYCOMPANY_COUNTRY__' => $mysoc->country,
'__MYCOMPANY_COUNTRY_ID__' => $mysoc->country_id,
- '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency
+ '__MYCOMPANY_COUNTRY_CODE__' => $mysoc->country_code,
+ '__MYCOMPANY_CURRENCY_CODE__' => $conf->currency
));
}
@@ -6044,7 +6124,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));
$substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
$substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs) : '');
- $substitutionarray['__SUPPLIER_ORDER_DELAY_DELIVERY__'] = $outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
+ $substitutionarray['__SUPPLIER_ORDER_DELAY_DELIVERY__'] = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '');
$birthday = dol_print_date($object->birth, 'day');
@@ -6089,6 +6169,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address : '');
$substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip : '');
$substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town : '');
+ $substitutionarray['__THIRDPARTY_COUNTRY_ID__'] = (is_object($object) ? $object->country_id : '');
+ $substitutionarray['__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object) ? $object->country_code : '');
$substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object) ? $object->idprof1 : '');
$substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object) ? $object->idprof2 : '');
$substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object) ? $object->idprof3 : '');
@@ -6112,6 +6194,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address : '');
$substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip : '');
$substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town : '');
+ $substitutionarray['__THIRDPARTY_COUNTRY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_id : '');
+ $substitutionarray['__THIRDPARTY_COUNTRY_CODE__'] = (is_object($object->thirdparty) ? $object->thirdparty->country_code : '');
$substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof1 : '');
$substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof2 : '');
$substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof3 : '');
@@ -6855,6 +6939,24 @@ function utf8_check($str)
return true;
}
+/**
+ * Check if a string is in ASCII
+ *
+ * @param string $str String to check
+ * @return boolean True if string is ASCII, False if not (byte value > 0x7F)
+ */
+function ascii_check($str)
+{
+ if (function_exists('mb_check_encoding')) {
+ //if (mb_detect_encoding($str, 'ASCII', true) return false;
+ if (!mb_check_encoding($str, 'ASCII')) return false;
+ } else {
+ if (preg_match('/[^\x00-\x7f]/', $str)) return false; // Contains a byte > 7f
+ }
+
+ return true;
+}
+
/**
* Return a string encoded into OS filesystem encoding. This function is used to define
@@ -7417,7 +7519,7 @@ function printCommonFooter($zone = 'private')
if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'), '/').'/', '', $relativepathstring);
$relativepathstring = preg_replace('/^\//', '', $relativepathstring);
$relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
- $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
+ //$tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
if (!empty($user->default_values[$relativepathstring]['focus']))
{
foreach ($user->default_values[$relativepathstring]['focus'] as $defkey => $defval)
@@ -7429,7 +7531,9 @@ function printCommonFooter($zone = 'private')
$foundintru = 0;
foreach ($tmpqueryarraytohave as $tmpquerytohave)
{
- if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru = 1;
+ $tmpquerytohaveparam = explode('=', $tmpquerytohave);
+ //print "console.log('".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');";
+ if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) $foundintru = 1;
}
if (!$foundintru) $qualified = 1;
//var_dump($defkey.'-'.$qualified);
@@ -7459,7 +7563,9 @@ function printCommonFooter($zone = 'private')
$foundintru = 0;
foreach ($tmpqueryarraytohave as $tmpquerytohave)
{
- if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) $foundintru = 1;
+ $tmpquerytohaveparam = explode('=', $tmpquerytohave);
+ //print "console.log('".$tmpquerytohaveparam[0]." ".$tmpquerytohaveparam[1]." ".GETPOST($tmpquerytohaveparam[0])."');";
+ if (!GETPOSTISSET($tmpquerytohaveparam[0]) || ($tmpquerytohaveparam[1] != GETPOST($tmpquerytohaveparam[0]))) $foundintru = 1;
}
if (!$foundintru) $qualified = 1;
//var_dump($defkey.'-'.$qualified);
@@ -7933,7 +8039,7 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
if (preg_match('/\.bas$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'bas'; $famime = 'file-code-o'; }
if (preg_match('/\.(c)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'c'; $famime = 'file-code-o'; }
if (preg_match('/\.(cpp)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cpp'; $famime = 'file-code-o'; }
- if (preg_match('/\.cs$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cs'; $famime = 'file-code-o'; }
+ if (preg_match('/\.cs$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cs'; $famime = 'file-code-o'; }
if (preg_match('/\.(h)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'h'; $famime = 'file-code-o'; }
if (preg_match('/\.(java|jsp)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'java'; $famime = 'file-code-o'; }
if (preg_match('/\.php([0-9]{1})?$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'php.png'; $srclang = 'php'; $famime = 'file-code-o'; }
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index 4d105e0074e..98d636e97dd 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -2627,7 +2627,7 @@ function price2fec($amount)
global $conf;
// Clean parameters
- if (empty($amount)) $amount=0; // To have a numeric value if amount not defined or = ''
+ if (empty($amount)) $amount = 0; // To have a numeric value if amount not defined or = ''
$amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number)
// Output decimal number by default
diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php
index 5fbb799b7dc..26db2bbec90 100644
--- a/htdocs/core/lib/functionsnumtoword.lib.php
+++ b/htdocs/core/lib/functionsnumtoword.lib.php
@@ -25,7 +25,7 @@
/**
* Function to return number in text.
- *
+ * May use module NUMBERWORDS if found.
*
* @param float $num Number to convert
* @param Translate $langs Language
@@ -38,100 +38,113 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
global $conf;
$num = str_replace(array(',', ' '), '', trim($num));
- if (! $num) {
+ if (!$num) {
return false;
}
+
if ($centimes && strlen($num) == 1) {
- $num = $num*10;
- }
- $TNum = explode('.', $num);
- $num = (int) $TNum[0];
- $words = array();
- $list1 = array(
- '',
- $langs->transnoentitiesnoconv('one'),
- $langs->transnoentitiesnoconv('two'),
- $langs->transnoentitiesnoconv('three'),
- $langs->transnoentitiesnoconv('four'),
- $langs->transnoentitiesnoconv('five'),
- $langs->transnoentitiesnoconv('six'),
- $langs->transnoentitiesnoconv('seven'),
- $langs->transnoentitiesnoconv('eight'),
- $langs->transnoentitiesnoconv('nine'),
- $langs->transnoentitiesnoconv('ten'),
- $langs->transnoentitiesnoconv('eleven'),
- $langs->transnoentitiesnoconv('twelve'),
- $langs->transnoentitiesnoconv('thirteen'),
- $langs->transnoentitiesnoconv('fourteen'),
- $langs->transnoentitiesnoconv('fifteen'),
- $langs->transnoentitiesnoconv('sixteen'),
- $langs->transnoentitiesnoconv('seventeen'),
- $langs->transnoentitiesnoconv('eighteen'),
- $langs->transnoentitiesnoconv('nineteen')
- );
- $list2 = array(
- '',
- $langs->transnoentitiesnoconv('ten'),
- $langs->transnoentitiesnoconv('twenty'),
- $langs->transnoentitiesnoconv('thirty'),
- $langs->transnoentitiesnoconv('forty'),
- $langs->transnoentitiesnoconv('fifty'),
- $langs->transnoentitiesnoconv('sixty'),
- $langs->transnoentitiesnoconv('seventy'),
- $langs->transnoentitiesnoconv('eighty'),
- $langs->transnoentitiesnoconv('ninety'),
- $langs->transnoentitiesnoconv('hundred')
- );
- $list3 = array(
- '',
- $langs->transnoentitiesnoconv('thousand'),
- $langs->transnoentitiesnoconv('million'),
- $langs->transnoentitiesnoconv('billion'),
- $langs->transnoentitiesnoconv('trillion'),
- $langs->transnoentitiesnoconv('quadrillion')
- );
-
- $num_length = strlen($num);
- $levels = (int) (($num_length + 2) / 3);
- $max_length = $levels * 3;
- $num = substr('00' . $num, -$max_length);
- $num_levels = str_split($num, 3);
- $nboflevels = count($num_levels);
- for ($i = 0; $i < $nboflevels; $i++) {
- $levels--;
- $hundreds = (int) ($num_levels[$i] / 100);
- $hundreds = ($hundreds ? ' ' . $list1[$hundreds] . ' '.$langs->transnoentities('hundred') . ( $hundreds == 1 ? '' : 's' ) . ' ': '');
- $tens = (int) ($num_levels[$i] % 100);
- $singles = '';
- if ( $tens < 20 ) {
- $tens = ($tens ? ' ' . $list1[$tens] . ' ' : '' );
- } else {
- $tens = (int) ($tens / 10);
- $tens = ' ' . $list2[$tens] . ' ';
- $singles = (int) ($num_levels[$i] % 10);
- $singles = ' ' . $list1[$singles] . ' ';
- }
- $words[] = $hundreds . $tens . $singles . ( ( $levels && ( int ) ( $num_levels[$i] ) ) ? ' ' . $list3[$levels] . ' ' : '' );
- } //end for loop
- $commas = count($words);
- if ($commas > 1) {
- $commas = $commas - 1;
- }
- $concatWords = implode(' ', $words);
- // Delete multi whitespaces
- $concatWords = trim(preg_replace('/[ ]+/', ' ', $concatWords));
-
- if(!empty($currency)) {
- $concatWords .= ' '.$currency;
+ $num = $num * 10;
}
- // If we need to write cents call again this function for cents
- if(!empty($TNum[1])) {
- if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and');
- $concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true);
- if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes');
+ if (!empty($conf->global->MAIN_MODULE_NUMBERWORDS)) {
+ if ($currency) {
+ $type = 1;
+ } else {
+ $type = 0;
+ }
+
+ $concatWords = $langs->getLabelFromNumber($num, $type);
+ return $concatWords;
+ } else {
+ $TNum = explode('.', $num);
+ $num = (int) $TNum[0];
+ $words = array();
+ $list1 = array(
+ '',
+ $langs->transnoentitiesnoconv('one'),
+ $langs->transnoentitiesnoconv('two'),
+ $langs->transnoentitiesnoconv('three'),
+ $langs->transnoentitiesnoconv('four'),
+ $langs->transnoentitiesnoconv('five'),
+ $langs->transnoentitiesnoconv('six'),
+ $langs->transnoentitiesnoconv('seven'),
+ $langs->transnoentitiesnoconv('eight'),
+ $langs->transnoentitiesnoconv('nine'),
+ $langs->transnoentitiesnoconv('ten'),
+ $langs->transnoentitiesnoconv('eleven'),
+ $langs->transnoentitiesnoconv('twelve'),
+ $langs->transnoentitiesnoconv('thirteen'),
+ $langs->transnoentitiesnoconv('fourteen'),
+ $langs->transnoentitiesnoconv('fifteen'),
+ $langs->transnoentitiesnoconv('sixteen'),
+ $langs->transnoentitiesnoconv('seventeen'),
+ $langs->transnoentitiesnoconv('eighteen'),
+ $langs->transnoentitiesnoconv('nineteen')
+ );
+ $list2 = array(
+ '',
+ $langs->transnoentitiesnoconv('ten'),
+ $langs->transnoentitiesnoconv('twenty'),
+ $langs->transnoentitiesnoconv('thirty'),
+ $langs->transnoentitiesnoconv('forty'),
+ $langs->transnoentitiesnoconv('fifty'),
+ $langs->transnoentitiesnoconv('sixty'),
+ $langs->transnoentitiesnoconv('seventy'),
+ $langs->transnoentitiesnoconv('eighty'),
+ $langs->transnoentitiesnoconv('ninety'),
+ $langs->transnoentitiesnoconv('hundred')
+ );
+ $list3 = array(
+ '',
+ $langs->transnoentitiesnoconv('thousand'),
+ $langs->transnoentitiesnoconv('million'),
+ $langs->transnoentitiesnoconv('billion'),
+ $langs->transnoentitiesnoconv('trillion'),
+ $langs->transnoentitiesnoconv('quadrillion')
+ );
+
+ $num_length = strlen($num);
+ $levels = (int) (($num_length + 2) / 3);
+ $max_length = $levels * 3;
+ $num = substr('00'.$num, -$max_length);
+ $num_levels = str_split($num, 3);
+ $nboflevels = count($num_levels);
+ for ($i = 0; $i < $nboflevels; $i++) {
+ $levels--;
+ $hundreds = (int) ($num_levels[$i] / 100);
+ $hundreds = ($hundreds ? ' '.$list1[$hundreds].' '.$langs->transnoentities('hundred').($hundreds == 1 ? '' : 's').' ' : '');
+ $tens = (int) ($num_levels[$i] % 100);
+ $singles = '';
+ if ($tens < 20) {
+ $tens = ($tens ? ' '.$list1[$tens].' ' : '');
+ } else {
+ $tens = (int) ($tens / 10);
+ $tens = ' '.$list2[$tens].' ';
+ $singles = (int) ($num_levels[$i] % 10);
+ $singles = ' '.$list1[$singles].' ';
+ }
+ $words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ? ' '.$list3[$levels].' ' : '');
+ } //end for loop
+ $commas = count($words);
+ if ($commas > 1) {
+ $commas = $commas - 1;
+ }
+ $concatWords = implode(' ', $words);
+ // Delete multi whitespaces
+ $concatWords = trim(preg_replace('/[ ]+/', ' ', $concatWords));
+
+ if (!empty($currency)) {
+ $concatWords .= ' '.$currency;
+ }
+
+ // If we need to write cents call again this function for cents
+ if (!empty($TNum[1])) {
+ if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and');
+ $concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true);
+ if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes');
+ }
+ return $concatWords;
}
- return $concatWords;
}
@@ -152,35 +165,35 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
return -1;
// Get 2 decimals to cents, another functions round or truncate
$strnumber = number_format($numero, 10);
- $len=strlen($strnumber);
- for ($i=0; $i<$len; $i++)
+ $len = strlen($strnumber);
+ for ($i = 0; $i < $len; $i++)
{
- if ($strnumber[$i]=='.') {
- $parte_decimal = $strnumber[$i+1].$strnumber[$i+2];
+ if ($strnumber[$i] == '.') {
+ $parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2];
break;
}
}
/*In dolibarr 3.6.2 (my current version) doesn't have $langs->default and
in case exist why ask $lang like a parameter?*/
- if (((is_object($langs) && $langs->default == 'es_MX') || (! is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency')
+ if (((is_object($langs) && $langs->default == 'es_MX') || (!is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency')
{
- if ($numero>=1 && $numero<2) {
+ if ($numero >= 1 && $numero < 2) {
return ("UN PESO ".$parte_decimal." / 100 M.N.");
}
- elseif ($numero>=0 && $numero<1){
+ elseif ($numero >= 0 && $numero < 1) {
return ("CERO PESOS ".$parte_decimal." / 100 M.N.");
}
- elseif ($numero>=1000000 && $numero<1000001){
+ elseif ($numero >= 1000000 && $numero < 1000001) {
return ("UN MILLÓN DE PESOS ".$parte_decimal." / 100 M.N.");
}
- elseif ($numero>=1000000000000 && $numero<1000000000001){
+ elseif ($numero >= 1000000000000 && $numero < 1000000000001) {
return ("UN BILLÓN DE PESOS ".$parte_decimal." / 100 M.N.");
}
else {
- $entexto ="";
+ $entexto = "";
$number = $numero;
- if ($number >= 1000000000){
+ if ($number >= 1000000000) {
$CdMMillon = (int) ($numero / 100000000000);
$numero = $numero - $CdMMillon * 100000000000;
$DdMMillon = (int) ($numero / 10000000000);
@@ -190,7 +203,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
$entexto .= hundreds2text($CdMMillon, $DdMMillon, $UdMMillon);
$entexto .= " MIL ";
}
- if ($number >= 1000000){
+ if ($number >= 1000000) {
$CdMILLON = (int) ($numero / 100000000);
$numero = $numero - $CdMILLON * 100000000;
$DdMILLON = (int) ($numero / 10000000);
@@ -198,7 +211,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
$udMILLON = (int) ($numero / 1000000);
$numero = $numero - $udMILLON * 1000000;
$entexto .= hundreds2text($CdMILLON, $DdMILLON, $udMILLON);
- if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON==1)
+ if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1)
$entexto .= " MILLÓN ";
else
$entexto .= " MILLONES ";
@@ -219,7 +232,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
$d = (int) ($numero / 10);
$u = (int) $numero - $d * 10;
$entexto .= hundreds2text($c, $d, $u);
- if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number>1000000)
+ if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number > 1000000)
$entexto .= " DE";
$entexto .= " PESOS ".$parte_decimal." / 100 M.N.";
}
@@ -237,40 +250,40 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
*/
function hundreds2text($hundreds, $tens, $units)
{
- if ($hundreds==1 && $tens==0 && $units==0){
+ if ($hundreds == 1 && $tens == 0 && $units == 0) {
return "CIEN";
}
- $centenas = array("CIENTO","DOSCIENTOS","TRESCIENTOS","CUATROCIENTOS","QUINIENTOS","SEISCIENTOS","SETECIENTOS","OCHOCIENTOS","NOVECIENTOS");
- $decenas = array("","","TREINTA ","CUARENTA ","CINCUENTA ","SESENTA ","SETENTA ","OCHENTA ","NOVENTA ");
- $veintis = array("VEINTE","VEINTIUN","VEINTIDÓS","VEINTITRÉS","VEINTICUATRO","VEINTICINCO","VEINTISÉIS","VEINTISIETE","VEINTIOCHO","VEINTINUEVE");
- $diecis = array("DIEZ","ONCE","DOCE","TRECE","CATORCE","QUINCE","DIECISÉIS","DIECISIETE","DIECIOCHO","DIECINUEVE");
- $unidades = array("UN","DOS","TRES","CUATRO","CINCO","SEIS","SIETE","OCHO","NUEVE");
+ $centenas = array("CIENTO", "DOSCIENTOS", "TRESCIENTOS", "CUATROCIENTOS", "QUINIENTOS", "SEISCIENTOS", "SETECIENTOS", "OCHOCIENTOS", "NOVECIENTOS");
+ $decenas = array("", "", "TREINTA ", "CUARENTA ", "CINCUENTA ", "SESENTA ", "SETENTA ", "OCHENTA ", "NOVENTA ");
+ $veintis = array("VEINTE", "VEINTIUN", "VEINTIDÓS", "VEINTITRÉS", "VEINTICUATRO", "VEINTICINCO", "VEINTISÉIS", "VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE");
+ $diecis = array("DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", "DIECISÉIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE");
+ $unidades = array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE");
$entexto = "";
- if ($hundreds!=0){
- $entexto .= $centenas[$hundreds-1];
+ if ($hundreds != 0) {
+ $entexto .= $centenas[$hundreds - 1];
}
- if ($tens>2){
- if ($hundreds!=0) $entexto .= " ";
- $entexto .= $decenas[$tens-1];
- if ($units!=0){
+ if ($tens > 2) {
+ if ($hundreds != 0) $entexto .= " ";
+ $entexto .= $decenas[$tens - 1];
+ if ($units != 0) {
$entexto .= " Y ";
- $entexto .= $unidades[$units-1];
+ $entexto .= $unidades[$units - 1];
}
return $entexto;
}
- elseif ($tens==2){
- if ($hundreds!=0) $entexto .= " ";
+ elseif ($tens == 2) {
+ if ($hundreds != 0) $entexto .= " ";
$entexto .= " ".$veintis[$units];
return $entexto;
}
- elseif ($tens==1){
- if ($hundreds!=0) $entexto .= " ";
+ elseif ($tens == 1) {
+ if ($hundreds != 0) $entexto .= " ";
$entexto .= $diecis[$units];
return $entexto;
}
- if ($units!=0) {
- if ($hundreds!=0 || $tens!=0) $entexto .= " ";
- $entexto .= $unidades[$units-1];
+ if ($units != 0) {
+ if ($hundreds != 0 || $tens != 0) $entexto .= " ";
+ $entexto .= $unidades[$units - 1];
}
return $entexto;
}
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index de1334c37a5..15de60eb791 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -137,13 +137,6 @@ function invoice_admin_prepare_head()
$head[$h][2] = 'payment';
$h++;
- if ($conf->global->INVOICE_USE_SITUATION || $conf->global->MAIN_FEATURES_LEVEL >= 1) {
- $head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php';
- $head[$h][1] = $langs->trans("InvoiceSituation");
- $head[$h][2] = 'situation';
- $h++;
- }
-
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
@@ -170,6 +163,11 @@ function invoice_admin_prepare_head()
$head[$h][2] = 'attributeslinesrec';
$h++;
+ $head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php';
+ $head[$h][1] = $langs->trans("InvoiceSituation");
+ $head[$h][2] = 'situation';
+ $h++;
+
complete_head_from_modules($conf, $langs, null, $head, $h, 'invoice_admin', 'remove');
return $head;
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 6de51cfe7ba..b75cb1e4bd6 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -1388,7 +1388,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
if (!empty($libelleproduitservice) && !empty($ref_prodserv)) $ref_prodserv .= " - ";
}
- if (!empty($ref_prodserv) && !empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)) { $ref_prodserv = ''.$ref_prodserv.' '; }
+ if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { $ref_prodserv = ''.$ref_prodserv.' '; }
$libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice;
// Add an additional description for the category products
@@ -1401,7 +1401,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
foreach ($tblcateg as $cate)
{
// Adding the descriptions if they are filled
- $desccateg = $cate->add_description;
+ $desccateg = $cate->description;
if ($desccateg)
$libelleproduitservice .= '__N__'.$desccateg;
}
@@ -1425,7 +1425,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
$period = '('.$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')';
}
//print '>'.$outputlangs->charset_output.','.$period;
- if (!empty($conf->global->ADD_HTML_FORMATING_INTO_DESC_DOC)) {
+ if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) {
$libelleproduitservice .= ''."__N__ ".$period.'';
} else {
$libelleproduitservice .= "__N__".$period;
@@ -2154,10 +2154,10 @@ function pdf_getLinkedObjects($object, $outputlangs)
$linkedobjects[$objecttype]['date_value'] = dol_print_date($elementobject->date_contrat, 'day', '', $outputlangs);
}
}
- else if ($objecttype == 'fichinter')
+ elseif ($objecttype == 'fichinter')
{
$outputlangs->load('interventions');
- foreach($objects as $elementobject)
+ foreach ($objects as $elementobject)
{
$linkedobjects[$objecttype]['ref_title'] = $outputlangs->transnoentities("InterRef");
$linkedobjects[$objecttype]['ref_value'] = $outputlangs->transnoentities($elementobject->ref);
diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php
index 9cf28ff20ee..79d77e0268f 100644
--- a/htdocs/core/lib/product.lib.php
+++ b/htdocs/core/lib/product.lib.php
@@ -76,13 +76,13 @@ function product_prepare_head($object)
}
// Sub products
- if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
+ if (!empty($conf->global->PRODUIT_SOUSPRODUITS))
{
$head[$h][0] = DOL_URL_ROOT."/product/composition/card.php?id=".$object->id;
$head[$h][1] = $langs->trans('AssociatedProducts');
$nbFatherAndChild = $object->hasFatherOrChild();
- if ($nbFatherAndChild > 0) $head[$h][1].= ''.$nbFatherAndChild.' ';
+ if ($nbFatherAndChild > 0) $head[$h][1] .= ''.$nbFatherAndChild.' ';
$head[$h][2] = 'subproduct';
$h++;
}
@@ -110,15 +110,15 @@ function product_prepare_head($object)
$head[$h][1] = $langs->trans('ProductCombinations');
$head[$h][2] = 'combinations';
$nbVariant = $prodcomb->countNbOfCombinationForFkProductParent($object->id);
- if ($nbVariant > 0) $head[$h][1].= ''.$nbVariant.' ';
+ if ($nbVariant > 0) $head[$h][1] .= ''.$nbVariant.' ';
}
$h++;
}
- if ($object->isProduct() || ($object->isService() && ! empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option)
+ if ($object->isProduct() || ($object->isService() && !empty($conf->global->STOCK_SUPPORTS_SERVICES))) // If physical product we can stock (or service with option)
{
- if (! empty($conf->stock->enabled) && $user->rights->stock->lire)
+ if (!empty($conf->stock->enabled) && $user->rights->stock->lire)
{
$head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$object->id;
$head[$h][1] = $langs->trans("Stock");
@@ -156,11 +156,11 @@ function product_prepare_head($object)
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$nbNote = 0;
- if(!empty($object->note_private)) $nbNote++;
- if(!empty($object->note_public)) $nbNote++;
+ if (!empty($object->note_private)) $nbNote++;
+ if (!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/product/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
- if ($nbNote > 0) $head[$h][1].= ''.$nbNote.' ';
+ if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.' ';
$head[$h][2] = 'note';
$h++;
}
@@ -168,18 +168,18 @@ function product_prepare_head($object)
// Attachments
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
- if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
- if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
+ if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
+ if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
- if (! empty($conf->product->enabled) && ($object->type==Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
- if (! empty($conf->service->enabled) && ($object->type==Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
+ if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
+ if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
$nbFiles += count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
}
- $nbLinks=Link::count($db, $object->element, $object->id);
+ $nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
- if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).' ';
+ if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).' ';
$head[$h][2] = 'documents';
$h++;
@@ -225,10 +225,10 @@ function productlot_prepare_head($object)
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
- $nbLinks=Link::count($db, $object->element, $object->id);
+ $nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT."/product/stock/productlot_document.php?id=".$object->id;
$head[$h][1] = $langs->trans("Documents");
- if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).' ';
+ if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).' ';
$head[$h][2] = 'documents';
$h++;
@@ -425,6 +425,24 @@ function show_stats_for_company($product, $socid)
print '';
print ' ';
}
+ // MO
+ if (!empty($conf->mrp->enabled) && $user->rights->mrp->read)
+ {
+ $nblines++;
+ //$ret = $product->load_stats_mo($socid);
+ if ($ret < 0) dol_print_error($db);
+ $langs->load("orders");
+ print '';
+ print ''.img_object('', 'mrp').' '.$langs->trans("MO").' ';
+ print ' ';
+ print $product->stats_mo['suppliers'];
+ print ' ';
+ print $product->stats_mo['nb'];
+ print ' ';
+ print $product->stats_mo['qty'];
+ print ' ';
+ print ' ';
+ }
// Customer invoices
if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
{
@@ -504,7 +522,7 @@ function measuring_units_string($scale = '', $measuring_style = '', $unit = 0, $
* Return translation label of a unit key
*
* @param int $unit ID of unit (rowid in llx_c_units table)
- * @param string $measuring_style Style of unit: weight, volume,...
+ * @param string $measuring_style Style of unit: 'weight', 'volume', ..., '' = 'net_measure' for option PRODUCT_ADD_NET_MEASURE
* @param string $scale Scale of unit: '0', '-3', '6', ...
* @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
* @return string Unit string
@@ -518,9 +536,16 @@ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_sho
if (empty($measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label]))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
- $measuringUnits= new CUnits($db);
+ $measuringUnits = new CUnits($db);
- if ($scale !== '')
+ if ($measuring_style == '' && $scale == '')
+ {
+ $arrayforfilter = array(
+ 't.rowid' => $unit,
+ 't.active' => 1
+ );
+ }
+ elseif ($scale !== '')
{
$arrayforfilter = array(
't.scale' => $scale,
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index b050b560197..ddca8ef1153 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -263,6 +263,14 @@ function project_timesheet_prepare_head($mode, $fuser = null)
$param .= ($mode ? '&mode='.$mode : '');
if (is_object($fuser) && $fuser->id > 0 && $fuser->id != $user->id) $param .= '&search_usertoprocessid='.$fuser->id;
+ if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERMONTH))
+ {
+ $head[$h][0] = DOL_URL_ROOT."/projet/activity/permonth.php".($param ? '?'.$param : '');
+ $head[$h][1] = $langs->trans("InputPerMonth");
+ $head[$h][2] = 'inputpermonth';
+ $h++;
+ }
+
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERWEEK))
{
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perweek.php".($param ? '?'.$param : '');
@@ -935,7 +943,7 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
// Warning
print '';
/*if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject"));
- else if ($disabledtask)
+ elseif ($disabledtask)
{
$titleassigntask = $langs->trans("AssignTaskToMe");
if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
@@ -1141,7 +1149,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
- print ' '."\n";
+ print ' '."\n";
// User
/*
@@ -1520,7 +1528,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
- print ' '."\n";
+ print ' '."\n";
// User
/*
@@ -1704,6 +1712,271 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
return $totalforeachday;
}
+/**
+ * Output a task line into a perday intput mode
+ *
+ * @param string $inc Line output identificator (start to 0, then increased by recursive call)
+ * @param int $firstdaytoshow First day to show
+ * @param User|null $fuser Restrict list to user if defined
+ * @param string $parent Id of parent task to show (0 to show all)
+ * @param Task[] $lines Array of lines (list of tasks but we will show only if we have a specific role on task)
+ * @param int $level Level (start to 0, then increased/decrease by recursive call)
+ * @param string $projectsrole Array of roles user has on project
+ * @param string $tasksrole Array of roles user has on task
+ * @param string $mine Show only task lines I am assigned to
+ * @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to
+ * @param array $isavailable Array with data that say if user is available for several days for morning and afternoon
+ * @param int $oldprojectforbreak Old project id of last project break
+ * @param array $TWeek Array of week numbers
+ * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks
+ */
+function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $TWeek = array())
+{
+ global $conf, $db, $user, $bc, $langs;
+ global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
+
+ $numlines = count($lines);
+
+ $lastprojectid = 0;
+ $workloadforid = array();
+ $totalforeachweek = array();
+ $lineswithoutlevel0 = array();
+
+ // Create a smaller array with sublevels only to be used later. This increase dramatically performances.
+ if ($parent == 0) // Always and only if at first level
+ {
+ for ($i = 0; $i < $numlines; $i++)
+ {
+ if ($lines[$i]->fk_task_parent) $lineswithoutlevel0[] = $lines[$i];
+ }
+ }
+
+ //dol_syslog('projectLinesPerWeek inc='.$inc.' firstdaytoshow='.$firstdaytoshow.' task parent id='.$parent.' level='.$level." count(lines)=".$numlines." count(lineswithoutlevel0)=".count($lineswithoutlevel0));
+
+ if (empty($oldprojectforbreak))
+ {
+ $oldprojectforbreak = (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT) ? 0 : -1); // 0 = start break, -1 = never break
+ }
+
+ for ($i = 0; $i < $numlines; $i++)
+ {
+ if ($parent == 0) $level = 0;
+
+ if ($lines[$i]->fk_task_parent == $parent)
+ {
+ // If we want all or we have a role on task, we show it
+ if (empty($mine) || !empty($tasksrole[$lines[$i]->id]))
+ {
+ //dol_syslog("projectLinesPerWeek Found line ".$i.", a qualified task (i have role or want to show all tasks) with id=".$lines[$i]->id." project id=".$lines[$i]->fk_project);
+
+ // Break on a new project
+ if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
+ {
+ $lastprojectid = $lines[$i]->fk_project;
+ $projectstatic->id = $lines[$i]->fk_project;
+ }
+
+ //var_dump('--- '.$level.' '.$firstdaytoshow.' '.$fuser->id.' '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
+ //var_dump($projectstatic->weekWorkLoadPerTask);
+ if (empty($workloadforid[$projectstatic->id]))
+ {
+ $projectstatic->loadTimeSpentMonth($firstdaytoshow, 0, $fuser->id); // Load time spent from table projet_task_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week
+ $workloadforid[$projectstatic->id] = 1;
+ }
+ //var_dump($projectstatic->weekWorkLoadPerTask);
+ //var_dump('--- '.$projectstatic->id.' '.$workloadforid[$projectstatic->id]);
+
+ $projectstatic->id = $lines[$i]->fk_project;
+ $projectstatic->ref = $lines[$i]->projectref;
+ $projectstatic->title = $lines[$i]->projectlabel;
+ $projectstatic->public = $lines[$i]->public;
+ $projectstatic->thirdparty_name = $lines[$i]->thirdparty_name;
+
+ $taskstatic->id = $lines[$i]->id;
+ $taskstatic->ref = ($lines[$i]->ref ? $lines[$i]->ref : $lines[$i]->id);
+ $taskstatic->label = $lines[$i]->label;
+ $taskstatic->date_start = $lines[$i]->date_start;
+ $taskstatic->date_end = $lines[$i]->date_end;
+
+ $thirdpartystatic->id = $lines[$i]->thirdparty_id;
+ $thirdpartystatic->name = $lines[$i]->thirdparty_name;
+ $thirdpartystatic->email = $lines[$i]->thirdparty_email;
+
+ if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id))
+ {
+ print ' '."\n";
+ print '';
+ print $projectstatic->getNomUrl(1, '', 0, ''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
+ if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1);
+ if ($projectstatic->title)
+ {
+ print ' - ';
+ print ''.$projectstatic->title.' ';
+ }
+ print ' ';
+ print ' ';
+ }
+
+ if ($oldprojectforbreak != -1) $oldprojectforbreak = $projectstatic->id;
+ print ''."\n";
+
+ // User
+ /*
+ print '';
+ print $fuser->getNomUrl(1, 'withproject', 'time');
+ print ' ';
+ */
+
+ // Project
+ /*print '';
+ if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]);
+ print " ";*/
+
+ // Thirdparty
+ /*print '';
+ if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project');
+ print ' ';*/
+
+ // Ref
+ print '';
+ print '';
+ for ($k = 0; $k < $level; $k++) print " ";
+ print $taskstatic->getNomUrl(1, 'withproject', 'time');
+ // Label task
+ print ' ';
+ for ($k = 0; $k < $level; $k++) print " ";
+ //print $taskstatic->getNomUrl(0, 'withproject', 'time');
+ print $taskstatic->label;
+ //print " ";
+ //for ($k = 0 ; $k < $level ; $k++) print " ";
+ //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
+ print " \n";
+
+ // Planned Workload
+ print '';
+ if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
+ else print '--:--';
+ print ' ';
+
+ // Progress declared %
+ print '';
+ print $formother->select_percent($lines[$i]->progress, $lines[$i]->id.'progress');
+ print ' ';
+
+ // Time spent by everybody
+ print '';
+ // $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
+ if ($lines[$i]->duration)
+ {
+ print '';
+ print convertSecondToTime($lines[$i]->duration, 'allhourmin');
+ print ' ';
+ }
+ else print '--:--';
+ print " \n";
+
+ // Time spent by user
+ print '';
+ $tmptimespent = $taskstatic->getSummaryOfTimeSpent($fuser->id);
+ if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'], 'allhourmin');
+ else print '--:--';
+ print " \n";
+
+ $disabledproject = 1; $disabledtask = 1;
+ //print "x".$lines[$i]->fk_project;
+ //var_dump($lines[$i]);
+ //var_dump($projectsrole[$lines[$i]->fk_project]);
+ // If at least one role for project
+ if ($lines[$i]->public || !empty($projectsrole[$lines[$i]->fk_project]) || $user->rights->projet->all->creer)
+ {
+ $disabledproject = 0;
+ $disabledtask = 0;
+ }
+ // If $restricteditformytask is on and I have no role on task, i disable edit
+ if ($restricteditformytask && empty($tasksrole[$lines[$i]->id]))
+ {
+ $disabledtask = 1;
+ }
+
+ //var_dump($projectstatic->weekWorkLoadPerTask);
+ //TODO
+ // Fields to show current time
+ $tableCell = ''; $modeinput = 'hours';
+ $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow));
+ $TFirstDay[reset($TWeek)] = 1;
+ foreach ($TFirstDay as &$fday) {
+ $fday--;
+ }
+ foreach ($TWeek as $weekNb)
+ {
+ $weekWorkLoad = $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id];
+ $totalforeachweek[$weekNb] += $weekWorkLoad;
+
+ $alreadyspent = '';
+ if ($weekWorkLoad > 0) $alreadyspent = convertSecondToTime($weekWorkLoad, 'allhourmin');
+ $alttitle = $langs->trans("AddHereTimeSpentForWeek", $weekNb);
+
+
+ $tableCell = '';
+ $placeholder = '';
+ if ($alreadyspent)
+ {
+ $tableCell .= ' ';
+ //$placeholder=' placeholder="00:00"';
+ //$tableCell.='+';
+ }
+
+ $tableCell .= ' ';
+ $tableCell .= ' ';
+ print $tableCell;
+ }
+
+ // Warning
+ print '';
+ if ((!$lines[$i]->public) && $disabledproject) print $form->textwithpicto('', $langs->trans("UserIsNotContactOfProject"));
+ elseif ($disabledtask)
+ {
+ $titleassigntask = $langs->trans("AssignTaskToMe");
+ if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...');
+
+ print $form->textwithpicto('', $langs->trans("TaskIsNotAssignedToUser", $titleassigntask));
+ }
+ print ' ';
+
+ print " \n";
+ }
+
+ // Call to show task with a lower level (task under the current task)
+ $inc++;
+ $level++;
+ if ($lines[$i]->id > 0)
+ {
+ //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
+ //var_dump($totalforeachday);
+ $ret = projectLinesPerMonth($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $TWeek);
+ //var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
+ //var_dump($ret);
+ foreach ($ret as $key => $val)
+ {
+ $totalforeachweek[$key] += $val;
+ }
+ //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level.' + subtasks');
+ //var_dump($totalforeachday);
+ }
+ $level--;
+ }
+ else
+ {
+ //$level--;
+ }
+ }
+
+ return $totalforeachweek;
+}
+
/**
* Search in task lines with a particular parent if there is a task for a particular user (in taskrole)
@@ -1757,9 +2030,22 @@ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole)
function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array())
{
global $langs, $conf, $user, $bc;
+ global $theme_datacolor;
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ $listofstatus = array_keys($listofoppstatus);
+ $statusOppList = array();
+ $themeColorId = 0;
+ foreach ($listofstatus as $oppStatus) {
+ $oppStatusCode = dol_getIdFromCode($db, $oppStatus, 'c_lead_status', 'rowid', 'code');
+ if ($oppStatusCode) {
+ $statusOppList[$oppStatus]['code'] = $oppStatusCode;
+ $statusOppList[$oppStatus]['color'] = isset($theme_datacolor[$themeColorId]) ? implode(', ', $theme_datacolor[$themeColorId]) : '';
+ }
+ $themeColorId++;
+ }
+
$projectstatic = new Project($db);
$thirdpartystatic = new Societe($db);
@@ -1836,14 +2122,14 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
if (empty($arrayidofprojects)) $arrayidofprojects[0] = -1;
// Get list of project with calculation on tasks
- $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,";
+ $sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_percent, p.opp_amount,";
$sql2 .= " p.dateo, p.datee,";
$sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
$sql2 .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
$sql2 .= " WHERE p.rowid IN (".join(',', $arrayidofprojects).")";
- $sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount, p.dateo, p.datee";
+ $sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, s.nom, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_percent, p.opp_amount, p.dateo, p.datee";
$sql2 .= " ORDER BY p.title, p.ref";
$resql = $db->query($sql2);
@@ -1861,16 +2147,17 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
+ if (!in_array('prospectionstatus', $hiddenfields)) print_liste_field_titre("OpportunityStatus", "", "", "", "", '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder);
- print_liste_field_titre("OpportunityStatus", "", "", "", "", 'align="right"', $sortfield, $sortorder);
+ print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder);
}
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder);
- if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", 'align="right"', $sortfield, $sortorder);
- if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", 'align="right"', $sortfield, $sortorder);
+ if (!in_array('plannedworkload', $hiddenfields)) print_liste_field_titre("PlannedWorkload", "", "", "", "", '', $sortfield, $sortorder, 'right ');
+ if (!in_array('declaredprogress', $hiddenfields)) print_liste_field_titre("ProgressDeclared", "", "", "", "", '', $sortfield, $sortorder, 'right ');
}
- print_liste_field_titre("Status", "", "", "", "", 'align="right"', $sortfield, $sortorder);
+ if (!in_array('projectstatus', $hiddenfields)) print_liste_field_titre("Status", "", "", "", "", '', $sortfield, $sortorder, 'right ');
print "\n";
$total_plannedworkload = 0;
@@ -1893,8 +2180,8 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
$projectstatic->datee = $db->jdate($objp->datee);
$projectstatic->dateo = $db->jdate($objp->dateo);
-
print '';
+
print '';
print $projectstatic->getNomUrl(1);
if (!in_array('projectlabel', $hiddenfields)) print ' '.dol_trunc($objp->title, 24);
@@ -1908,16 +2195,47 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
print $thirdpartystatic->getNomUrl(1);
}
print ' ';
+
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
+ if (!in_array('prospectionstatus', $hiddenfields)) {
+ print '';
+ // Because color of prospection status has no meaning yet, it is used if hidden constant is set
+ if (empty($conf->global->USE_COLOR_FOR_PROSPECTION_STATUS)) {
+ if ($langs->trans("OppStatus".$oppStatusCode) != "OppStatus".$oppStatusCode) {
+ print $langs->trans("OppStatus".$oppStatusCode);
+ }
+ } else {
+ if (isset($statusOppList[$objp->opp_status])) {
+ $oppStatusCode = $statusOppList[$objp->opp_status]['code'];
+ $oppStatusColor = $statusOppList[$objp->opp_status]['color'];
+ } else {
+ $oppStatusCode = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
+ $oppStatusColor = '';
+ }
+ if ($oppStatusCode) {
+ if (!empty($oppStatusColor)) {
+ print ' ';
+ } else {
+ print ''.$oppStatusCode.' ';
+ }
+ }
+ }
+ print ' ';
+ }
+
print '';
if ($objp->opp_amount) print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
print ' ';
print '';
- $code = dol_getIdFromCode($db, $objp->opp_status, 'c_lead_status', 'rowid', 'code');
- if ($code) print $langs->trans("OppStatus".$code);
+ if ($objp->opp_percent && $objp->opp_amount) {
+ $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100;
+ print price($opp_weighted_amount, 0, '', 1, -1, -1, $conf->currency);
+ $ponderated_opp_amount += price2num($opp_weighted_amount);
+ }
print ' ';
}
+
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
print ''.$objp->nb.' ';
@@ -1939,12 +2257,16 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
}
}
- print ''.$projectstatic->getLibStatut(3).' ';
+ if (!in_array('projectstatus', $hiddenfields)) {
+ print '';
+ print $projectstatic->getLibStatut(3);
+ print ' ';
+ }
+
print " \n";
$total_task = $total_task + $objp->nb;
$total_opp_amount = $total_opp_amount + $objp->opp_amount;
- $ponderated_opp_amount = $ponderated_opp_amount + price2num($listofoppstatus[$objp->opp_status] * $objp->opp_amount / 100);
}
$i++;
@@ -1954,6 +2276,9 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
print ''.$langs->trans("Total")." ";
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
+ if (!in_array('prospectionstatus', $hiddenfields)) {
+ print ' ';
+ }
print ''.price($total_opp_amount, 0, '', 1, -1, -1, $conf->currency).' ';
print ''.$form->textwithpicto(price($ponderated_opp_amount, 0, '', 1, -1, -1, $conf->currency), $langs->trans("OpportunityPonderatedAmountDesc"), 1).' ';
}
@@ -1963,7 +2288,9 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
if (!in_array('plannedworkload', $hiddenfields)) print ''.($total_plannedworkload ?convertSecondToTime($total_plannedworkload) : '').' ';
if (!in_array('declaredprogress', $hiddenfields)) print ''.($total_plannedworkload ?round(100 * $total_declaredprogressworkload / $total_plannedworkload, 0).'%' : '').' ';
}
- print ' ';
+ if (!in_array('projectstatus', $hiddenfields)) {
+ print ' ';
+ }
print '';
$db->free($resql);
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index 5a7b8342bd6..a0ac6ecfae1 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -168,10 +168,10 @@ function dol_verifyHash($chain, $hash, $type = '0')
* If GETPOST('action','aZ09') defined, we also check write and delete permission.
*
* @param User $user User to check
- * @param string $features Features to check (it must be module name. Examples: 'societe', 'contact', 'produit&service', 'produit|service', ...)
+ * @param string $features Features to check (it must be module $object->element. Examples: 'societe', 'contact', 'produit&service', 'produit|service', ...)
* @param int $objectid Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
* @param string $tableandshare 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional).
- * @param string $feature2 Feature to check, second level of permission (optional). Can be a 'or' check with 'level1|level2'.
+ * @param string $feature2 Feature to check, second level of permission (optional). Can be a 'or' check with 'sublevela|sublevelb'.
* @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
* @param int $isdraft 1=The object with id=$objectid is a draft
@@ -188,6 +188,11 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
//print ", dbtablename=".$dbtablename.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select;
//print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)." ";
+ if ($features == 'facturerec') $features = 'facture';
+ if ($features == 'mo') $features = 'mrp';
+ if ($features == 'member') $features = 'adherent';
+ if ($features == 'subscription') { $features = 'adherent'; $feature2 = 'cotisation'; };
+
// Get more permissions checks from hooks
$parameters = array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select);
$reshook = $hookmanager->executeHooks('restrictedArea', $parameters);
@@ -311,6 +316,9 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
{
foreach ($feature2 as $subfeature)
{
+ if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->creer) continue; // User can edit its own card
+ if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->password) continue; // User can edit its own password
+
if (empty($user->rights->$feature->$subfeature->creer)
&& empty($user->rights->$feature->$subfeature->write)
&& empty($user->rights->$feature->$subfeature->create)) {
diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php
index 26e97499482..c943220a5ac 100644
--- a/htdocs/core/lib/security2.lib.php
+++ b/htdocs/core/lib/security2.lib.php
@@ -34,9 +34,9 @@
*/
function dol_getwebuser($mode)
{
- $t='?';
- if ($mode=='user') $t=getenv('APACHE_RUN_USER'); // $_ENV['APACHE_RUN_USER'] is empty
- if ($mode=='group') $t=getenv('APACHE_RUN_GROUP');
+ $t = '?';
+ if ($mode == 'user') $t = getenv('APACHE_RUN_USER'); // $_ENV['APACHE_RUN_USER'] is empty
+ if ($mode == 'group') $t = getenv('APACHE_RUN_GROUP');
return $t;
}
@@ -52,11 +52,11 @@ function dol_getwebuser($mode)
*/
function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode, $context = '')
{
- global $conf,$langs;
+ global $conf, $langs;
//global $dolauthmode; // To return authentication finally used
// Check parameters
- if ($entitytotest == '') $entitytotest=1;
+ if ($entitytotest == '') $entitytotest = 1;
dol_syslog("checkLoginPassEntity usertotest=".$usertotest." entitytotest=".$entitytotest." authmode=".join(',', $authmode));
$login = '';
@@ -64,52 +64,52 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth
// Validation of login/pass/entity with standard modules
if (empty($login))
{
- $test=true;
- foreach($authmode as $mode)
+ $test = true;
+ foreach ($authmode as $mode)
{
- if ($test && $mode && ! $login)
+ if ($test && $mode && !$login)
{
// Validation of login/pass/entity for mode $mode
- $mode=trim($mode);
- $authfile='functions_'.$mode.'.php';
- $fullauthfile='';
+ $mode = trim($mode);
+ $authfile = 'functions_'.$mode.'.php';
+ $fullauthfile = '';
- $dirlogin=array_merge(array("/core/login"), (array) $conf->modules_parts['login']);
- foreach($dirlogin as $reldir)
+ $dirlogin = array_merge(array("/core/login"), (array) $conf->modules_parts['login']);
+ foreach ($dirlogin as $reldir)
{
- $dir=dol_buildpath($reldir, 0);
- $newdir=dol_osencode($dir);
+ $dir = dol_buildpath($reldir, 0);
+ $newdir = dol_osencode($dir);
// Check if file found (do not use dol_is_file to avoid loading files.lib.php)
- $tmpnewauthfile = $newdir.(preg_match('/\/$/', $newdir)?'':'/').$authfile;
- if (is_file($tmpnewauthfile)) $fullauthfile=$tmpnewauthfile;
+ $tmpnewauthfile = $newdir.(preg_match('/\/$/', $newdir) ? '' : '/').$authfile;
+ if (is_file($tmpnewauthfile)) $fullauthfile = $tmpnewauthfile;
}
- $result=false;
- if ($fullauthfile) $result=include_once $fullauthfile;
+ $result = false;
+ if ($fullauthfile) $result = include_once $fullauthfile;
if ($fullauthfile && $result)
{
// Call function to check user/password
- $function='check_user_password_'.$mode;
- $login=call_user_func($function, $usertotest, $passwordtotest, $entitytotest, $context);
+ $function = 'check_user_password_'.$mode;
+ $login = call_user_func($function, $usertotest, $passwordtotest, $entitytotest, $context);
if ($login) // Login is successfull
{
- $test=false; // To stop once at first login success
- $conf->authmode=$mode; // This properties is defined only when logged to say what mode was successfully used
- $dol_tz=GETPOST('tz');
- $dol_dst=GETPOST('dst');
- $dol_screenwidth=GETPOST('screenwidth');
- $dol_screenheight=GETPOST('screenheight');
+ $test = false; // To stop once at first login success
+ $conf->authmode = $mode; // This properties is defined only when logged to say what mode was successfully used
+ $dol_tz = GETPOST('tz');
+ $dol_dst = GETPOST('dst');
+ $dol_screenwidth = GETPOST('screenwidth');
+ $dol_screenheight = GETPOST('screenheight');
}
}
else
{
- dol_syslog("Authentification ko - failed to load file '".$authfile."'", LOG_ERR);
+ dol_syslog("Authentication KO - failed to load file '".$authfile."'", LOG_ERR);
sleep(1);
// Load translation files required by the page
$langs->loadLangs(array('other', 'main', 'errors'));
- $_SESSION["dol_loginmesg"]=$langs->trans("ErrorFailedToLoadLoginFileForMode", $mode);
+ $_SESSION["dol_loginmesg"] = $langs->trans("ErrorFailedToLoadLoginFileForMode", $mode);
}
}
}
@@ -119,7 +119,7 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth
}
-if (! function_exists('dol_loginfunction'))
+if (!function_exists('dol_loginfunction'))
{
/**
* Show Dolibarr default login page.
@@ -135,22 +135,22 @@ if (! function_exists('dol_loginfunction'))
global $dolibarr_main_demo, $db;
global $hookmanager;
- $langs->loadLangs(array("main","other","help","admin"));
+ $langs->loadLangs(array("main", "other", "help", "admin"));
// Instantiate hooks of thirdparty module only if not already define
$hookmanager->initHooks(array('mainloginpage'));
- $main_authentication=$conf->file->main_authentication;
+ $main_authentication = $conf->file->main_authentication;
- $session_name=session_name(); // Get current session name
+ $session_name = session_name(); // Get current session name
$dol_url_root = DOL_URL_ROOT;
// Title
- $appli=constant('DOL_APPLICATION_TITLE');
- $title=$appli.' '.constant('DOL_VERSION');
- if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE;
- $titletruedolibarrversion=constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version
+ $appli = constant('DOL_APPLICATION_TITLE');
+ $title = $appli.' '.constant('DOL_VERSION');
+ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = $conf->global->MAIN_APPLICATION_TITLE;
+ $titletruedolibarrversion = constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version
// Note: $conf->css looks like '/theme/eldy/style.css.php'
/*
@@ -171,13 +171,13 @@ if (! function_exists('dol_loginfunction'))
*/
// Select templates dir
- if (! empty($conf->modules_parts['tpl'])) // Using this feature slow down application
+ if (!empty($conf->modules_parts['tpl'])) // Using this feature slow down application
{
- $dirtpls=array_merge($conf->modules_parts['tpl'], array('/core/tpl/'));
- foreach($dirtpls as $reldir)
+ $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl/'));
+ foreach ($dirtpls as $reldir)
{
- $tmp=dol_buildpath($reldir.'login.tpl.php');
- if (file_exists($tmp)) { $template_dir=preg_replace('/login\.tpl\.php$/', '', $tmp); break; }
+ $tmp = dol_buildpath($reldir.'login.tpl.php');
+ if (file_exists($tmp)) { $template_dir = preg_replace('/login\.tpl\.php$/', '', $tmp); break; }
}
}
else
@@ -186,116 +186,116 @@ if (! function_exists('dol_loginfunction'))
}
// Set cookie for timeout management
- $prefix=dol_getprefix('');
- $sessiontimeout='DOLSESSTIMEOUT_'.$prefix;
- if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, false, true);
+ $prefix = dol_getprefix('');
+ $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix;
+ if (!empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, false, true);
- if (GETPOST('urlfrom', 'alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom', 'alpha');
+ if (GETPOST('urlfrom', 'alpha')) $_SESSION["urlfrom"] = GETPOST('urlfrom', 'alpha');
else unset($_SESSION["urlfrom"]);
- if (! GETPOST("username", 'alpha')) $focus_element='username';
- else $focus_element='password';
+ if (!GETPOST("username", 'alpha')) $focus_element = 'username';
+ else $focus_element = 'password';
- $demologin='';
- $demopassword='';
- if (! empty($dolibarr_main_demo))
+ $demologin = '';
+ $demopassword = '';
+ if (!empty($dolibarr_main_demo))
{
- $tab=explode(',', $dolibarr_main_demo);
- $demologin=$tab[0];
- $demopassword=$tab[1];
+ $tab = explode(',', $dolibarr_main_demo);
+ $demologin = $tab[0];
+ $demopassword = $tab[1];
}
// Execute hook getLoginPageOptions (for table)
- $parameters=array('entity' => GETPOST('entity', 'int'));
- $reshook = $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
+ $parameters = array('entity' => GETPOST('entity', 'int'));
+ $reshook = $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
$morelogincontent = $hookmanager->resPrint;
// Execute hook getLoginPageExtraOptions (eg for js)
- $parameters=array('entity' => GETPOST('entity', 'int'));
- $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
+ $parameters = array('entity' => GETPOST('entity', 'int'));
+ $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
$moreloginextracontent = $hookmanager->resPrint;
// Login
- $login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin));
+ $login = (!empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin));
$password = $demopassword;
// Show logo (search in order: small company logo, large company logo, theme logo, common logo)
- $width=0;
- $urllogo=DOL_URL_ROOT.'/theme/login_logo.png';
+ $width = 0;
+ $urllogo=DOL_URL_ROOT.'/theme/common/login_logo.png';
- if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
+ if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
{
- $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
+ $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
}
- elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
+ elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
{
- $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo);
- $width=128;
+ $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo);
+ $width = 128;
}
elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png'))
{
- $urllogo=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png';
+ $urllogo = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png';
}
elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png'))
{
- $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png';
+ $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.png';
}
// Security graphical code
- $captcha=0;
- $captcha_refresh='';
- if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA))
+ $captcha = 0;
+ $captcha_refresh = '';
+ if (function_exists("imagecreatefrompng") && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA))
{
- $captcha=1;
- $captcha_refresh=img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"');
+ $captcha = 1;
+ $captcha_refresh = img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"');
}
// Extra link
- $forgetpasslink=0;
- $helpcenterlink=0;
+ $forgetpasslink = 0;
+ $helpcenterlink = 0;
if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK))
{
if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK))
{
- $forgetpasslink=1;
+ $forgetpasslink = 1;
}
if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK))
{
- $helpcenterlink=1;
+ $helpcenterlink = 1;
}
}
// Home message
- $main_home='';
- if (! empty($conf->global->MAIN_HOME))
+ $main_home = '';
+ if (!empty($conf->global->MAIN_HOME))
{
- $substitutionarray=getCommonSubstitutionArray($langs);
+ $substitutionarray = getCommonSubstitutionArray($langs);
complete_substitutions_array($substitutionarray, $langs);
$texttoshow = make_substitutions($conf->global->MAIN_HOME, $substitutionarray, $langs);
- $main_home=dol_htmlcleanlastbr($texttoshow);
+ $main_home = dol_htmlcleanlastbr($texttoshow);
}
// Google AD
- $main_google_ad_client = ((! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))?1:0);
+ $main_google_ad_client = ((!empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT)) ? 1 : 0);
// Set jquery theme
- $dol_loginmesg = (! empty($_SESSION["dol_loginmesg"])?$_SESSION["dol_loginmesg"]:'');
+ $dol_loginmesg = (!empty($_SESSION["dol_loginmesg"]) ? $_SESSION["dol_loginmesg"] : '');
$favicon = DOL_URL_ROOT.'/theme/dolibarr_logo_256x256.png';
- if (! empty($mysoc->logo_squarred_mini)) $favicon = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini);
- if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL;
+ if (!empty($mysoc->logo_squarred_mini)) $favicon = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini);
+ if (!empty($conf->global->MAIN_FAVICON_URL)) $favicon = $conf->global->MAIN_FAVICON_URL;
$jquerytheme = 'base';
- if (! empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME;
+ if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME;
// Set dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, dol_no_mouse_hover
- $dol_hide_topmenu=GETPOST('dol_hide_topmenu', 'int');
- $dol_hide_leftmenu=GETPOST('dol_hide_leftmenu', 'int');
- $dol_optimize_smallscreen=GETPOST('dol_optimize_smallscreen', 'int');
- $dol_no_mouse_hover=GETPOST('dol_no_mouse_hover', 'int');
- $dol_use_jmobile=GETPOST('dol_use_jmobile', 'int');
+ $dol_hide_topmenu = GETPOST('dol_hide_topmenu', 'int');
+ $dol_hide_leftmenu = GETPOST('dol_hide_leftmenu', 'int');
+ $dol_optimize_smallscreen = GETPOST('dol_optimize_smallscreen', 'int');
+ $dol_no_mouse_hover = GETPOST('dol_no_mouse_hover', 'int');
+ $dol_use_jmobile = GETPOST('dol_use_jmobile', 'int');
// Include login page template
include $template_dir.'login.tpl.php';
@@ -316,20 +316,20 @@ if (! function_exists('dol_loginfunction'))
function makesalt($type = CRYPT_SALT_LENGTH)
{
dol_syslog("makesalt type=".$type);
- switch($type)
+ switch ($type)
{
case 12: // 8 + 4
- $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break;
+ $saltlen = 8; $saltprefix = '$1$'; $saltsuffix = '$'; break;
case 8: // 8 (Pour compatibilite, ne devrait pas etre utilise)
- $saltlen=8; $saltprefix='$1$'; $saltsuffix='$'; break;
+ $saltlen = 8; $saltprefix = '$1$'; $saltsuffix = '$'; break;
case 2: // 2
default: // by default, fall back on Standard DES (should work everywhere)
- $saltlen=2; $saltprefix=''; $saltsuffix=''; break;
+ $saltlen = 2; $saltprefix = ''; $saltsuffix = ''; break;
}
- $salt='';
- while(dol_strlen($salt) < $saltlen) $salt.=chr(mt_rand(64, 126));
+ $salt = '';
+ while (dol_strlen($salt) < $saltlen) $salt .= chr(mt_rand(64, 126));
- $result=$saltprefix.$salt.$saltsuffix;
+ $result = $saltprefix.$salt.$saltsuffix;
dol_syslog("makesalt return=".$result);
return $result;
}
@@ -344,35 +344,35 @@ function encodedecode_dbpassconf($level = 0)
{
dol_syslog("encodedecode_dbpassconf level=".$level, LOG_DEBUG);
$config = '';
- $passwd='';
- $passwd_crypted='';
+ $passwd = '';
+ $passwd_crypted = '';
if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php', 'r'))
{
- while(!feof($fp))
+ while (!feof($fp))
{
$buffer = fgets($fp, 4096);
- $lineofpass=0;
+ $lineofpass = 0;
if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) // Old way to save crypted value
{
- $val = trim($reg[1]); // This also remove CR/LF
- $val=preg_replace('/^["\']/', '', $val);
- $val=preg_replace('/["\'][\s;]*$/', '', $val);
- if (! empty($val))
+ $val = trim($reg[1]); // This also remove CR/LF
+ $val = preg_replace('/^["\']/', '', $val);
+ $val = preg_replace('/["\'][\s;]*$/', '', $val);
+ if (!empty($val))
{
$passwd_crypted = $val;
$val = dol_decode($val);
$passwd = $val;
- $lineofpass=1;
+ $lineofpass = 1;
}
}
elseif (preg_match('/^[^#]*dolibarr_main_db_pass[\s]*=[\s]*(.*)/i', $buffer, $reg))
{
- $val = trim($reg[1]); // This also remove CR/LF
- $val=preg_replace('/^["\']/', '', $val);
- $val=preg_replace('/["\'][\s;]*$/', '', $val);
+ $val = trim($reg[1]); // This also remove CR/LF
+ $val = preg_replace('/^["\']/', '', $val);
+ $val = preg_replace('/["\'][\s;]*$/', '', $val);
if (preg_match('/crypted:/i', $buffer))
{
$val = preg_replace('/crypted:/i', '', $val);
@@ -386,7 +386,7 @@ function encodedecode_dbpassconf($level = 0)
$val = dol_encode($val);
$passwd_crypted = $val;
}
- $lineofpass=1;
+ $lineofpass = 1;
}
// Output line
@@ -413,7 +413,7 @@ function encodedecode_dbpassconf($level = 0)
fclose($fp);
// Write new conf file
- $file=DOL_DOCUMENT_ROOT.'/conf/conf.php';
+ $file = DOL_DOCUMENT_ROOT.'/conf/conf.php';
if ($fp = @fopen($file, 'w'))
{
fputs($fp, $config);
@@ -451,17 +451,17 @@ function encodedecode_dbpassconf($level = 0)
*/
function getRandomPassword($generic = false, $replaceambiguouschars = null, $length = 32)
{
- global $db,$conf,$langs,$user;
+ global $db, $conf, $langs, $user;
- $generated_password='';
+ $generated_password = '';
if ($generic)
{
$lowercase = "qwertyuiopasdfghjklzxcvbnm";
$uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP";
$numbers = "1234567890";
$randomCode = "";
- $nbofchar = round($length/3);
- $nbofcharlast = ($length - 2*$nbofchar);
+ $nbofchar = round($length / 3);
+ $nbofcharlast = ($length - 2 * $nbofchar);
//var_dump($nbofchar.'-'.$nbofcharlast);
if (function_exists('random_int')) // Cryptographic random
{
@@ -478,7 +478,7 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
$randomCode .= $numbers{random_int(0, $max)};
}
- $generated_password=str_shuffle($randomCode);
+ $generated_password = str_shuffle($randomCode);
}
else // Old platform, non cryptographic random
{
@@ -495,17 +495,17 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
$randomCode .= $numbers{mt_rand(0, $max)};
}
- $generated_password=str_shuffle($randomCode);
+ $generated_password = str_shuffle($randomCode);
}
}
- elseif (! empty($conf->global->USER_PASSWORD_GENERATED))
+ elseif (!empty($conf->global->USER_PASSWORD_GENERATED))
{
- $nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
- $nomfichier=$nomclass.".class.php";
+ $nomclass = "modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED);
+ $nomfichier = $nomclass.".class.php";
//print DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomclass;
require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier;
- $genhandler=new $nomclass($db, $conf, $langs, $user);
- $generated_password=$genhandler->getNewGeneratedPassword();
+ $genhandler = new $nomclass($db, $conf, $langs, $user);
+ $generated_password = $genhandler->getNewGeneratedPassword();
unset($genhandler);
}
@@ -516,11 +516,11 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len
$max = strlen($numbers) - 1;
if (function_exists('random_int')) // Cryptographic random
{
- $generated_password=str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password);
+ $generated_password = str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password);
}
else
{
- $generated_password=str_replace($replaceambiguouschars, $numbers{mt_rand(0, $max)}, $generated_password);
+ $generated_password = str_replace($replaceambiguouschars, $numbers{mt_rand(0, $max)}, $generated_password);
}
}
diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php
index 79446183685..7f8de19e2e5 100644
--- a/htdocs/core/lib/sendings.lib.php
+++ b/htdocs/core/lib/sendings.lib.php
@@ -119,7 +119,7 @@ function shipping_prepare_head($object)
*/
function delivery_prepare_head($object)
{
- global $langs, $conf, $user;
+ global $langs, $db, $conf, $user;
// Load translation files required by the page
$langs->loadLangs(array("sendings","deliveries"));
@@ -140,29 +140,56 @@ function delivery_prepare_head($object)
$head[$h][2] = 'delivery';
$h++;
- $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->origin_id;
+ // Show more tabs from modules
+ // Entries must be declared in modules descriptor with line
+ // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
+ // $this->tabs = array('entity:-tabname); to remove a tab
+ // complete_head_from_modules use $object->id for this link so we temporary change it
+
+ $savObjectId = $object->id;
+
+ // Get parent object
+ $tmpobject = null;
+ if ($object->origin) {
+ $tmpobject = new Expedition($db);
+ $tmpobject->fetch($object->origin_id);
+ } else {
+ $tmpobject = $object;
+ }
+
+ $head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$tmpobject->id;
$head[$h][1] = $langs->trans("ContactsAddresses");
$head[$h][2] = 'contact';
$h++;
- $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$object->origin_id;
+
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
+ $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($tmpobject->ref);
+ $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
+ $nbLinks=Link::count($db, $tmpobject->element, $tmpobject->id);
+ $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$tmpobject->id;
+ $head[$h][1] = $langs->trans('Documents');
+ if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).' ';
+ $head[$h][2] = 'documents';
+ $h++;
+
+ $nbNote = 0;
+ if (!empty($tmpobject->note_private)) $nbNote++;
+ if (!empty($tmpobject->note_public)) $nbNote++;
+ $head[$h][0] = DOL_URL_ROOT."/expedition/note.php?id=".$tmpobject->id;
$head[$h][1] = $langs->trans("Notes");
+ if ($nbNote > 0) $head[$h][1].= ''.$nbNote.' ';
$head[$h][2] = 'note';
$h++;
- // Show more tabs from modules
- // Entries must be declared in modules descriptor with line
- // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
- // $this->tabs = array('entity:-tabname); to remove a tab
- // complete_head_from_modules use $object->id for this link so we temporary change it
- $tmpObjectId = $object->id;
- $object->id = $object->origin_id;
+ $object->id = $tmpobject->id;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery');
complete_head_from_modules($conf, $langs, $object, $head, $h, 'delivery', 'remove');
- $object->id = $tmpObjectId;
+ $object->id = $savObjectId;
return $head;
}
diff --git a/htdocs/core/lib/takepos.lib.php b/htdocs/core/lib/takepos.lib.php
index dc86853859e..65ad4c091a0 100644
--- a/htdocs/core/lib/takepos.lib.php
+++ b/htdocs/core/lib/takepos.lib.php
@@ -38,13 +38,10 @@ function takepos_prepare_head()
$head[$h][2] = 'setup';
$h++;
- if ($conf->global->TAKEPOS_CUSTOM_RECEIPT)
- {
- $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/receipt.php';
- $head[$h][1] = $langs->trans("Receipt");
- $head[$h][2] = 'receipt';
- $h++;
- }
+ $head[$h][0] = DOL_URL_ROOT.'/takepos/admin/receipt.php';
+ $head[$h][1] = $langs->trans("Receipt");
+ $head[$h][2] = 'receipt';
+ $h++;
$numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS);
for ($i = 1; $i <= $numterminals; $i++)
diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php
index fd2d56c946b..fe7fb4ba5a7 100644
--- a/htdocs/core/lib/ticket.lib.php
+++ b/htdocs/core/lib/ticket.lib.php
@@ -216,30 +216,51 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $
print '';
+ // Define urllogo
+ $width = 0;
if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO) || ! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) {
- print '';
// Print logo
if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO))
{
- $urllogo = DOL_URL_ROOT . '/theme/login_logo.png';
+ $urllogo = DOL_URL_ROOT . '/theme/common/login_logo.png';
if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small);
+ $width = 150;
} elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
$urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo);
- $width = 128;
+ $width = 150;
} elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) {
$urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png';
}
- print ' ';
}
- if (! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC))
- {
- print '' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . ' ';
- }
- print ' ';
}
+ print '';
+ // Output html code for logo
+ if ($urllogo || ! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC))
+ {
+ print '
';
+ print '
';
+ if ($urllogo) {
+ print '
';
+ print ' ';
+ print ' ';
+ }
+ if (! empty($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC)) {
+ print '
' . ($conf->global->TICKET_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . ' ';
+ }
+ print '
';
+ if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
+ print '
';
+ }
+ print '
';
+ }
+
+ print '
';
+
print '';
}
diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php
index 709832118c2..a234f4ed5e0 100644
--- a/htdocs/core/lib/usergroups.lib.php
+++ b/htdocs/core/lib/usergroups.lib.php
@@ -448,7 +448,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
print '
'.$langs->trans("EnableShowLogo").' ';
if ($edit)
{
- print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1);
+ print ajax_constantonoff('MAIN_SHOW_LOGO', array(), null, 0, 0, 1);
+ //print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1);
}
else
{
@@ -494,7 +495,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
print ' ';
if ($edit)
{
- print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1);
+ print ajax_constantonoff('THEME_TOPMENU_DISABLE_IMAGE', array(), null, 0, 0, 1);
+ //print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1);
}
else
{
diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index f97c6efed1c..05e70f7912d 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -239,15 +239,15 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
{
global $website;
+ $content = str_replace(' global->MAIN_UMASK));
}
+ // Save also alias into language subdirectory if we have to
+ if ($objectpage->lang && in_array($objectpage->lang, explode(',', $object->otherlang))) {
+ $dirname = dirname($filealias);
+ $filename = basename($filealias);
+ $filealias = $dirname.'/'.$objectpage->lang.'/'.$filename;
+
+ $aliascontent = 'id.'.tpl.php\'; ';
+ $aliascontent .= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
+ $aliascontent .= '?>'."\n";
+ $result = file_put_contents($filealias, $aliascontent);
+ if (!empty($conf->global->MAIN_UMASK)) {
+ @chmod($filealias, octdec($conf->global->MAIN_UMASK));
+ }
+ }
+
return ($result ?true:false);
}
@@ -85,6 +104,7 @@ function dolSavePageAlias($filealias, $object, $objectpage)
* @param Website $object Object website
* @param WebsitePage $objectpage Object websitepage
* @return boolean True if OK
+ * @see dolSavePageAlias()
*/
function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
{
@@ -101,7 +121,10 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
$tplcontent = '';
$tplcontent .= "isMultiLang()) {
// Add myself
- $tplcontent .= ' '."\n";
+ $tplcontent .= ' '."\n";
// Add page "translation of"
$translationof = $objectpage->fk_page;
if ($translationof) {
@@ -135,7 +158,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
$tmpshortlangcode = '';
if ($tmppage->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $tmppage->lang); // en_US or en-US -> en
if ($tmpshortlangcode != $shortlangcode) {
- $tplcontent .= ' '."\n";
+ $tplcontent .= ' '."\n";
}
}
}
@@ -152,7 +175,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
$tmpshortlangcode = '';
if ($obj->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $obj->lang); // en_US or en-US -> en
if ($tmpshortlangcode != $shortlangcode) {
- $tplcontent .= ' '."\n";
+ $tplcontent .= ' '."\n";
}
}
}
@@ -160,11 +183,11 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
else dol_print_error($db);
}
// Add canonical reference
- $tplcontent .= ' '."\n";
+ $tplcontent .= ' '."\n";
// Add manifest.json on homepage
$tplcontent .= 'use_manifest) { print \' \'."\n"; } ?>'."\n";
$tplcontent .= ''."\n";
- $tplcontent .= ' '."\n";
+ $tplcontent .= ' '."\n";
$tplcontent .= ''."\n";
$tplcontent .= '/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
$tplcontent .= ''."\n";
diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php
index 7e5439fa66a..861c31a0e37 100644
--- a/htdocs/core/login/functions_dolibarr.php
+++ b/htdocs/core/login/functions_dolibarr.php
@@ -110,7 +110,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes
else
{
sleep(2); // Anti brut force protection
- dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."', cryptType=".$cryptType);
+ dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO bad password for '".$usertotest."', cryptType=".$cryptType, LOG_NOTICE);
// Load translation files required by the page
$langs->loadLangs(array('main', 'errors'));
@@ -129,7 +129,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes
$ret = $mc->checkRight($obj->rowid, $entitytotest);
if ($ret < 0)
{
- dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko entity '" . $entitytotest . "' not allowed for user '" . $obj->rowid . "'");
+ dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO entity '" . $entitytotest . "' not allowed for user '" . $obj->rowid . "'", LOG_NOTICE);
$login = ''; // force authentication failure
}
}
@@ -137,7 +137,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes
}
else
{
- dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko user not found for '".$usertotest."'");
+ dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO user not found for '".$usertotest."'", LOG_NOTICE);
sleep(1);
// Load translation files required by the page
@@ -148,7 +148,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes
}
else
{
- dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko db error for '".$usertotest."' error=".$db->lasterror());
+ dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentication KO db error for '".$usertotest."' error=".$db->lasterror(), LOG_ERR);
sleep(1);
$_SESSION["dol_loginmesg"]=$db->lasterror();
}
diff --git a/htdocs/core/login/functions_googleoauth.php b/htdocs/core/login/functions_googleoauth.php
index 2f1fbcf3667..e621f41e562 100644
--- a/htdocs/core/login/functions_googleoauth.php
+++ b/htdocs/core/login/functions_googleoauth.php
@@ -48,7 +48,7 @@ function check_user_password_googleoauth($usertotest, $passwordtotest, $entityto
$login = '';
// Get identity from user and redirect browser to Google OAuth Server
- if (isset($_POST['username']))
+ if (GETPOSTISSET('username'))
{
/*$openid = new SimpleOpenID();
$openid->SetIdentity($_POST['username']);
diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php
index 63a4c6d01e6..81bbfdf5b84 100644
--- a/htdocs/core/login/functions_ldap.php
+++ b/htdocs/core/login/functions_ldap.php
@@ -52,7 +52,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
if (! function_exists("ldap_connect"))
{
- dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP. LDAP functions are disabled on this PHP");
+ dol_syslog("functions_ldap::check_user_password_ldap Authentication KO failed to connect to LDAP. LDAP functions are disabled on this PHP", LOG_ERR);
sleep(1);
// Load translation files required by the page
@@ -202,7 +202,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
$ret=$mc->checkRight($usertmp->id, $entitytotest);
if ($ret < 0)
{
- dol_syslog("functions_ldap::check_user_password_ldap Authentification ko entity '".$entitytotest."' not allowed for user '".$usertmp->id."'");
+ dol_syslog("functions_ldap::check_user_password_ldap Authentication KO entity '".$entitytotest."' not allowed for user '".$usertmp->id."'", LOG_NOTICE);
$login=''; // force authentication failure
}
unset($usertmp);
@@ -210,7 +210,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
}
if ($result == 1)
{
- dol_syslog("functions_ldap::check_user_password_ldap Authentification ko bad user/password for '".$usertotest."'");
+ dol_syslog("functions_ldap::check_user_password_ldap Authentication KO bad user/password for '".$usertotest."'", LOG_NOTICE);
sleep(1);
// Load translation files required by the page
@@ -229,7 +229,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
** 49 - Wrong password
** 53 - Account inactive (manually locked out by administrator)
*/
- dol_syslog("functions_ldap::check_user_password_ldap Authentification ko failed to connect to LDAP for '".$usertotest."'");
+ dol_syslog("functions_ldap::check_user_password_ldap Authentication KO failed to connect to LDAP for '".$usertotest."'", LOG_NOTICE);
if (is_resource($ldap->connection)) // If connection ok but bind ko
{
$ldap->ldapErrorCode = ldap_errno($ldap->connection);
diff --git a/htdocs/core/login/functions_openid.php b/htdocs/core/login/functions_openid.php
index c20b2a32f90..a401dfd7764 100644
--- a/htdocs/core/login/functions_openid.php
+++ b/htdocs/core/login/functions_openid.php
@@ -36,26 +36,26 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/openid.class.php';
*/
function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
{
- global $_POST,$db,$conf,$langs;
+ global $_POST, $db, $conf, $langs;
dol_syslog("functions_openid::check_user_password_openid usertotest=".$usertotest);
- $login='';
+ $login = '';
// Get identity from user and redirect browser to OpenID Server
- if (isset($_POST['username']))
+ if (GETPOSISSET('username'))
{
$openid = new SimpleOpenID();
$openid->SetIdentity($_POST['username']);
$protocol = ($conf->file->main_force_https ? 'https://' : 'http://');
- $openid->SetTrustRoot($protocol . $_SERVER["HTTP_HOST"]);
- $openid->SetRequiredFields(array('email','fullname'));
+ $openid->SetTrustRoot($protocol.$_SERVER["HTTP_HOST"]);
+ $openid->SetRequiredFields(array('email', 'fullname'));
$_SESSION['dol_entity'] = $_POST["entity"];
//$openid->SetOptionalFields(array('dob','gender','postcode','country','language','timezone'));
if ($openid->sendDiscoveryRequestToGetXRDS())
{
- $openid->SetApprovedURL($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]); // Send Response from OpenID server to this script
- $openid->Redirect(); // This will redirect user to OpenID Server
+ $openid->SetApprovedURL($protocol.$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"]); // Send Response from OpenID server to this script
+ $openid->Redirect(); // This will redirect user to OpenID Server
}
else
{
@@ -65,7 +65,7 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
return false;
}
// Perform HTTP Request to OpenID server to validate key
- elseif($_GET['openid_mode'] == 'id_res')
+ elseif ($_GET['openid_mode'] == 'id_res')
{
$openid = new SimpleOpenID();
$openid->SetIdentity($_GET['openid_identity']);
@@ -74,23 +74,23 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
{
// OK HERE KEY IS VALID
- $sql ="SELECT login";
- $sql.=" FROM ".MAIN_DB_PREFIX."user";
- $sql.=" WHERE openid = '".$db->escape($_GET['openid_identity'])."'";
- $sql.=" AND entity IN (0," . ($_SESSION["dol_entity"] ? $_SESSION["dol_entity"] : 1) . ")";
+ $sql = "SELECT login";
+ $sql .= " FROM ".MAIN_DB_PREFIX."user";
+ $sql .= " WHERE openid = '".$db->escape($_GET['openid_identity'])."'";
+ $sql .= " AND entity IN (0,".($_SESSION["dol_entity"] ? $_SESSION["dol_entity"] : 1).")";
dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG);
- $resql=$db->query($sql);
+ $resql = $db->query($sql);
if ($resql)
{
- $obj=$db->fetch_object($resql);
+ $obj = $db->fetch_object($resql);
if ($obj)
{
- $login=$obj->login;
+ $login = $obj->login;
}
}
}
- elseif($openid->IsError() === true)
+ elseif ($openid->IsError() === true)
{
// ON THE WAY, WE GOT SOME ERROR
$error = $openid->GetError();
diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php
index e35f45576d1..390c50aa748 100644
--- a/htdocs/core/menus/standard/auguria.lib.php
+++ b/htdocs/core/menus/standard/auguria.lib.php
@@ -548,7 +548,7 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t
if ($menu_array[$i]['enabled']) // Enabled so visible
{
print ' ';
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index 075ba0efb84..b8740fa60de 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -116,7 +116,7 @@ class pdf_einstein extends ModelePDFCommandes
/**
* Issuer
- * @var Societe object that emits
+ * @var Societe Object that emits
*/
public $emetteur;
@@ -128,7 +128,7 @@ class pdf_einstein extends ModelePDFCommandes
*/
public function __construct($db)
{
- global $conf,$langs,$mysoc;
+ global $conf, $langs, $mysoc;
// Translations
$langs->loadLangs(array("main", "bills", "products"));
@@ -136,72 +136,70 @@ class pdf_einstein extends ModelePDFCommandes
$this->db = $db;
$this->name = "einstein";
$this->description = $langs->trans('PDFEinsteinDescription');
- $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
+ $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
// Dimension page
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
+ $formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+ $this->format = array($this->page_largeur, $this->page_hauteur);
+ $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
+ $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
+ $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
+ $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
- $this->option_logo = 1; // Display logo
- $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
- $this->option_modereg = 1; // Display payment mode
- $this->option_condreg = 1; // Display payment terms
- $this->option_codeproduitservice = 1; // Display product-service code
- $this->option_multilang = 1; // Available in several languages
- $this->option_escompte = 0; // Displays if there has been a discount
- $this->option_credit_note = 0; // Support credit notes
- $this->option_freetext = 1; // Support add of a personalised text
- $this->option_draft_watermark = 1; // Support add of a watermark on drafts
-
- $this->franchise=!$mysoc->tva_assuj;
+ $this->option_logo = 1; // Display logo
+ $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Display payment mode
+ $this->option_condreg = 1; // Display payment terms
+ $this->option_codeproduitservice = 1; // Display product-service code
+ $this->option_multilang = 1; // Available in several languages
+ $this->option_escompte = 0; // Displays if there has been a discount
+ $this->option_credit_note = 0; // Support credit notes
+ $this->option_freetext = 1; // Support add of a personalised text
+ $this->option_draft_watermark = 1; // Support add of a watermark on drafts
// Get source company
- $this->emetteur=$mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined
+ $this->emetteur = $mysoc;
+ if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
// Define position of columns
- $this->posxdesc=$this->marge_gauche+1;
- if($conf->global->PRODUCT_USE_UNITS)
+ $this->posxdesc = $this->marge_gauche + 1;
+ if ($conf->global->PRODUCT_USE_UNITS)
{
- $this->posxtva=101;
- $this->posxup=118;
- $this->posxqty=135;
- $this->posxunit=151;
+ $this->posxtva = 101;
+ $this->posxup = 118;
+ $this->posxqty = 135;
+ $this->posxunit = 151;
}
else
{
- $this->posxtva=110;
- $this->posxup=126;
- $this->posxqty=145;
- $this->posxunit=162;
+ $this->posxtva = 110;
+ $this->posxup = 126;
+ $this->posxqty = 145;
+ $this->posxunit = 162;
}
- $this->posxdiscount=162;
- $this->postotalht=174;
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
- $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
+ $this->posxdiscount = 162;
+ $this->postotalht = 174;
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
+ $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{
- $this->posxpicture-=20;
- $this->posxtva-=20;
- $this->posxup-=20;
- $this->posxqty-=20;
- $this->posxunit-=20;
- $this->posxdiscount-=20;
- $this->postotalht-=20;
+ $this->posxpicture -= 20;
+ $this->posxtva -= 20;
+ $this->posxup -= 20;
+ $this->posxqty -= 20;
+ $this->posxunit -= 20;
+ $this->posxdiscount -= 20;
+ $this->postotalht -= 20;
}
- $this->tva=array();
- $this->localtax1=array();
- $this->localtax2=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
+ $this->tva = array();
+ $this->localtax1 = array();
+ $this->localtax2 = array();
+ $this->atleastoneratenotnull = 0;
+ $this->atleastonediscount = 0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -221,9 +219,9 @@ class pdf_einstein extends ModelePDFCommandes
// phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ if (!is_object($outputlangs)) $outputlangs = $langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@@ -240,20 +238,20 @@ class pdf_einstein extends ModelePDFCommandes
if ($object->specimen)
{
$dir = $conf->commande->multidir_output[$conf->entity];
- $file = $dir . "/SPECIMEN.pdf";
+ $file = $dir."/SPECIMEN.pdf";
}
else
{
$objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->commande->multidir_output[$object->entity] . "/" . $objectref;
- $file = $dir . "/" . $objectref . ".pdf";
+ $dir = $conf->commande->multidir_output[$object->entity]."/".$objectref;
+ $file = $dir."/".$objectref.".pdf";
}
- if (! file_exists($dir))
+ if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
@@ -261,25 +259,25 @@ class pdf_einstein extends ModelePDFCommandes
if (file_exists($dir))
{
// Add pdfgeneration hook
- if (! is_object($hookmanager))
+ if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager=new HookManager($this->db);
+ $hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Create pdf instance
- $pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1, 0);
- $heightforinfotot = 40; // Height reserved to output the info and total part
- $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
+ $heightforinfotot = 40; // Height reserved to output the info and total part
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
if (class_exists('TCPDF'))
{
@@ -288,14 +286,14 @@ class pdf_einstein extends ModelePDFCommandes
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
- if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
$pdf->Open();
- $pagenb=0;
+ $pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
@@ -303,12 +301,12 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
- if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Set $this->atleastonediscount if you have at least one discount
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
if ($object->lines[$i]->remise_percent)
{
@@ -318,27 +316,27 @@ class pdf_einstein extends ModelePDFCommandes
if (empty($this->atleastonediscount))
{
$delta = ($this->postotalht - $this->posxdiscount);
- $this->posxpicture+=$delta;
- $this->posxtva+=$delta;
- $this->posxup+=$delta;
- $this->posxqty+=$delta;
- $this->posxunit+=$delta;
- $this->posxdiscount+=$delta;
+ $this->posxpicture += $delta;
+ $this->posxtva += $delta;
+ $this->posxup += $delta;
+ $this->posxqty += $delta;
+ $this->posxunit += $delta;
+ $this->posxdiscount += $delta;
// post of fields after are not modified, stay at same position
}
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);
- $tab_top = 90+$top_shift;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
+ $tab_top = 90 + $top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
// Incoterm
if ($conf->incoterm->enabled)
@@ -349,50 +347,50 @@ class pdf_einstein extends ModelePDFCommandes
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
- $height_incoterms=$nexY-$tab_top;
+ $height_incoterms = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
}
}
// Displays notes
- $notetoshow=empty($object->note_public)?'':$object->note_public;
- if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
{
// Get first sale rep
if (is_object($object->thirdparty))
{
- $salereparray=$object->thirdparty->getSalesRepresentatives($user);
- $salerepobj=new User($this->db);
+ $salereparray = $object->thirdparty->getSalesRepresentatives($user);
+ $salerepobj = new User($this->db);
$salerepobj->fetch($salereparray[0]['id']);
- if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
+ if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
}
}
if ($notetoshow)
{
$tab_top -= 2;
- $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
+ $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
$nexY = $pdf->GetY();
- $height_note=$nexY-$tab_top;
+ $height_note = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
}
$iniY = $tab_top + 7;
@@ -400,156 +398,160 @@ class pdf_einstein extends ModelePDFCommandes
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
$pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore=$pdf->getPage();
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
// Description of product line
- $curX = $this->posxdesc-1;
+ $curX = $this->posxdesc - 1;
- $showpricebeforepagebreak=1;
+ $showpricebeforepagebreak = 1;
$pdf->startTransaction();
- pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva-$curX, 3, $curX, $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
+ pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
+ $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
- pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva-$curX, 4, $curX, $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
- $posyafter=$pdf->GetY();
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposafter+1);
+ $pdf->setPage($pageposafter + 1);
}
}
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
{
$pdf->commitTransaction();
}
- $posYAfterDescription=$pdf->GetY();
+ $posYAfterDescription = $pdf->GetY();
$nexY = $pdf->GetY();
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
+ $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
// VAT Rate
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
{
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
- $pdf->SetXY($this->posxtva-5, $curY);
- $pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
+ $pdf->SetXY($this->posxtva - 5, $curY);
+ $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0, 'R');
}
// Unit price before discount
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxup, $curY);
- $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
+ $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
// Quantity
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxqty, $curY);
- $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
+ $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
// Unit
- if($conf->global->PRODUCT_USE_UNITS)
+ if ($conf->global->PRODUCT_USE_UNITS)
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
- $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
+ $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
}
// Discount on line
$pdf->SetXY($this->posxdiscount, $curY);
if ($object->lines[$i]->remise_percent)
{
- $pdf->SetXY($this->posxdiscount-2, $curY);
+ $pdf->SetXY($this->posxdiscount - 2, $curY);
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
+ $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
}
// Total HT line
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->postotalht, $curY);
- $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
+ $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
// Collection of totals by value of vat in $this->vat["rate"] = total_tva
- if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
- else $tvaligne=$object->lines[$i]->total_tva;
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $object->lines[$i]->total_tva;
- $localtax1ligne=$object->lines[$i]->total_localtax1;
- $localtax2ligne=$object->lines[$i]->total_localtax2;
- $localtax1_rate=$object->lines[$i]->localtax1_tx;
- $localtax2_rate=$object->lines[$i]->localtax2_tx;
- $localtax1_type=$object->lines[$i]->localtax1_type;
- $localtax2_type=$object->lines[$i]->localtax2_type;
+ $localtax1ligne = $object->lines[$i]->total_localtax1;
+ $localtax2ligne = $object->lines[$i]->total_localtax2;
+ $localtax1_rate = $object->lines[$i]->localtax1_tx;
+ $localtax2_rate = $object->lines[$i]->localtax2_tx;
+ $localtax1_type = $object->lines[$i]->localtax1_type;
+ $localtax2_type = $object->lines[$i]->localtax2_type;
- if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
+ if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
- $vatrate=(string) $object->lines[$i]->tva_tx;
+ $vatrate = (string) $object->lines[$i]->tva_tx;
// Retrieve type from database for backward compatibility with old records
- if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
- && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
+ if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
{
- $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
+ $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
$localtax1_type = $localtaxtmp_array[0];
$localtax2_type = $localtaxtmp_array[2];
}
// retrieve global local tax
if ($localtax1_type && $localtax1ligne != 0)
- $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
+ $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
if ($localtax2_type && $localtax2ligne != 0)
- $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
+ $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
- if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
- if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0;
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
+ if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
$this->tva[$vatrate] += $tvaligne;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
+ $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Add space between lines
+ $nexY += 2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -566,10 +568,10 @@ class pdf_einstein extends ModelePDFCommandes
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pagenb++;
$pdf->setPage($pagenb);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
- if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
{
if ($pagenb == 1)
{
@@ -582,7 +584,7 @@ class pdf_einstein extends ModelePDFCommandes
$this->_pagefoot($pdf, $object, $outputlangs, 1);
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
@@ -593,13 +595,13 @@ class pdf_einstein extends ModelePDFCommandes
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
else
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
// Affiche zone infos
- $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
+ $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux
- $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+ $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Affiche zone versements
/*
@@ -619,31 +621,31 @@ class pdf_einstein extends ModelePDFCommandes
// Add pdfgeneration hook
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
- if (! empty($conf->global->MAIN_UMASK))
+ if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
- return 1; // No error
+ return 1; // No error
}
else
{
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
else
{
- $this->error=$langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
+ $this->error = $langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
return 0;
}
}
@@ -678,22 +680,22 @@ class pdf_einstein extends ModelePDFCommandes
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{
// phpcs:enable
- global $conf;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
{
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
- $posy=$pdf->GetY()+4;
+ $posy = $pdf->GetY() + 4;
}
- $posxval=52;
+ $posxval = 52;
// Show payments conditions
if ($object->cond_reglement_code || $object->cond_reglement)
@@ -705,11 +707,11 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
- $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
- $posy=$pdf->GetY()+3;
+ $posy = $pdf->GetY() + 3;
}
// Check a payment mode is defined
@@ -740,7 +742,7 @@ class pdf_einstein extends ModelePDFCommandes
}*/
// Show planed date of delivery
- if (! empty($object->date_livraison))
+ if (!empty($object->date_livraison))
{
$outputlangs->load("sendings");
$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -749,10 +751,10 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell(80, 4, $titre, 0, 'L');
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $dlp=dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
+ $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
$pdf->MultiCell(80, 4, $dlp, 0, 'L');
- $posy=$pdf->GetY()+1;
+ $posy = $pdf->GetY() + 1;
}
elseif ($object->availability_code || $object->availability) // Show availability conditions
{
@@ -763,11 +765,11 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
- $lib_availability=str_replace('\n', "\n", $lib_availability);
+ $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '');
+ $lib_availability = str_replace('\n', "\n", $lib_availability);
$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
- $posy=$pdf->GetY()+1;
+ $posy = $pdf->GetY() + 1;
}
// Show payment mode
@@ -781,17 +783,17 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
+ $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
- $posy=$pdf->GetY()+2;
+ $posy = $pdf->GetY() + 2;
}
// Show payment mode CHQ
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
{
// Si mode reglement non force ou si force a CHQ
- if (! empty($conf->global->FACTURE_CHQ_NUMBER))
+ if (!empty($conf->global->FACTURE_CHQ_NUMBER))
{
if ($conf->global->FACTURE_CHQ_NUMBER > 0)
{
@@ -801,14 +803,14 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
- $posy=$pdf->GetY()+1;
+ $posy = $pdf->GetY() + 1;
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
{
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
+ $posy = $pdf->GetY() + 2;
}
}
if ($conf->global->FACTURE_CHQ_NUMBER == -1)
@@ -816,14 +818,14 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
- $posy=$pdf->GetY()+1;
+ $posy = $pdf->GetY() + 1;
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
{
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
+ $posy = $pdf->GetY() + 2;
}
}
}
@@ -832,19 +834,19 @@ class pdf_einstein extends ModelePDFCommandes
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
{
- if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
+ if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
{
- $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
- if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
+ $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
+ if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
$account = new Account($this->db);
$account->fetch($bankid);
- $curx=$this->marge_gauche;
- $cury=$posy;
+ $curx = $this->marge_gauche;
+ $cury = $posy;
- $posy=pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
+ $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
- $posy+=2;
+ $posy += 2;
}
}
@@ -866,7 +868,7 @@ class pdf_einstein extends ModelePDFCommandes
protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
// phpcs:enable
- global $conf,$mysoc;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -878,32 +880,32 @@ class pdf_einstein extends ModelePDFCommandes
$col1x = 120; $col2x = 170;
if ($this->page_largeur < 210) // To work with US executive format
{
- $col2x-=20;
+ $col2x -= 20;
}
$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
- $useborder=0;
+ $useborder = 0;
$index = 0;
// Total HT
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + 0);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
// Show VAT by rates and total
$pdf->SetFillColor(248, 248, 248);
$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
- $this->atleastoneratenotnull=0;
+ $this->atleastoneratenotnull = 0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
- $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
+ $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
{
// Nothing to do
}
@@ -912,27 +914,27 @@ class pdf_einstein extends ModelePDFCommandes
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -943,27 +945,27 @@ class pdf_einstein extends ModelePDFCommandes
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -972,7 +974,7 @@ class pdf_einstein extends ModelePDFCommandes
}
//}
// VAT
- foreach($this->tva as $tvakey => $tvaval)
+ foreach ($this->tva as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -981,15 +983,15 @@ class pdf_einstein extends ModelePDFCommandes
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
- $totalvat.=vatrate($tvakey, 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
+ $totalvat .= vatrate($tvakey, 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -999,11 +1001,11 @@ class pdf_einstein extends ModelePDFCommandes
//Local tax 1 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -1012,16 +1014,16 @@ class pdf_einstein extends ModelePDFCommandes
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
}
@@ -1031,11 +1033,11 @@ class pdf_einstein extends ModelePDFCommandes
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -1044,16 +1046,16 @@ class pdf_einstein extends ModelePDFCommandes
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1067,7 +1069,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
@@ -1076,13 +1078,13 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0, 0, 0);
- $creditnoteamount=0;
- $depositsamount=0;
+ $creditnoteamount = 0;
+ $depositsamount = 0;
//$creditnoteamount=$object->getSumCreditNotesUsed();
//$depositsamount=$object->getSumDepositsUsed();
//print "x".$creditnoteamount."-".$depositsamount;exit;
$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
- if (! empty($object->paye)) $resteapayer=0;
+ if (!empty($object->paye)) $resteapayer = 0;
if ($deja_regle > 0)
{
@@ -1090,7 +1092,7 @@ class pdf_einstein extends ModelePDFCommandes
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
@@ -1098,7 +1100,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
@@ -1130,8 +1132,8 @@ class pdf_einstein extends ModelePDFCommandes
global $conf;
// Force to disable hidetop and hidebottom
- $hidebottom=0;
- if ($hidetop) $hidetop=-1;
+ $hidebottom = 0;
+ if ($hidetop) $hidetop = -1;
$currency = !empty($currency) ? $currency : $conf->currency;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1143,52 +1145,52 @@ class pdf_einstein extends ModelePDFCommandes
if (empty($hidetop))
{
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
- if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
}
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', '', $default_font_size - 1);
// Output Rect
- $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
if (empty($hidetop))
{
- $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter
+ $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter
- $pdf->SetXY($this->posxdesc-1, $tab_top+1);
+ $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
}
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
{
- $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
+ $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
if (empty($hidetop))
{
- $pdf->SetXY($this->posxtva-3, $tab_top+1);
- $pdf->MultiCell($this->posxup-$this->posxtva+3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
+ $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
+ $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
}
}
- $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
+ $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
if (empty($hidetop))
{
- $pdf->SetXY($this->posxup-1, $tab_top+1);
- $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
+ $pdf->SetXY($this->posxup - 1, $tab_top + 1);
+ $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
}
- $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
+ $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
if (empty($hidetop))
{
- $pdf->SetXY($this->posxqty-1, $tab_top+1);
- $pdf->MultiCell($this->posxunit-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
+ $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
+ $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
- if($conf->global->PRODUCT_USE_UNITS) {
+ if ($conf->global->PRODUCT_USE_UNITS) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -1196,13 +1198,13 @@ class pdf_einstein extends ModelePDFCommandes
}
}
- $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
+ $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
if (empty($hidetop))
{
if ($this->atleastonediscount)
{
- $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
+ $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
+ $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
}
}
@@ -1212,7 +1214,7 @@ class pdf_einstein extends ModelePDFCommandes
}
if (empty($hidetop))
{
- $pdf->SetXY($this->postotalht-1, $tab_top+1);
+ $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
}
}
@@ -1232,7 +1234,7 @@ class pdf_einstein extends ModelePDFCommandes
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
{
// phpcs:enable
- global $conf,$langs,$hookmanager;
+ global $conf, $langs, $hookmanager;
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
@@ -1242,7 +1244,7 @@ class pdf_einstein extends ModelePDFCommandes
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
+ if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
{
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
}
@@ -1250,8 +1252,8 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-100;
+ $posy = $this->marge_haute;
+ $posx = $this->page_largeur - $this->marge_droite - 100;
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1261,7 +1263,7 @@ class pdf_einstein extends ModelePDFCommandes
if ($this->emetteur->logo)
{
$logodir = $conf->mycompany->dir_output;
- if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
@@ -1271,20 +1273,20 @@ class pdf_einstein extends ModelePDFCommandes
}
if (is_readable($logo))
{
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
}
else
{
$pdf->SetTextColor(200, 0, 0);
- $pdf->SetFont('', 'B', $default_font_size -2);
+ $pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
}
}
else
{
- $text=$this->emetteur->name;
+ $text = $this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
}
@@ -1292,56 +1294,80 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetFont('', 'B', $default_font_size + 3);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $title=$outputlangs->transnoentities($titlekey);
+ $title = $outputlangs->transnoentities($titlekey);
$pdf->MultiCell(100, 3, $title, '', 'R');
$pdf->SetFont('', 'B', $default_font_size);
- $posy+=5;
+ $posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
+ $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
- $posy+=1;
+ $posy += 1;
$pdf->SetFont('', '', $default_font_size - 1);
if ($object->ref_client)
{
- $posy+=5;
+ $posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
- $posy+=4;
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
+ }
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
+ }
+ }
+
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
- if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && ! empty($object->thirdparty->code_client))
+ if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client))
{
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
}
// Get contact
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
{
- $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL');
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
if (count($arrayidcontact) > 0)
{
- $usertmp=new User($this->db);
+ $usertmp = new User($this->db);
$usertmp->fetch($arrayidcontact[0]);
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
}
}
- $posy+=2;
+ $posy += 2;
$top_shift = 0;
// Show list of linked objects
@@ -1355,28 +1381,28 @@ class pdf_einstein extends ModelePDFCommandes
if ($showaddress)
{
// Sender properties
- $carac_emetteur='';
+ $carac_emetteur = '';
// Add internal contact of proposal if defined
- $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL');
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
if (count($arrayidcontact) > 0)
{
$object->fetch_user($arrayidcontact[0]);
- $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
- $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+ $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
+ $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
}
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
- $posy=42+$top_shift;
- $posx=$this->marge_gauche;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
- $hautcadre=40;
+ $posy = 42 + $top_shift;
+ $posx = $this->marge_gauche;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
+ $hautcadre = 40;
// Show sender frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx, $posy-5);
+ $pdf->SetXY($posx, $posy - 5);
$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
$pdf->SetXY($posx, $posy);
$pdf->SetFillColor(230, 230, 230);
@@ -1384,25 +1410,25 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0, 0, 60);
// Show sender name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
- $posy=$pdf->getY();
+ $posy = $pdf->getY();
// Show sender information
- $pdf->SetXY($posx+2, $posy);
+ $pdf->SetXY($posx + 2, $posy);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
// If CUSTOMER contact defined on order, we use it
- $usecontact=false;
- $arrayidcontact=$object->getIdContact('external', 'CUSTOMER');
+ $usecontact = false;
+ $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
if (count($arrayidcontact) > 0)
{
- $usecontact=true;
- $result=$object->fetch_contact($arrayidcontact[0]);
+ $usecontact = true;
+ $result = $object->fetch_contact($arrayidcontact[0]);
}
//Recipient name
@@ -1413,26 +1439,26 @@ class pdf_einstein extends ModelePDFCommandes
$thirdparty = $object->thirdparty;
}
- $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
+ $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
- $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object);
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
// Show recipient
- $widthrecbox=100;
- if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
- $posy=42+$top_shift;
- $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ $widthrecbox = 100;
+ if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
+ $posy = 42 + $top_shift;
+ $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
// Show recipient frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx+2, $posy-5);
+ $pdf->SetXY($posx + 2, $posy - 5);
$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show recipient name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
@@ -1440,7 +1466,7 @@ class pdf_einstein extends ModelePDFCommandes
// Show recipient information
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->SetXY($posx+2, $posy);
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
}
@@ -1463,7 +1489,7 @@ class pdf_einstein extends ModelePDFCommandes
{
// phpcs:enable
global $conf;
- $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
}
diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
index 6342cd6ce74..5bdc591c2fb 100644
--- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
@@ -77,7 +77,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* Dolibarr version of the loaded document
* @var string
*/
- public $version = 'development';
+ public $version = 'dolibarr';
/**
* @var int page_largeur
@@ -116,7 +116,7 @@ class pdf_eratosthene extends ModelePDFCommandes
/**
* Issuer
- * @var Societe
+ * @var Societe Object that emits
*/
public $emetteur;
@@ -136,47 +136,45 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->db = $db;
$this->name = "eratosthene";
$this->description = $langs->trans('PDFEratostheneDescription');
- $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
+ $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
// Dimension page
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
+ $formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+ $this->format = array($this->page_largeur, $this->page_hauteur);
+ $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
+ $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
+ $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
+ $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
- $this->option_logo = 1; // Display logo
- $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
- $this->option_modereg = 1; // Display payment mode
- $this->option_condreg = 1; // Display payment terms
- $this->option_codeproduitservice = 1; // Display product-service code
- $this->option_multilang = 1; // Available in several languages
- $this->option_escompte = 0; // Displays if there has been a discount
- $this->option_credit_note = 0; // Support credit notes
- $this->option_freetext = 1; // Support add of a personalised text
- $this->option_draft_watermark = 1; // Support add of a watermark on drafts
-
- $this->franchise=!$mysoc->tva_assuj;
+ $this->option_logo = 1; // Display logo
+ $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Display payment mode
+ $this->option_condreg = 1; // Display payment terms
+ $this->option_codeproduitservice = 1; // Display product-service code
+ $this->option_multilang = 1; // Available in several languages
+ $this->option_escompte = 0; // Displays if there has been a discount
+ $this->option_credit_note = 0; // Support credit notes
+ $this->option_freetext = 1; // Support add of a personalised text
+ $this->option_draft_watermark = 1; // Support add of a watermark on drafts
// Get source company
- $this->emetteur=$mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined
+ $this->emetteur = $mysoc;
+ if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
// Define position of columns
- $this->posxdesc=$this->marge_gauche+1;
+ $this->posxdesc = $this->marge_gauche + 1;
$this->tabTitleHeight = 5; // default height
- $this->tva=array();
- $this->localtax1=array();
- $this->localtax2=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
+ $this->tva = array();
+ $this->localtax1 = array();
+ $this->localtax2 = array();
+ $this->atleastoneratenotnull = 0;
+ $this->atleastonediscount = 0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -196,48 +194,55 @@ class pdf_eratosthene extends ModelePDFCommandes
// phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ if (!is_object($outputlangs)) $outputlangs = $langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
- // Translations
+ // Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ global $outputlangsbis;
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
+ }
+
$nblines = count($object->lines);
- $hidetop=0;
- if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){
- $hidetop=$conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
+ $hidetop = 0;
+ if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
+ $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
}
// Loop on each lines to detect if there is at least one image to show
- $realpatharray=array();
+ $realpatharray = array();
$this->atleastonephoto = false;
- if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
+ if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
{
$objphoto = new Product($this->db);
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto->fetch($object->lines[$i]->fk_product);
//var_dump($objphoto->ref);exit;
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
- $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/";
- $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/';
+ $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
+ $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
}
else
{
- $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default
- $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; // alternative
+ $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
+ $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
}
$arephoto = false;
foreach ($pdir as $midir)
{
- if (! $arephoto)
+ if (!$arephoto)
{
$dir = $conf->product->dir_output.'/'.$midir;
@@ -282,20 +287,20 @@ class pdf_eratosthene extends ModelePDFCommandes
if ($object->specimen)
{
$dir = $conf->commande->multidir_output[$conf->entity];
- $file = $dir . "/SPECIMEN.pdf";
+ $file = $dir."/SPECIMEN.pdf";
}
else
{
$objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->commande->multidir_output[$object->entity] . "/" . $objectref;
- $file = $dir . "/" . $objectref . ".pdf";
+ $dir = $conf->commande->multidir_output[$object->entity]."/".$objectref;
+ $file = $dir."/".$objectref.".pdf";
}
- if (! file_exists($dir))
+ if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
@@ -329,14 +334,14 @@ class pdf_eratosthene extends ModelePDFCommandes
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
- if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
$pdf->Open();
- $pagenb=0;
+ $pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
@@ -359,16 +364,16 @@ class pdf_eratosthene extends ModelePDFCommandes
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);
- $tab_top = 90+$top_shift;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
+ $tab_top = 90 + $top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
// Incoterm
if ($conf->incoterm->enabled)
@@ -379,39 +384,39 @@ class pdf_eratosthene extends ModelePDFCommandes
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
- $height_incoterms=$nexY-$tab_top;
+ $height_incoterms = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
}
}
- // Affiche notes
- $notetoshow=empty($object->note_public)?'':$object->note_public;
- if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
+ // Displays notes
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
{
// Get first sale rep
if (is_object($object->thirdparty))
{
- $salereparray=$object->thirdparty->getSalesRepresentatives($user);
- $salerepobj=new User($this->db);
+ $salereparray = $object->thirdparty->getSalesRepresentatives($user);
+ $salerepobj = new User($this->db);
$salerepobj->fetch($salereparray[0]['id']);
- if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
+ if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
}
}
$pagenb = $pdf->getPage();
if ($notetoshow)
{
- $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
+ $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
$pageposbeforenote = $pagenb;
- $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
+ $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
@@ -539,85 +544,94 @@ class pdf_eratosthene extends ModelePDFCommandes
$nexY = $tab_top + $this->tabTitleHeight + 2;
// Loop on each lines
- $pageposbeforeprintlines=$pdf->getPage();
+ $pageposbeforeprintlines = $pdf->getPage();
$pagenb = $pageposbeforeprintlines;
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
- $imglinesize=array();
- if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
+ $imglinesize = array();
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
$pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore=$pdf->getPage();
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
// Description of product line
- $curX = $this->posxdesc-1;
+ $curX = $this->posxdesc - 1;
- $showpricebeforepagebreak=1;
- $posYAfterImage=0;
- $posYAfterDescription=0;
+ $showpricebeforepagebreak = 1;
+ $posYAfterImage = 0;
+ $posYAfterDescription = 0;
- if($this->getColumnStatus('photo'))
+ if ($this->getColumnStatus('photo'))
{
// We start with Photo of product line
- if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page
+ if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
- $pdf->setPage($pageposbefore+1);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ $pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
{
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
- $posYAfterImage=$curY+$imglinesize['height'];
+ $posYAfterImage = $curY + $imglinesize['height'];
}
}
- if($this->getColumnStatus('desc'))
+ if ($this->getColumnStatus('desc'))
{
$pdf->startTransaction();
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
- $posyafter=$pdf->GetY();
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposafter+1);
+ $pdf->setPage($pageposafter + 1);
}
}
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
{
$pdf->commitTransaction();
}
- $posYAfterDescription=$pdf->GetY();
+ $posYAfterDescription = $pdf->GetY();
}
@@ -625,18 +639,18 @@ class pdf_eratosthene extends ModelePDFCommandes
$nexY = max($pdf->GetY(), $posYAfterImage);
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
+ $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
// VAT Rate
if ($this->getColumnStatus('vat'))
@@ -698,56 +712,56 @@ class pdf_eratosthene extends ModelePDFCommandes
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails
);
- $reshook=$hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
+ $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
// Collection of totals by value of vat in $this->tva["rate"] = total_tva
- if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
- else $tvaligne=$object->lines[$i]->total_tva;
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $object->lines[$i]->total_tva;
- $localtax1ligne=$object->lines[$i]->total_localtax1;
- $localtax2ligne=$object->lines[$i]->total_localtax2;
- $localtax1_rate=$object->lines[$i]->localtax1_tx;
- $localtax2_rate=$object->lines[$i]->localtax2_tx;
- $localtax1_type=$object->lines[$i]->localtax1_type;
- $localtax2_type=$object->lines[$i]->localtax2_type;
+ $localtax1ligne = $object->lines[$i]->total_localtax1;
+ $localtax2ligne = $object->lines[$i]->total_localtax2;
+ $localtax1_rate = $object->lines[$i]->localtax1_tx;
+ $localtax2_rate = $object->lines[$i]->localtax2_tx;
+ $localtax1_type = $object->lines[$i]->localtax1_type;
+ $localtax2_type = $object->lines[$i]->localtax2_type;
- if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
+ if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
- $vatrate=(string) $object->lines[$i]->tva_tx;
+ $vatrate = (string) $object->lines[$i]->tva_tx;
// Retrieve type from database for backward compatibility with old records
- if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
- && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
+ if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
{
- $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
+ $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
$localtax1_type = $localtaxtmp_array[0];
$localtax2_type = $localtaxtmp_array[2];
}
// retrieve global local tax
if ($localtax1_type && $localtax1ligne != 0)
- $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
+ $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
if ($localtax2_type && $localtax2ligne != 0)
- $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
+ $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
- if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
- if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0;
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
+ if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
$this->tva[$vatrate] += $tvaligne;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
+ $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Add space between lines
+ $nexY += 2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -817,31 +831,31 @@ class pdf_eratosthene extends ModelePDFCommandes
// Add pdfgeneration hook
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
- if (! empty($conf->global->MAIN_UMASK))
+ if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
- return 1; // No error
+ return 1; // No error
}
else
{
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
else
{
- $this->error=$langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
+ $this->error = $langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
return 0;
}
}
@@ -866,17 +880,17 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param Object $object Object to show
* @param int $posy Y
* @param Translate $outputlangs Langs object
- * @return void
+ * @return int Pos y
*/
protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
{
- global $conf;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
{
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1073,11 +1087,19 @@ class pdf_eratosthene extends ModelePDFCommandes
$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
$useborder = 0;
$index = 0;
+
+ $outputlangsbis = null;
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
+ }
+
// Total HT
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
- $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
+ $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
@@ -1099,26 +1121,27 @@ class pdf_eratosthene extends ModelePDFCommandes
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
+ $totalvat .= ' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1129,27 +1152,28 @@ class pdf_eratosthene extends ModelePDFCommandes
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
+ $totalvat .= ' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1173,7 +1197,8 @@ class pdf_eratosthene extends ModelePDFCommandes
$tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
+ $totalvat .= ' ';
$totalvat .= vatrate($tvakey, 1).$tvacompl;
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
@@ -1185,11 +1210,11 @@ class pdf_eratosthene extends ModelePDFCommandes
//Local tax 1 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -1198,16 +1223,17 @@ class pdf_eratosthene extends ModelePDFCommandes
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
+ $totalvat .= ' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
}
@@ -1217,11 +1243,11 @@ class pdf_eratosthene extends ModelePDFCommandes
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -1230,16 +1256,17 @@ class pdf_eratosthene extends ModelePDFCommandes
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
+ $totalvat .= ' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1253,7 +1280,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalTTC", $mysoc->country_code) : ''), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
@@ -1276,7 +1303,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', 0);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
@@ -1284,7 +1311,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
@@ -1329,24 +1356,26 @@ class pdf_eratosthene extends ModelePDFCommandes
if (empty($hidetop))
{
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
- if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
+ $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ }
}
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', '', $default_font_size - 1);
// Output Rect
- $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
- if (empty($hidetop)){
- $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
+ if (empty($hidetop)) {
+ $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
}
}
@@ -1360,14 +1389,14 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @param string $titlekey Translation key to show as title of document
- * @return void
+ * @return int Return topshift value
*/
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
{
// phpcs:enable
- global $conf,$langs,$hookmanager;
+ global $conf, $langs, $hookmanager;
- // Translations
+ // Load traductions files required by page
$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1383,8 +1412,8 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-100;
+ $posy = $this->marge_haute;
+ $posx = $this->page_largeur - $this->marge_droite - 100;
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1394,7 +1423,7 @@ class pdf_eratosthene extends ModelePDFCommandes
if ($this->emetteur->logo)
{
$logodir = $conf->mycompany->dir_output;
- if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
@@ -1404,20 +1433,20 @@ class pdf_eratosthene extends ModelePDFCommandes
}
if (is_readable($logo))
{
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
}
else
{
$pdf->SetTextColor(200, 0, 0);
- $pdf->SetFont('', 'B', $default_font_size -2);
+ $pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
}
}
else
{
- $text=$this->emetteur->name;
+ $text = $this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
}
@@ -1446,10 +1475,43 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
+ }
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
+ }
+ }
+
$posy += 4;
+
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "%d %b %Y", false, $outputlangs, true), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
+
+ if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client))
+ {
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
+ }
// Get contact
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php
index 9ba5c731ef5..c36b78d66ab 100644
--- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php
@@ -28,7 +28,7 @@
* \brief File of Class to generate PDF orders with template Proforma
*/
-require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/doc/pdf_einstein.modules.php';
+require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/doc/pdf_eratosthene.modules.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
@@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
/**
* Class to generate PDF orders with template Proforma
*/
-class pdf_proforma extends pdf_einstein
+class pdf_proforma extends pdf_eratosthene
{
/**
diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
index 4594a9d63cd..190abd86126 100644
--- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
+++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php
@@ -185,7 +185,7 @@ class doc_generic_contract_odt extends ModelePDFContract
/**
* Function to build a document on disk using the generic odt module.
*
- * @param Contract $object Object source to build document
+ * @param Contrat $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
index badf7343295..0058ad524f4 100644
--- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php
+++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
@@ -391,7 +391,12 @@ class pdf_strato extends ModelePDFContract
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
diff --git a/htdocs/core/modules/dons/html_cerfafr.html b/htdocs/core/modules/dons/html_cerfafr.html
index 31bf444c63b..4c5b69aadb8 100644
--- a/htdocs/core/modules/dons/html_cerfafr.html
+++ b/htdocs/core/modules/dons/html_cerfafr.html
@@ -3,6 +3,20 @@
Reçu au titre des dons à certains organismes d’intérêt général
+
+
@@ -10,14 +24,14 @@
- N° 11580*03
+ N° 11580*04
DGFIP
Reçu au titre des dons
à certains organismes d’intérêt général
- Articles 200, 238 bis et 885-0 V bis A du code général des impôts (CGI)
+ Articles 200, 238 bis et 978 du code général des impôts (CGI)
Numéro d'ordre du reçu
@@ -46,13 +60,13 @@
__MAIN_INFO_SOCIETE_NOM__
Adresse :
__MAIN_INFO_SOCIETE_ADDRESS__
- Code postal __MAIN_INFO_SOCIETE_ZIP__ Commune __MAIN_INFO_SOCIETE_TOWN__
+ Code postal __MAIN_INFO_SOCIETE_ZIP__ Commune __MAIN_INFO_SOCIETE_TOWN__
Objet:
__MAIN_INFO_SOCIETE_OBJECT__
-
+
Cochez la case concernée (1) :
@@ -217,7 +231,7 @@
__ARTICLE200__
__ARTICLE238__
- __ARTICLE885__
+ __ARTICLE978__
@@ -251,7 +265,7 @@
(3)
-
+
L’organisme bénéficiaire peut cocher une ou plusieurs cases.
L’organisme bénéficiaire peut, en application de l’article L. 80 C du livre des procédures fiscales, demander à l’administration s’il relève
de l’une des catégories d’organismes mentionnées aux articles 200 et 238 bis du code général des impôts.
@@ -262,7 +276,7 @@
(4)
-
+
Notamment : abandon de revenus ou de produits ; frais engagés par les bénévoles, dont ils renoncent expressément au remboursement
@@ -274,10 +288,10 @@
-
+
-
- Date et signature
+
+ Date et signature
diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php
index bcda35459f6..4c025750f04 100644
--- a/htdocs/core/modules/dons/html_cerfafr.modules.php
+++ b/htdocs/core/modules/dons/html_cerfafr.modules.php
@@ -3,7 +3,7 @@
* Copyright (C) 2005-2006 Laurent Destailleur
* Copyright (C) 2012 Regis Houssin
* Copyright (C) 2012 Marcos García
- * Copyright (C) 2014-2015 Alexandre Spangaro
+ * Copyright (C) 2014-2020 Alexandre Spangaro
* Copyright (C) 2015 Benoit Bruchard
*
* This program is free software; you can redistribute it and/or modify
@@ -42,11 +42,11 @@ class html_cerfafr extends ModeleDon
*/
public function __construct($db)
{
- global $conf,$langs;
+ global $conf, $langs;
$this->db = $db;
$this->name = "cerfafr";
- $this->description = $langs->trans('DonationsReceiptModel').' - fr_FR - Cerfa 11580*03';
+ $this->description = $langs->trans('DonationsReceiptModel').' - fr_FR - Cerfa 11580*04';
// Dimension page for size A4
$this->type = 'html';
@@ -76,46 +76,46 @@ class html_cerfafr extends ModeleDon
public function write_file($don, $outputlangs, $currency = '')
{
// phpcs:enable
- global $user,$conf,$langs,$mysoc;
+ global $user, $conf, $langs, $mysoc;
- $now=dol_now();
- $id = (! is_object($don)?$don:'');
+ $now = dol_now();
+ $id = (!is_object($don) ? $don : '');
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ if (!is_object($outputlangs)) $outputlangs = $langs;
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "donations"));
$currency = !empty($currency) ? $currency : $conf->currency;
- if (! empty($conf->don->dir_output))
+ if (!empty($conf->don->dir_output))
{
// Definition of the object don (for upward compatibility)
- if (! is_object($don))
+ if (!is_object($don))
{
$don = new Don($this->db);
- $ret=$don->fetch($id);
- $id=$don->id;
+ $ret = $don->fetch($id);
+ $id = $don->id;
}
// Definition of $dir and $file
- if (! empty($don->specimen))
+ if (!empty($don->specimen))
{
$dir = $conf->don->dir_output;
- $file = $dir . "/SPECIMEN.html";
+ $file = $dir."/SPECIMEN.html";
}
else
{
$donref = dol_sanitizeFileName($don->ref);
- $dir = $conf->don->dir_output . "/" . $donref;
- $file = $dir . "/" . $donref . ".html";
+ $dir = $conf->don->dir_output."/".$donref;
+ $file = $dir."/".$donref.".html";
}
- if (! file_exists($dir))
+ if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
- $this->error=$langs->trans("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return -1;
}
}
@@ -133,13 +133,13 @@ class html_cerfafr extends ModeleDon
}
else $paymentmode = '';
- if ($don->modepaymentcode=='CHQ'){
+ if ($don->modepaymentcode == 'CHQ') {
$ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire ';
}
- elseif ($don->modepaymentcode=='LIQ'){
+ elseif ($don->modepaymentcode == 'LIQ') {
$ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire ';
}
- elseif ($don->modepaymentcode=='VIR' || $don->modepaymentcode=='PRE' || $don->modepaymentcode=='CB'){
+ elseif ($don->modepaymentcode == 'VIR' || $don->modepaymentcode == 'PRE' || $don->modepaymentcode == 'CB') {
$ModePaiement = ' Remise d\'espèces Chèque Virement, prélèvement, carte bancaire ';
}
else
@@ -150,16 +150,16 @@ class html_cerfafr extends ModeleDon
/*
if (empty($don->societe))
{
- $CodeDon = ' 200 du CGI 238 bis du CGI 885-0 V bis A du CGI ';
+ $CodeDon = ' 200 du CGI 238 bis du CGI 978 du CGI ';
}
else
{
- $CodeDon = ' 200 du CGI 238 bis du CGI 885-0 V bis A du CGI ';
+ $CodeDon = ' 200 du CGI 238 bis du CGI 978 du CGI ';
}
*/
// Define contents
- $donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html";
+ $donmodel = DOL_DOCUMENT_ROOT."/core/modules/dons/html_cerfafr.html";
$form = implode('', file($donmodel));
$form = str_replace('__REF__', $don->id, $form);
$form = str_replace('__DATE__', dol_print_date($don->date, 'day', false, $outputlangs), $form);
@@ -203,59 +203,59 @@ class html_cerfafr extends ModeleDon
$form = str_replace('__ModePaiement__', $ModePaiement, $form);
- $frencharticle='';
- if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencharticle='Article 200, 238 bis et 885-0 V bis A du code général des impôts (CGI) ';
+ $frencharticle = '';
+ if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencharticle = 'Article 200, 238 bis et 978 du code général des impôts (CGI) ';
$form = str_replace('__FrenchArticle__', $frencharticle, $form);
- $frencheligibility='';
- if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencheligibility='Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :';
+ $frencheligibility = '';
+ if (preg_match('/fr/i', $outputlangs->defaultlang)) $frencheligibility = 'Le bénéficiaire certifie sur l\'honneur que les dons et versements qu\'il reçoit ouvrent droit à la réduction d\'impôt prévue à l\'article :';
$form = str_replace('__FrenchEligibility__', $frencheligibility, $form);
- $art200='';
+ $art200 = '';
if (preg_match('/fr/i', $outputlangs->defaultlang)) {
if ($conf->global->DONATION_ART200 >= 1)
{
- $art200=' 200 du CGI';
+ $art200 = ' 200 du CGI';
}
else
{
- $art200=' 200 du CGI';
+ $art200 = ' 200 du CGI';
}
}
$form = str_replace('__ARTICLE200__', $art200, $form);
- $art238='';
+ $art238 = '';
if (preg_match('/fr/i', $outputlangs->defaultlang)) {
if ($conf->global->DONATION_ART238 >= 1)
{
- $art238=' 238 bis du CGI';
+ $art238 = ' 238 bis du CGI';
}
else
{
- $art238=' 238 bis du CGI';
+ $art238 = ' 238 bis du CGI';
}
}
$form = str_replace('__ARTICLE238__', $art238, $form);
- $art885='';
+ $art978 = '';
if (preg_match('/fr/i', $outputlangs->defaultlang)) {
- if ($conf->global->DONATION_ART885 >= 1)
+ if ($conf->global->DONATION_ART978 >= 1)
{
- $art885=' 885-0 V bis du CGI';
+ $art978 = ' 978 du CGI';
}
else
{
- $art885=' 885-0 V bis du CGI';
+ $art978 = ' 978 du CGI';
}
}
- $form = str_replace('__ARTICLE885__', $art885, $form);
+ $form = str_replace('__ARTICLE978__', $art978, $form);
// Save file on disk
dol_syslog("html_cerfafr::write_file $file");
- $handle=fopen($file, "w");
+ $handle = fopen($file, "w");
fwrite($handle, $form);
fclose($handle);
- if (! empty($conf->global->MAIN_UMASK))
+ if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
@@ -264,13 +264,13 @@ class html_cerfafr extends ModeleDon
}
else
{
- $this->error=$langs->trans("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return 0;
}
}
else
{
- $this->error=$langs->trans("ErrorConstantNotDefined", "DON_OUTPUTDIR");
+ $this->error = $langs->trans("ErrorConstantNotDefined", "DON_OUTPUTDIR");
return 0;
}
}
@@ -288,147 +288,147 @@ class html_cerfafr extends ModeleDon
$unite = array();
$dix = array();
$cent = array();
- if(empty($devise1)) $dev1='euros';
- else $dev1=$devise1;
- if(empty($devise2)) $dev2='centimes';
- else $dev2=$devise2;
- $valeur_entiere=intval($montant);
- $valeur_decimal=intval(round($montant-intval($montant), 2)*100);
- $dix_c=intval($valeur_decimal%100/10);
- $cent_c=intval($valeur_decimal%1000/100);
- $unite[1]=$valeur_entiere%10;
- $dix[1]=intval($valeur_entiere%100/10);
- $cent[1]=intval($valeur_entiere%1000/100);
- $unite[2]=intval($valeur_entiere%10000/1000);
- $dix[2]=intval($valeur_entiere%100000/10000);
- $cent[2]=intval($valeur_entiere%1000000/100000);
- $unite[3]=intval($valeur_entiere%10000000/1000000);
- $dix[3]=intval($valeur_entiere%100000000/10000000);
- $cent[3]=intval($valeur_entiere%1000000000/100000000);
- $chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf');
- $secon_c='';
- $trio_c='';
- for($i=1; $i<=3; $i++) {
- $prim[$i]='';
- $secon[$i]='';
- $trio[$i]='';
- if ($dix[$i]==0) {
- $secon[$i]='';
- $prim[$i]=$chif[$unite[$i]];
+ if (empty($devise1)) $dev1 = 'euros';
+ else $dev1 = $devise1;
+ if (empty($devise2)) $dev2 = 'centimes';
+ else $dev2 = $devise2;
+ $valeur_entiere = intval($montant);
+ $valeur_decimal = intval(round($montant - intval($montant), 2) * 100);
+ $dix_c = intval($valeur_decimal % 100 / 10);
+ $cent_c = intval($valeur_decimal % 1000 / 100);
+ $unite[1] = $valeur_entiere % 10;
+ $dix[1] = intval($valeur_entiere % 100 / 10);
+ $cent[1] = intval($valeur_entiere % 1000 / 100);
+ $unite[2] = intval($valeur_entiere % 10000 / 1000);
+ $dix[2] = intval($valeur_entiere % 100000 / 10000);
+ $cent[2] = intval($valeur_entiere % 1000000 / 100000);
+ $unite[3] = intval($valeur_entiere % 10000000 / 1000000);
+ $dix[3] = intval($valeur_entiere % 100000000 / 10000000);
+ $cent[3] = intval($valeur_entiere % 1000000000 / 100000000);
+ $chif = array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf');
+ $secon_c = '';
+ $trio_c = '';
+ for ($i = 1; $i <= 3; $i++) {
+ $prim[$i] = '';
+ $secon[$i] = '';
+ $trio[$i] = '';
+ if ($dix[$i] == 0) {
+ $secon[$i] = '';
+ $prim[$i] = $chif[$unite[$i]];
}
- elseif ($dix[$i]==1) {
- $secon[$i]='';
- $prim[$i]=$chif[($unite[$i]+10)];
+ elseif ($dix[$i] == 1) {
+ $secon[$i] = '';
+ $prim[$i] = $chif[($unite[$i] + 10)];
}
- elseif ($dix[$i]==2) {
- if ($unite[$i]==1) {
- $secon[$i]='vingt et';
- $prim[$i]=$chif[$unite[$i]];
+ elseif ($dix[$i] == 2) {
+ if ($unite[$i] == 1) {
+ $secon[$i] = 'vingt et';
+ $prim[$i] = $chif[$unite[$i]];
} else {
- $secon[$i]='vingt';
- $prim[$i]=$chif[$unite[$i]];
+ $secon[$i] = 'vingt';
+ $prim[$i] = $chif[$unite[$i]];
}
}
- elseif ($dix[$i]==3) {
- if ($unite[$i]==1) {
- $secon[$i]='trente et';
- $prim[$i]=$chif[$unite[$i]];
+ elseif ($dix[$i] == 3) {
+ if ($unite[$i] == 1) {
+ $secon[$i] = 'trente et';
+ $prim[$i] = $chif[$unite[$i]];
} else {
- $secon[$i]='trente';
- $prim[$i]=$chif[$unite[$i]];
+ $secon[$i] = 'trente';
+ $prim[$i] = $chif[$unite[$i]];
}
}
- elseif ($dix[$i]==4) {
- if ($unite[$i]==1) {
- $secon[$i]='quarante et';
- $prim[$i]=$chif[$unite[$i]];
+ elseif ($dix[$i] == 4) {
+ if ($unite[$i] == 1) {
+ $secon[$i] = 'quarante et';
+ $prim[$i] = $chif[$unite[$i]];
}
else {
- $secon[$i]='quarante';
- $prim[$i]=$chif[$unite[$i]];
+ $secon[$i] = 'quarante';
+ $prim[$i] = $chif[$unite[$i]];
}
}
- elseif ($dix[$i]==5) {
- if ($unite[$i]==1) {
- $secon[$i]='cinquante et';
- $prim[$i]=$chif[$unite[$i]];
+ elseif ($dix[$i] == 5) {
+ if ($unite[$i] == 1) {
+ $secon[$i] = 'cinquante et';
+ $prim[$i] = $chif[$unite[$i]];
}
else {
- $secon[$i]='cinquante';
- $prim[$i]=$chif[$unite[$i]];
+ $secon[$i] = 'cinquante';
+ $prim[$i] = $chif[$unite[$i]];
}
}
- elseif ($dix[$i]==6) {
- if ($unite[$i]==1) {
- $secon[$i]='soixante et';
- $prim[$i]=$chif[$unite[$i]];
+ elseif ($dix[$i] == 6) {
+ if ($unite[$i] == 1) {
+ $secon[$i] = 'soixante et';
+ $prim[$i] = $chif[$unite[$i]];
}
else {
- $secon[$i]='soixante';
- $prim[$i]=$chif[$unite[$i]];
+ $secon[$i] = 'soixante';
+ $prim[$i] = $chif[$unite[$i]];
}
}
- elseif ($dix[$i]==7) {
- if ($unite[$i]==1) {
- $secon[$i]='soixante et';
- $prim[$i]=$chif[$unite[$i]+10];
+ elseif ($dix[$i] == 7) {
+ if ($unite[$i] == 1) {
+ $secon[$i] = 'soixante et';
+ $prim[$i] = $chif[$unite[$i] + 10];
}
else {
- $secon[$i]='soixante';
- $prim[$i]=$chif[$unite[$i]+10];
+ $secon[$i] = 'soixante';
+ $prim[$i] = $chif[$unite[$i] + 10];
}
}
- elseif ($dix[$i]==8) {
- if ($unite[$i]==1) {
- $secon[$i]='quatre-vingts et';
- $prim[$i]=$chif[$unite[$i]];
+ elseif ($dix[$i] == 8) {
+ if ($unite[$i] == 1) {
+ $secon[$i] = 'quatre-vingts et';
+ $prim[$i] = $chif[$unite[$i]];
}
else {
- $secon[$i]='quatre-vingt';
- $prim[$i]=$chif[$unite[$i]];
+ $secon[$i] = 'quatre-vingt';
+ $prim[$i] = $chif[$unite[$i]];
}
}
- elseif ($dix[$i]==9) {
- if ($unite[$i]==1) {
- $secon[$i]='quatre-vingts et';
- $prim[$i]=$chif[$unite[$i]+10];
+ elseif ($dix[$i] == 9) {
+ if ($unite[$i] == 1) {
+ $secon[$i] = 'quatre-vingts et';
+ $prim[$i] = $chif[$unite[$i] + 10];
}
else {
- $secon[$i]='quatre-vingts';
- $prim[$i]=$chif[$unite[$i]+10];
+ $secon[$i] = 'quatre-vingts';
+ $prim[$i] = $chif[$unite[$i] + 10];
}
}
- if($cent[$i]==1) $trio[$i]='cent';
- elseif($cent[$i]!=0 || $cent[$i]!='') $trio[$i]=$chif[$cent[$i]] .' cents';
+ if ($cent[$i] == 1) $trio[$i] = 'cent';
+ elseif ($cent[$i] != 0 || $cent[$i] != '') $trio[$i] = $chif[$cent[$i]].' cents';
}
- $chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix');
- $secon_c=$chif2[$dix_c];
- if ($cent_c==1) $trio_c='cent';
- elseif ($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents';
+ $chif2 = array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix');
+ $secon_c = $chif2[$dix_c];
+ if ($cent_c == 1) $trio_c = 'cent';
+ elseif ($cent_c != 0 || $cent_c != '') $trio_c = $chif[$cent_c].' cents';
- if (($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1))
- $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million ';
- elseif (($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!=''))
- $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions ';
+ if (($cent[3] == 0 || $cent[3] == '') && ($dix[3] == 0 || $dix[3] == '') && ($unite[3] == 1))
+ $somme = $trio[3].' '.$secon[3].' '.$prim[3].' million ';
+ elseif (($cent[3] != 0 && $cent[3] != '') || ($dix[3] != 0 && $dix[3] != '') || ($unite[3] != 0 && $unite[3] != ''))
+ $somme = $trio[3].' '.$secon[3].' '.$prim[3].' millions ';
else
- $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3];
+ $somme = $trio[3].' '.$secon[3].' '.$prim[3];
- if (($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1))
+ if (($cent[2] == 0 || $cent[2] == '') && ($dix[2] == 0 || $dix[2] == '') && ($unite[2] == 1))
$somme = $somme.' mille ';
- elseif (($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!=''))
- $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles ';
+ elseif (($cent[2] != 0 && $cent[2] != '') || ($dix[2] != 0 && $dix[2] != '') || ($unite[2] != 0 && $unite[2] != ''))
+ $somme = $somme.$trio[2].' '.$secon[2].' '.$prim[2].' milles ';
else
- $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2];
+ $somme = $somme.$trio[2].' '.$secon[2].' '.$prim[2];
- $somme = $somme. $trio[1]. ' ' .$secon[1]. ' ' . $prim[1];
+ $somme = $somme.$trio[1].' '.$secon[1].' '.$prim[1];
- $somme = $somme. ' '. $dev1 .' ' ;
+ $somme = $somme.' '.$dev1.' ';
- if (($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c==''))
- return $somme. ' et zéro '. $dev2;
+ if (($cent_c == '0' || $cent_c == '') && ($dix_c == '0' || $dix_c == ''))
+ return $somme.' et zéro '.$dev2;
else
- return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2;
+ return $somme.$trio_c.' '.$secon_c.' '.$dev2;
}
}
diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
index 0e74faaa56d..b47149f26a6 100644
--- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
@@ -168,25 +168,32 @@ class pdf_espadon extends ModelePdfExpedition
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ global $outputlangsbis;
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
+ }
+
$nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
- $realpatharray=array();
- if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
+ $realpatharray = array();
+ if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
{
$objphoto = new Product($this->db);
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);
- $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/";
+ $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
- $realpath='';
+ $realpath = '';
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
{
@@ -243,25 +250,25 @@ class pdf_espadon extends ModelePdfExpedition
if (file_exists($dir))
{
// Add pdfgeneration hook
- if (! is_object($hookmanager))
+ if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager=new HookManager($this->db);
+ $hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Set nblines with the new facture lines content after hook
$nblines = count($object->lines);
- $pdf=pdf_getInstance($this->format);
+ $pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
- $heightforinfotot = 8; // Height reserved to output the info and total part
- $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
+ $heightforinfotot = 8; // Height reserved to output the info and total part
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF'))
@@ -316,51 +323,51 @@ class pdf_espadon extends ModelePdfExpedition
$tab_top = 88;
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
- $height_incoterms=$nexY-$tab_top;
+ $height_incoterms = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
$height_incoterms += 4;
}
}
- if (! empty($object->note_public) || ! empty($object->tracking_number))
+ if (!empty($object->note_public) || !empty($object->tracking_number))
{
$tab_top = 88 + $height_incoterms;
$tab_top_alt = $tab_top;
$pdf->SetFont('', 'B', $default_font_size - 2);
- $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L');
+ $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L');
$tab_top_alt = $pdf->GetY();
//$tab_top_alt += 1;
// Tracking number
- if (! empty($object->tracking_number))
+ if (!empty($object->tracking_number))
{
$object->getUrlTrackingStatus($object->tracking_number);
- if (! empty($object->tracking_url))
+ if (!empty($object->tracking_url))
{
if ($object->shipping_method_id > 0)
{
// Get code using getLabelFromKey
- $code=$outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
- $label='';
- if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")." ";
- $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
+ $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
+ $label = '';
+ if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")." ";
+ $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
//var_dump($object->tracking_url != $object->tracking_number);exit;
if ($object->tracking_url != $object->tracking_number)
{
- $label.=" : ";
- $label.=$object->tracking_url;
+ $label .= " : ";
+ $label .= $object->tracking_url;
}
$pdf->SetFont('', 'B', $default_font_size - 2);
- $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L');
+ $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L');
$tab_top_alt = $pdf->GetY();
}
@@ -368,25 +375,25 @@ class pdf_espadon extends ModelePdfExpedition
}
// Notes
- if (! empty($object->note_public))
+ if (!empty($object->note_public))
{
- $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
+ $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
}
$nexY = $pdf->GetY();
- $height_note=$nexY-$tab_top;
+ $height_note = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
$tab_height = $tab_height - $height_note;
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
}
else
{
- $height_note=0;
+ $height_note = 0;
}
@@ -407,90 +414,99 @@ class pdf_espadon extends ModelePdfExpedition
for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
- $imglinesize=array();
- if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
+ $imglinesize = array();
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
$pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore=$pdf->getPage();
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
- $showpricebeforepagebreak=1;
- $posYAfterImage=0;
- $posYAfterDescription=0;
+ $showpricebeforepagebreak = 1;
+ $posYAfterImage = 0;
+ $posYAfterDescription = 0;
- if($this->getColumnStatus('photo'))
+ if ($this->getColumnStatus('photo'))
{
// We start with Photo of product line
- if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // If photo too high, we moved completely on new page
+ if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposbefore+1);
+ $pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
{
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
- $posYAfterImage=$curY+$imglinesize['height'];
+ $posYAfterImage = $curY + $imglinesize['height'];
}
}
// Description of product line
- if($this->getColumnStatus('desc'))
+ if ($this->getColumnStatus('desc'))
{
$pdf->startTransaction();
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
- $posyafter=$pdf->GetY();
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // There is no space left for total+free text
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposafter+1);
+ $pdf->setPage($pageposafter + 1);
}
}
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
{
$pdf->commitTransaction();
}
- $posYAfterDescription=$pdf->GetY();
+ $posYAfterDescription = $pdf->GetY();
}
$nexY = $pdf->GetY();
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description or photo were moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -502,25 +518,25 @@ class pdf_espadon extends ModelePdfExpedition
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
+ $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
// weight
- $weighttxt='';
+ $weighttxt = '';
if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
{
- $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units);
+ $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
}
- $voltxt='';
+ $voltxt = '';
if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
{
- $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0);
+ $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
}
if ($this->getColumnStatus('weight'))
{
- $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt)?' ':'').$voltxt, array('html'=>1));
+ $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? ' ' : '').$voltxt, array('html'=>1));
$nexY = max($pdf->GetY(), $nexY);
}
@@ -544,16 +560,16 @@ class pdf_espadon extends ModelePdfExpedition
- $nexY+=3;
- if ($weighttxt && $voltxt) $nexY+=2;
+ $nexY += 3;
+ if ($weighttxt && $voltxt) $nexY += 2;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80,80,80)));
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1);
+ $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
$pdf->SetLineStyle(array('dash'=>0));
}
@@ -572,10 +588,10 @@ class pdf_espadon extends ModelePdfExpedition
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pagenb++;
$pdf->setPage($pagenb);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
- if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
{
if ($pagenb == 1)
{
@@ -598,16 +614,16 @@ class pdf_espadon extends ModelePdfExpedition
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
// Display total area
- $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
+ $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
// Pagefoot
$this->_pagefoot($pdf, $object, $outputlangs);
@@ -674,7 +690,7 @@ class pdf_espadon extends ModelePdfExpedition
$pdf->SetFont('', 'B', $default_font_size - 1);
// Total table
- $col1x = $this->posxweightvol-50; $col2x = $this->posxweightvol;
+ $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol;
/*if ($this->page_largeur < 210) // To work with US executive format
{
$col2x-=20;
@@ -781,20 +797,22 @@ class pdf_espadon extends ModelePdfExpedition
if (empty($hidetop))
{
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
- if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
+ $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ }
}
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', '', $default_font_size - 1);
// Output Rect
- $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
- if (empty($hidetop)){
- $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
+ if (empty($hidetop)) {
+ $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
}
}
@@ -830,19 +848,19 @@ class pdf_espadon extends ModelePdfExpedition
$w = 110;
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-$w;
+ $posy = $this->marge_haute;
+ $posx = $this->page_largeur - $this->marge_droite - $w;
$pdf->SetXY($this->marge_gauche, $posy);
// Logo
- $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
+ $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (is_readable($logo))
{
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
}
else
{
@@ -854,21 +872,21 @@ class pdf_espadon extends ModelePdfExpedition
}
else
{
- $text=$this->emetteur->name;
+ $text = $this->emetteur->name;
$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
// Show barcode
- if (! empty($conf->barcode->enabled))
+ if (!empty($conf->barcode->enabled))
{
- $posx=105;
+ $posx = 105;
}
else
{
- $posx=$this->marge_gauche+3;
+ $posx = $this->marge_gauche + 3;
}
//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
- if (! empty($conf->barcode->enabled))
+ if (!empty($conf->barcode->enabled))
{
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
@@ -884,67 +902,67 @@ class pdf_espadon extends ModelePdfExpedition
}
- $posx=$this->page_largeur - $w - $this->marge_droite;
- $posy=$this->marge_haute;
+ $posx = $this->page_largeur - $w - $this->marge_droite;
+ $posy = $this->marge_haute;
$pdf->SetFont('', 'B', $default_font_size + 2);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $title=$outputlangs->transnoentities("SendingSheet");
+ $title = $outputlangs->transnoentities("SendingSheet");
$pdf->MultiCell($w, 4, $title, '', 'R');
$pdf->SetFont('', '', $default_font_size + 1);
- $posy+=5;
+ $posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R');
+ $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R');
// Date planned delivery
- if (! empty($object->date_delivery))
+ if (!empty($object->date_delivery))
{
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
}
- if (! empty($object->thirdparty->code_client))
+ if (!empty($object->thirdparty->code_client))
{
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
}
$pdf->SetFont('', '', $default_font_size + 3);
- $Yoff=25;
+ $Yoff = 25;
// Add list of linked orders
- $origin = $object->origin;
- $origin_id = $object->origin_id;
+ $origin = $object->origin;
+ $origin_id = $object->origin_id;
// TODO move to external function
- if (! empty($conf->$origin->enabled)) // commonly $origin='commande'
+ if (!empty($conf->$origin->enabled)) // commonly $origin='commande'
{
$outputlangs->load('orders');
$classname = ucfirst($origin);
$linkedobject = new $classname($this->db);
- $result=$linkedobject->fetch($origin_id);
+ $result = $linkedobject->fetch($origin_id);
if ($result >= 0)
{
//$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
$pdf->SetFont('', '', $default_font_size - 2);
- $text=$linkedobject->ref;
- if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
- $Yoff = $Yoff+8;
+ $text = $linkedobject->ref;
+ if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')';
+ $Yoff = $Yoff + 8;
$pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
- $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
- $Yoff = $Yoff+3;
+ $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R');
+ $Yoff = $Yoff + 3;
$pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
$pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R');
}
@@ -985,24 +1003,24 @@ class pdf_espadon extends ModelePdfExpedition
$pdf->SetFillColor(255, 255, 255);
// Show sender name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
- $pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
- $posy=$pdf->getY();
+ $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+ $posy = $pdf->getY();
// Show sender information
- $pdf->SetXY($posx+2, $posy);
+ $pdf->SetXY($posx + 2, $posy);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L');
+ $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
// If SHIPPING contact defined, we use it
- $usecontact=false;
- $arrayidcontact=$object->$origin->getIdContact('external', 'SHIPPING');
+ $usecontact = false;
+ $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING');
if (count($arrayidcontact) > 0)
{
- $usecontact=true;
- $result=$object->fetch_contact($arrayidcontact[0]);
+ $usecontact = true;
+ $result = $object->fetch_contact($arrayidcontact[0]);
}
//Recipient name
@@ -1013,26 +1031,26 @@ class pdf_espadon extends ModelePdfExpedition
$thirdparty = $object->thirdparty;
}
- $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
+ $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
- $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact)?$object->contact:null), $usecontact, 'targetwithdetails', $object);
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
// Show recipient
- $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
- if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
- $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
- $posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
+ if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
+ $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
+ $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
// Show recipient frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx+2, $posy-5);
+ $pdf->SetXY($posx + 2, $posy - 5);
$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show recipient name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
@@ -1040,7 +1058,7 @@ class pdf_espadon extends ModelePdfExpedition
// Show recipient information
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->SetXY($posx+2, $posy);
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
}
diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index 0e9db902662..ad0272f46a1 100644
--- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -452,7 +452,12 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
- $showpricebeforepagebreak = 0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
if (isset($imglinesize['width']) && isset($imglinesize['height']))
@@ -494,7 +499,12 @@ class pdf_rouget extends ModelePdfExpedition
else
{
// We found a page break
- $showpricebeforepagebreak = 0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
@@ -526,12 +536,12 @@ class pdf_rouget extends ModelePdfExpedition
$weighttxt = '';
if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
{
- $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units);
+ $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
}
$voltxt = '';
if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
{
- $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0);
+ $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
}
if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
index a2cefcf9ff0..0adf7cd2a6a 100644
--- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
@@ -135,43 +135,41 @@ class pdf_standard extends ModeleExpenseReport
// Page size for A4 format
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
+ $formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+ $this->format = array($this->page_largeur, $this->page_hauteur);
+ $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
+ $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
+ $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
+ $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
- $this->option_logo = 1; // Affiche logo
- $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
- $this->option_modereg = 1; // Affiche mode reglement
- $this->option_condreg = 1; // Affiche conditions reglement
- $this->option_codeproduitservice = 1; // Affiche code produit-service
- $this->option_multilang = 1; // Dispo en plusieurs langues
- $this->option_escompte = 0; // Affiche si il y a eu escompte
- $this->option_credit_note = 0; // Support credit notes
- $this->option_freetext = 1; // Support add of a personalised text
- $this->option_draft_watermark = 1; // Support add of a watermark on drafts
-
- $this->franchise = !$mysoc->tva_assuj;
+ $this->option_logo = 1; // Affiche logo
+ $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Affiche mode reglement
+ $this->option_condreg = 1; // Affiche conditions reglement
+ $this->option_codeproduitservice = 1; // Affiche code produit-service
+ $this->option_multilang = 1; // Dispo en plusieurs langues
+ $this->option_escompte = 0; // Affiche si il y a eu escompte
+ $this->option_credit_note = 0; // Support credit notes
+ $this->option_freetext = 1; // Support add of a personalised text
+ $this->option_draft_watermark = 1; // Support add of a watermark on drafts
// Get source company
- $this->emetteur=$mysoc;
+ $this->emetteur = $mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined
+ if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
// Define position of columns
- $this->posxpiece=$this->marge_gauche+1;
- $this->posxcomment=$this->marge_gauche+10;
+ $this->posxpiece = $this->marge_gauche + 1;
+ $this->posxcomment = $this->marge_gauche + 10;
//$this->posxdate=88;
//$this->posxtype=107;
//$this->posxprojet=120;
- $this->posxtva=130;
- $this->posxup=145;
- $this->posxqty=168;
- $this->postotalttc=178;
+ $this->posxtva = 130;
+ $this->posxup = 145;
+ $this->posxqty = 168;
+ $this->postotalttc = 178;
// if (empty($conf->projet->enabled)) {
// $this->posxtva-=20;
// $this->posxup-=20;
@@ -289,40 +287,40 @@ class pdf_standard extends ModeleExpenseReport
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Trips"));
- if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);
$tab_top = 95;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10);
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 65 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
// Show notes
- $notetoshow=empty($object->note_public)?'':$object->note_public;
- if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
{
// Get first sale rep
if (is_object($object->thirdparty))
{
- $salereparray=$object->thirdparty->getSalesRepresentatives($user);
- $salerepobj=new User($this->db);
+ $salereparray = $object->thirdparty->getSalesRepresentatives($user);
+ $salerepobj = new User($this->db);
$salerepobj->fetch($salereparray[0]['id']);
- if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
+ if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
}
}
if ($notetoshow)
{
- $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
+ $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
@@ -330,20 +328,20 @@ class pdf_standard extends ModeleExpenseReport
$tab_top = 95;
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxpiece-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxpiece - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
$nexY = $pdf->GetY();
- $height_note=$nexY-$tab_top;
+ $height_note = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
$tab_height = $tab_height - $height_note;
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
}
else
{
- $height_note=0;
+ $height_note = 0;
}
$iniY = $tab_top + 7;
@@ -351,41 +349,45 @@ class pdf_standard extends ModeleExpenseReport
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0 ; $i < $nblines ; $i++) {
- $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
+ for ($i = 0; $i < $nblines; $i++) {
+ $pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
$pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore = $pdf->getPage();
$curY = $nexY;
$pdf->startTransaction();
$this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) {
// There is a pagebreak
$pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
$this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
$pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
// There is no space left for total+free text
- if ($i == ($nblines-1)) {
+ if ($i == ($nblines - 1)) {
// No more lines, and no space left to show total, so we create a new page
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposafter+1);
+ $pdf->setPage($pageposafter + 1);
}
}
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
@@ -415,7 +417,7 @@ class pdf_standard extends ModeleExpenseReport
// }
//$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3); // Add space between lines
- $nexY += ($pdf->getFontSize()*1.3); // Add space between lines
+ $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -511,31 +513,31 @@ class pdf_standard extends ModeleExpenseReport
// Add pdfgeneration hook
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
- if (! empty($conf->global->MAIN_UMASK))
+ if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
- return 1; // No error
+ return 1; // No error
}
else
{
- $this->error=$langs->trans("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return 0;
}
}
else
{
- $this->error=$langs->trans("ErrorConstantNotDefined", "EXPENSEREPORT_OUTPUTDIR");
+ $this->error = $langs->trans("ErrorConstantNotDefined", "EXPENSEREPORT_OUTPUTDIR");
return 0;
}
}
@@ -574,8 +576,10 @@ class pdf_standard extends ModeleExpenseReport
}
$expensereporttypecode = $object->lines[$linenumber]->type_fees_code;
- $expensereporttypecodetoshow = $outputlangs->trans($expensereporttypecode);
- if ($expensereporttypecodetoshow == $expensereporttypecode) {
+ $expensereporttypecodetoshow = ($outputlangs->trans(($expensereporttypecode)) == $expensereporttypecode ? $object->lines[$linenumber]->type_fees_libelle : $outputlangs->trans($expensereporttypecode));
+
+
+ if ($expensereporttypecodetoshow == $expensereporttypecode) {
$expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow);
}
//$expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9);
@@ -594,30 +598,30 @@ class pdf_standard extends ModeleExpenseReport
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
$vat_rate = pdf_getlinevatrate($object, $linenumber, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxtva, $curY);
- $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 4, $vat_rate, 0, 'R');
+ $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0, 'R');
}
// Unit price
$pdf->SetXY($this->posxup, $curY);
- $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R');
+ $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R');
// Quantity
$pdf->SetXY($this->posxqty, $curY);
- $pdf->MultiCell($this->postotalttc-$this->posxqty-0.8, 4, $object->lines[$linenumber]->qty, 0, 'R');
+ $pdf->MultiCell($this->postotalttc - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R');
// Total with all taxes
- $pdf->SetXY($this->postotalttc-1, $curY);
- $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R');
+ $pdf->SetXY($this->postotalttc - 1, $curY);
+ $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R');
// Comments
$pdf->SetXY($this->posxcomment, $curY);
- $comment = $outputlangs->trans("Date").':'. dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' ';
- $comment .= $outputlangs->trans("Type").':'. $expensereporttypecodetoshow.' ';
- if (! empty($object->lines[$linenumber]->projet_ref)) {
- $comment .= $outputlangs->trans("Project").':'. $object->lines[$linenumber]->projet_ref.' ';
+ $comment = $outputlangs->trans("Date").':'.dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' ';
+ $comment .= $outputlangs->trans("Type").':'.$expensereporttypecodetoshow.' ';
+ if (!empty($object->lines[$linenumber]->projet_ref)) {
+ $comment .= $outputlangs->trans("Project").':'.$object->lines[$linenumber]->projet_ref.' ';
}
$comment .= $object->lines[$linenumber]->comments;
- $pdf->writeHTMLCell($this->posxtva-$this->posxcomment-0.8, 4, $this->posxcomment-1, $curY, $comment, 0, 1);
+ $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@@ -753,96 +757,96 @@ class pdf_standard extends ModeleExpenseReport
// Show sender information
if (empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
- $pdf->SetXY($posx+2, $posy+8);
+ $pdf->SetXY($posx + 2, $posy + 8);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
} else {
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset(dolGetFirstLastname($receiver->firstname, $receiver->lastname)), 0, 'L');
- $pdf->SetXY($posx+2, $posy+8);
+ $pdf->SetXY($posx + 2, $posy + 8);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(80, 4, $expense_receiver, 0, 'L');
}
// Show recipient
- $posy=50;
- $posx=100;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ $posy = 50;
+ $posx = 100;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
// Show recipient frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', 'B', 8);
- $pdf->SetXY($posx, $posy-5);
+ $pdf->SetXY($posx, $posy - 5);
$pdf->MultiCell(80, 5, $outputlangs->transnoentities("TripNDF")." :", 0, 'L');
$pdf->rect($posx, $posy, $this->page_largeur - $this->marge_gauche - $posx, $hautcadre);
// Informations for trip (dates and users workflow)
if ($object->fk_user_author > 0) {
- $userfee=new User($this->db);
+ $userfee = new User($this->db);
$userfee->fetch($object->fk_user_author);
- $posy+=3;
- $pdf->SetXY($posx+2, $posy);
+ $posy += 3;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->SetFont('', '', 10);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHOR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L');
- $posy+=5;
- $pdf->SetXY($posx+2, $posy);
+ $posy += 5;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create, "day", false, $outputlangs), 0, 'L');
}
- if ($object->fk_statut==99) {
+ if ($object->fk_statut == 99) {
if ($object->fk_user_refuse > 0) {
- $userfee=new User($this->db);
- $userfee->fetch($object->fk_user_refuse); $posy+=6;
- $pdf->SetXY($posx+2, $posy);
+ $userfee = new User($this->db);
+ $userfee->fetch($object->fk_user_refuse); $posy += 6;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L');
- $posy+=5;
- $pdf->SetXY($posx+2, $posy);
+ $posy += 5;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_REFUS")." : ".$outputlangs->convToOutputCharset($object->detail_refuse), 0, 'L');
- $posy+=5;
- $pdf->SetXY($posx+2, $posy);
+ $posy += 5;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_REFUS")." : ".dol_print_date($object->date_refuse, "day", false, $outputlangs), 0, 'L');
}
}
- elseif($object->fk_statut==4)
+ elseif ($object->fk_statut == 4)
{
if ($object->fk_user_cancel > 0) {
- $userfee=new User($this->db);
- $userfee->fetch($object->fk_user_cancel); $posy+=6;
- $pdf->SetXY($posx+2, $posy);
+ $userfee = new User($this->db);
+ $userfee->fetch($object->fk_user_cancel); $posy += 6;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L');
- $posy+=5;
- $pdf->SetXY($posx+2, $posy);
+ $posy += 5;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("MOTIF_CANCEL")." : ".$outputlangs->convToOutputCharset($object->detail_cancel), 0, 'L');
- $posy+=5;
- $pdf->SetXY($posx+2, $posy);
+ $posy += 5;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_CANCEL")." : ".dol_print_date($object->date_cancel, "day", false, $outputlangs), 0, 'L');
}
}
else
{
if ($object->fk_user_approve > 0) {
- $userfee=new User($this->db);
- $userfee->fetch($object->fk_user_approve); $posy+=6;
- $pdf->SetXY($posx+2, $posy);
+ $userfee = new User($this->db);
+ $userfee->fetch($object->fk_user_approve); $posy += 6;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L');
- $posy+=5;
- $pdf->SetXY($posx+2, $posy);
+ $posy += 5;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateApprove")." : ".dol_print_date($object->date_approve, "day", false, $outputlangs), 0, 'L');
}
}
- if($object->fk_statut==6) {
+ if ($object->fk_statut == 6) {
if ($object->fk_user_paid > 0) {
- $userfee=new User($this->db);
- $userfee->fetch($object->fk_user_paid); $posy+=6;
- $pdf->SetXY($posx+2, $posy);
+ $userfee = new User($this->db);
+ $userfee->fetch($object->fk_user_paid); $posy += 6;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L');
- $posy+=5;
- $pdf->SetXY($posx+2, $posy);
+ $posy += 5;
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell(96, 4, $outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement, "day", false, $outputlangs), 0, 'L');
}
}
@@ -878,31 +882,31 @@ class pdf_standard extends ModeleExpenseReport
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top -4);
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 4), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
$pdf->SetDrawColor(128, 128, 128);
// Rect takes a length in 3rd parameter
- $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
+ $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height);
// line prend une position y en 3eme param
if (empty($hidetop)) {
- $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
+ $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
}
$pdf->SetFont('', '', 8);
// Accountancy piece
if (empty($hidetop)) {
- $pdf->SetXY($this->posxpiece-1, $tab_top+1);
- $pdf->MultiCell($this->posxcomment-$this->posxpiece-1, 1, '', '', 'R');
+ $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
+ $pdf->MultiCell($this->posxcomment - $this->posxpiece - 1, 1, '', '', 'R');
}
// Comments
- $pdf->line($this->posxcomment-1, $tab_top, $this->posxcomment-1, $tab_top + $tab_height);
+ $pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
- $pdf->SetXY($this->posxcomment-1, $tab_top+1);
- $pdf->MultiCell($this->posxdate-$this->posxcomment-1, 1, $outputlangs->transnoentities("Description"), '', 'L');
+ $pdf->SetXY($this->posxcomment - 1, $tab_top + 1);
+ $pdf->MultiCell($this->posxdate - $this->posxcomment - 1, 1, $outputlangs->transnoentities("Description"), '', 'L');
}
// Date
@@ -933,32 +937,32 @@ class pdf_standard extends ModeleExpenseReport
// VAT
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
- $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
+ $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
- $pdf->SetXY($this->posxtva-1, $tab_top+1);
- $pdf->MultiCell($this->posxup-$this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C');
+ $pdf->SetXY($this->posxtva - 1, $tab_top + 1);
+ $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C');
}
}
// Unit price
- $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
+ $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
- $pdf->SetXY($this->posxup-1, $tab_top+1);
- $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceU"), '', 'C');
+ $pdf->SetXY($this->posxup - 1, $tab_top + 1);
+ $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceU"), '', 'C');
}
// Quantity
- $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
+ $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
- $pdf->SetXY($this->posxqty-1, $tab_top+1);
- $pdf->MultiCell($this->postotalttc-$this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
+ $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
+ $pdf->MultiCell($this->postotalttc - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
// Total with all taxes
$pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
if (empty($hidetop)) {
- $pdf->SetXY($this->postotalttc-1, $tab_top+1);
- $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R');
+ $pdf->SetXY($this->postotalttc - 1, $tab_top + 1);
+ $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R');
}
$pdf->SetTextColor(0, 0, 0);
@@ -985,94 +989,94 @@ class pdf_standard extends ModeleExpenseReport
$default_font_size = pdf_getPDFFontSize($outputlangs);
- $title=$outputlangs->transnoentities("PaymentsAlreadyDone");
+ $title = $outputlangs->transnoentities("PaymentsAlreadyDone");
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($tab3_posx, $tab3_top - 4);
$pdf->SetTextColor(0, 0, 0);
$pdf->MultiCell(60, 3, $title, 0, 'L', 0);
- $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width+2, $tab3_top); // Top border line of table title
+ $pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width + 2, $tab3_top); // Top border line of table title
- $pdf->SetXY($tab3_posx, $tab3_top+1);
+ $pdf->SetXY($tab3_posx, $tab3_top + 1);
$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Date"), 0, 'L', 0);
- $pdf->SetXY($tab3_posx+19, $tab3_top+1); // Old value 17
+ $pdf->SetXY($tab3_posx + 19, $tab3_top + 1); // Old value 17
$pdf->MultiCell(15, 3, $outputlangs->transnoentities("Amount"), 0, 'C', 0);
- $pdf->SetXY($tab3_posx+35, $tab3_top+1);
+ $pdf->SetXY($tab3_posx + 35, $tab3_top + 1);
$pdf->MultiCell(30, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
- if (! empty($conf->banque->enabled)) {
- $pdf->SetXY($tab3_posx+65, $tab3_top+1);
+ if (!empty($conf->banque->enabled)) {
+ $pdf->SetXY($tab3_posx + 65, $tab3_top + 1);
$pdf->MultiCell(25, 3, $outputlangs->transnoentities("BankAccount"), 0, 'L', 0);
}
- $pdf->line($tab3_posx, $tab3_top+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$tab3_height); // Bottom border line of table title
+ $pdf->line($tab3_posx, $tab3_top + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $tab3_height); // Bottom border line of table title
- $y=0;
+ $y = 0;
// Loop on each payment
// TODO create method on expensereport class to get payments
// Payments already done (from payment on this expensereport)
$sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
- $sql.= "c.code as p_code, c.libelle as payment_type,";
- $sql.= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
- $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id";
- $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid';
- $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid';
- $sql.= " WHERE e.rowid = '".$object->id."'";
- $sql.= " AND p.fk_expensereport = e.rowid";
- $sql.= ' AND e.entity IN ('.getEntity('expensereport').')';
- $sql.= " ORDER BY dp";
+ $sql .= "c.code as p_code, c.libelle as payment_type,";
+ $sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
+ $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id";
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
+ $sql .= " WHERE e.rowid = '".$object->id."'";
+ $sql .= " AND p.fk_expensereport = e.rowid";
+ $sql .= ' AND e.entity IN ('.getEntity('expensereport').')';
+ $sql .= " ORDER BY dp";
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$totalpaid = 0;
- $i=0;
+ $i = 0;
while ($i < $num) {
- $y+=$tab3_height;
+ $y += $tab3_height;
$row = $this->db->fetch_object($resql);
- $pdf->SetXY($tab3_posx, $tab3_top+$y+1);
+ $pdf->SetXY($tab3_posx, $tab3_top + $y + 1);
$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->dp), 'day', false, $outputlangs, true), 0, 'L', 0);
- $pdf->SetXY($tab3_posx+17, $tab3_top+$y+1);
+ $pdf->SetXY($tab3_posx + 17, $tab3_top + $y + 1);
$pdf->MultiCell(15, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'R', 0);
- $pdf->SetXY($tab3_posx+35, $tab3_top+$y+1);
- $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->p_code);
+ $pdf->SetXY($tab3_posx + 35, $tab3_top + $y + 1);
+ $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->p_code);
$pdf->MultiCell(40, 3, $oper, 0, 'L', 0);
- if (! empty($conf->banque->enabled)) {
- $pdf->SetXY($tab3_posx+65, $tab3_top+$y+1);
+ if (!empty($conf->banque->enabled)) {
+ $pdf->SetXY($tab3_posx + 65, $tab3_top + $y + 1);
$pdf->MultiCell(30, 3, $row->baref, 0, 'L', 0);
}
- $pdf->line($tab3_posx, $tab3_top+$y+$tab3_height, $tab3_posx+$tab3_width+2, $tab3_top+$y+$tab3_height); // Bottom line border of table
+ $pdf->line($tab3_posx, $tab3_top + $y + $tab3_height, $tab3_posx + $tab3_width + 2, $tab3_top + $y + $tab3_height); // Bottom line border of table
$totalpaid += $row->amount;
$i++;
}
if ($num > 0 && $object->paid == 0)
{
- $y+=$tab3_height;
+ $y += $tab3_height;
- $pdf->SetXY($tab3_posx+17, $tab3_top+$y);
+ $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
$pdf->MultiCell(15, 3, price($totalpaid), 0, 'R', 0);
- $pdf->SetXY($tab3_posx+35, $tab3_top+$y);
+ $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
$pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("AlreadyPaid"), 0, 'L', 0);
- $y+=$tab3_height-2;
- $pdf->SetXY($tab3_posx+17, $tab3_top+$y);
+ $y += $tab3_height - 2;
+ $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
$pdf->MultiCell(15, 3, price($object->total_ttc), 0, 'R', 0);
- $pdf->SetXY($tab3_posx+35, $tab3_top+$y);
+ $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
$pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("AmountExpected"), 0, 'L', 0);
- $y+=$tab3_height-2;
+ $y += $tab3_height - 2;
$remaintopay = $object->total_ttc - $totalpaid;
- $pdf->SetXY($tab3_posx+17, $tab3_top+$y);
+ $pdf->SetXY($tab3_posx + 17, $tab3_top + $y);
$pdf->MultiCell(15, 3, price($remaintopay), 0, 'R', 0);
- $pdf->SetXY($tab3_posx+35, $tab3_top+$y);
+ $pdf->SetXY($tab3_posx + 35, $tab3_top + $y);
$pdf->MultiCell(30, 4, $outputlangs->transnoentitiesnoconv("RemainderToPay"), 0, 'L', 0);
}
}
else
{
- $this->error=$this->db->lasterror();
+ $this->error = $this->db->lasterror();
return -1;
}
}
diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php
deleted file mode 100644
index 43cb4d6e9cd..00000000000
--- a/htdocs/core/modules/export/export_excel.modules.php
+++ /dev/null
@@ -1,526 +0,0 @@
-
- * Copyright (C) 2012 Marcos García
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/core/modules/export/export_excel.modules.php
- * \ingroup export
- * \brief File of class to generate export file with Excel format
- */
-
-require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-
-
-/**
- * Class to build export files with Excel format
- */
-class ExportExcel extends ModeleExports
-{
- /**
- * @var string ID
- */
- public $id;
-
- /**
- * @var string Export Excel label
- */
- public $label;
-
- public $extension;
-
- /**
- * Dolibarr version of the loaded document
- * @var string
- */
- public $version = 'dolibarr';
-
- public $label_lib;
-
- public $version_lib;
-
- public $workbook; // Handle file
-
- public $worksheet; // Handle sheet
-
- public $row;
-
- public $col;
-
- public $file; // To save filename
-
-
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- public function __construct($db)
- {
- global $conf, $langs;
- $this->db = $db;
-
- $this->id='excel'; // Same value then xxx in file name export_xxx.modules.php
- $this->label='Excel 95 (old library)'; // Label of driver
- $this->desc = $langs->trans('Excel95FormatDesc');
- $this->extension='xls'; // Extension for generated file by this driver
- $this->picto='mime/xls'; // Picto
- $this->version='1.30'; // Driver version
-
- $this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages)
-
- if (empty($this->disabled))
- {
- // If driver use an external library, put its name here
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
- {
- require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
- require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
- require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
- $this->label_lib='PhpWriteExcel';
- $this->version_lib='unknown';
- }
- else
- {
- require_once PHPEXCEL_PATH.'PHPExcel.php';
- require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
- $this->label_lib='PhpExcel';
- $this->version_lib='1.8.0'; // No way to get info from library
- }
- }
-
- $this->row=0;
- }
-
- /**
- * getDriverId
- *
- * @return string
- */
- public function getDriverId()
- {
- return $this->id;
- }
-
- /**
- * getDriverLabel
- *
- * @return string Return driver label
- */
- public function getDriverLabel()
- {
- return $this->label;
- }
-
- /**
- * getDriverDesc
- *
- * @return string
- */
- public function getDriverDesc()
- {
- return $this->desc;
- }
-
- /**
- * getDriverExtension
- *
- * @return string
- */
- public function getDriverExtension()
- {
- return $this->extension;
- }
-
- /**
- * getDriverVersion
- *
- * @return string
- */
- public function getDriverVersion()
- {
- return $this->version;
- }
-
- /**
- * getLibLabel
- *
- * @return string
- */
- public function getLibLabel()
- {
- return $this->label_lib;
- }
-
- /**
- * getLibVersion
- *
- * @return string
- */
- public function getLibVersion()
- {
- return $this->version_lib;
- }
-
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Open output file
- *
- * @param string $file File name to generate
- * @param Translate $outputlangs Output language object
- * @return int <0 if KO, >=0 if OK
- */
- public function open_file($file, $outputlangs)
- {
- // phpcs:enable
- global $user,$conf,$langs;
-
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
- {
- $outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
- }
-
- dol_syslog(get_class($this)."::open_file file=".$file);
- $this->file=$file;
-
- $ret=1;
-
- $outputlangs->load("exports");
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) {
- require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
- require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
- require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
- $this->workbook = new writeexcel_workbookbig($file);
- $this->workbook->set_tempdir($conf->export->dir_temp); // Set temporary directory
- $this->workbook->set_sheetname($outputlangs->trans("Sheet"));
- $this->worksheet = &$this->workbook->addworksheet();
- }
- else
- {
- require_once PHPEXCEL_PATH.'PHPExcel.php';
- require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
-
- if ($this->id == 'excel2007')
- {
- if (! class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive
- {
- $langs->load("errors");
- $this->error=$langs->trans('ErrorPHPNeedModule', 'zip');
- return -1;
- }
- }
-
- if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) {
- $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
- $cacheSettings = array (
- 'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR
- );
- PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
- }
-
- $this->workbook = new PHPExcel();
- $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs).' - '.DOL_APPLICATION_TITLE.' '.DOL_VERSION);
- //$this->workbook->getProperties()->setLastModifiedBy('Dolibarr '.DOL_VERSION);
- $this->workbook->getProperties()->setTitle(basename($file));
- $this->workbook->getProperties()->setSubject(basename($file));
- $this->workbook->getProperties()->setDescription(DOL_APPLICATION_TITLE.' '.DOL_VERSION);
-
- $this->workbook->setActiveSheetIndex(0);
- $this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet"));
- $this->workbook->getActiveSheet()->getDefaultRowDimension()->setRowHeight(16);
- }
- return $ret;
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Write header
- *
- * @param Translate $outputlangs Object lang to translate values
- * @return int <0 if KO, >0 if OK
- */
- public function write_header($outputlangs)
- {
- // phpcs:enable
- //$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
-
- return 0;
- }
-
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Output title line into file
- *
- * @param array $array_export_fields_label Array with list of label of fields
- * @param array $array_selected_sorted Array with list of field to export
- * @param Translate $outputlangs Object lang to translate values
- * @param array $array_types Array with types of fields
- * @return int <0 if KO, >0 if OK
- */
- public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types)
- {
- // phpcs:enable
- global $conf;
-
- // Create a format for the column headings
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
- {
- $outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
-
- $formatheader =$this->workbook->addformat();
- $formatheader->set_bold();
- $formatheader->set_color('blue');
- //$formatheader->set_size(12);
- //$formatheader->set_font("Courier New");
- //$formatheader->set_align('center');
- }
- else
- {
- $this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true);
- $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
- }
-
- $this->col=0;
- foreach($array_selected_sorted as $code => $value)
- {
- $alias=$array_export_fields_label[$code];
- //print "dd".$alias;
- if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
- {
- $this->worksheet->write($this->row, $this->col, $outputlangs->transnoentities($alias), $formatheader);
- }
- else
- {
- $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $outputlangs->transnoentities($alias));
- if (! empty($array_types[$code]) && in_array($array_types[$code], array('Date','Numeric','TextAuto'))) // Set autowidth for some types
- {
- $this->workbook->getActiveSheet()->getColumnDimension($this->column2Letter($this->col + 1))->setAutoSize(true);
- }
- }
- $this->col++;
- }
- $this->row++;
- return 0;
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Output record line into file
- *
- * @param array $array_selected_sorted Array with list of field to export
- * @param resource $objp A record from a fetch with all fields from select
- * @param Translate $outputlangs Object lang to translate values
- * @param array $array_types Array with types of fields
- * @return int <0 if KO, >0 if OK
- */
- public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types)
- {
- // phpcs:enable
- global $conf;
-
- // Create a format for the column headings
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
- {
- $outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO
- }
-
- // Define first row
- $this->col=0;
-
- $reg=array();
-
- foreach($array_selected_sorted as $code => $value)
- {
- if (strpos($code, ' as ') == 0) $alias=str_replace(array('.','-','(',')'), '_', $code);
- else $alias=substr($code, strpos($code, ' as ') + 4);
- if (empty($alias)) dol_print_error('', 'Bad value for field with code='.$code.'. Try to redefine export.');
- $newvalue=$objp->$alias;
-
- $newvalue=$this->excel_clean($newvalue);
- $typefield=isset($array_types[$code])?$array_types[$code]:'';
-
- if (preg_match('/^Select:/i', $typefield, $reg) && $typefield = substr($typefield, 7))
- {
- $array = unserialize($typefield);
- $array = $array['options'];
- $newvalue = $array[$newvalue];
- }
-
- // Traduction newvalue
- if (preg_match('/^\((.*)\)$/i', $newvalue, $reg))
- {
- $newvalue=$outputlangs->transnoentities($reg[1]);
- }
- else
- {
- $newvalue=$outputlangs->convToOutputCharset($newvalue);
- }
-
- if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i', $newvalue))
- {
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
- {
- $formatdate=$this->workbook->addformat();
- $formatdate->set_num_format('yyyy-mm-dd');
- //$formatdate->set_num_format(0x0f);
- $arrayvalue=preg_split('/[.,]/', xl_parse_date($newvalue));
- //print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).' ';
- $newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
- $this->worksheet->write($this->row, $this->col, $newvalue, PHPExcel_Shared_Date::PHPToExcel($formatdate));
- }
- else
- {
- $newvalue=dol_stringtotime($newvalue);
- $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
- $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
- $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd');
- }
- }
- elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i', $newvalue))
- {
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
- {
- $formatdatehour=$this->workbook->addformat();
- $formatdatehour->set_num_format('yyyy-mm-dd hh:mm:ss');
- //$formatdatehour->set_num_format(0x0f);
- $arrayvalue=preg_split('/[.,]/', xl_parse_date($newvalue));
- //print "x".$arrayvalue[0].'.'.strval($arrayvalue[1]).' ';
- $newvalue=strval($arrayvalue[0]).'.'.strval($arrayvalue[1]); // $newvalue=strval(36892.521); directly does not work because . will be convert into , later
- $this->worksheet->write($this->row, $this->col, $newvalue, $formatdatehour);
- }
- else
- {
- $newvalue=dol_stringtotime($newvalue);
- $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, PHPExcel_Shared_Date::PHPToExcel($newvalue));
- $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
- $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss');
- }
- }
- else
- {
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
- {
- $this->worksheet->write($this->row, $this->col, $newvalue);
- }
- else
- {
- if ($typefield == 'Text' || $typefield == 'TextAuto')
- {
- //$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING);
- $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue);
- $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate();
- $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@');
- $this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
- }
- else
- {
- $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue);
- }
- }
- }
- $this->col++;
- }
- $this->row++;
- return 0;
- }
-
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Write footer
- *
- * @param Translate $outputlangs Output language object
- * @return int <0 if KO, >0 if OK
- */
- public function write_footer($outputlangs)
- {
- // phpcs:enable
- return 0;
- }
-
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Close Excel file
- *
- * @return int <0 if KO, >0 if OK
- */
- public function close_file()
- {
- // phpcs:enable
- global $conf;
-
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
- {
- $this->workbook->close();
- }
- else
- {
- require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
- $objWriter = new PHPExcel_Writer_Excel5($this->workbook);
- $objWriter->save($this->file);
- $this->workbook->disconnectWorksheets();
- unset($this->workbook);
- }
- return 1;
- }
-
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Clean a cell to respect rules of Excel file cells
- *
- * @param string $newvalue String to clean
- * @return string Value cleaned
- */
- public function excel_clean($newvalue)
- {
- // phpcs:enable
- // Rule Dolibarr: No HTML
- $newvalue=dol_string_nohtmltag($newvalue);
-
- return $newvalue;
- }
-
-
- /**
- * Convert a column to letter (1->A, 0->B, 27->AA, ...)
- *
- * @param int $c Column position
- * @return string Letter
- */
- public function column2Letter($c)
- {
-
- $c = intval($c);
- $letter = '';
- if ($c <= 0) {
- return '';
- }
-
- while ($c != 0) {
- $p = ($c - 1) % 26;
- $c = intval(($c - $p) / 26);
- $letter = chr(65 + $p) . $letter;
- }
-
- return $letter;
- }
-}
diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php
deleted file mode 100644
index ac9eb3ddfe6..00000000000
--- a/htdocs/core/modules/export/export_excel2007.modules.php
+++ /dev/null
@@ -1,135 +0,0 @@
-
- * Copyright (C) 2012 Marcos García
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * \file htdocs/core/modules/export/export_excel2007.modules.php
- * \ingroup export
- * \brief File of class to generate export file with Excel format
- */
-
-require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
-require_once DOL_DOCUMENT_ROOT.'/core/modules/export/export_excel.modules.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-
-
-/**
- * Class to build export files with Excel format
- */
-class ExportExcel2007 extends ExportExcel
-{
- /**
- * @var string ID
- */
- public $id;
-
- /**
- * @var string label
- */
- public $label;
-
- public $extension;
-
- /**
- * Dolibarr version of the loaded document
- * @var string
- */
- public $version = 'dolibarr';
-
- public $label_lib;
-
- public $version_lib;
-
- public $workbook; // Handle fichier
-
- public $worksheet; // Handle onglet
-
- public $row;
-
- public $col;
-
- public $file; // To save filename
-
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- public function __construct($db)
- {
- global $conf, $langs;
- $this->db = $db;
-
- $this->id='excel2007'; // Same value then xxx in file name export_xxx.modules.php
- $this->label='Excel 2007 (old library)'; // Label of driver
- $this->desc = $langs->trans('Excel2007FormatDesc');
- $this->extension='xlsx'; // Extension for generated file by this driver
- $this->picto='mime/xls'; // Picto
- $this->version='1.30'; // Driver version
-
- $this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages)
-
- if (empty($this->disabled))
- {
- // If driver use an external library, put its name here
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
- {
- require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php';
- require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php';
- require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php';
- $this->label_lib='PhpWriteExcel';
- $this->version_lib='unknown';
- }
- else
- {
- require_once PHPEXCEL_PATH.'PHPExcel.php';
- require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php';
- $this->label_lib='PhpExcel';
- $this->version_lib='1.8.0'; // No way to get info from library
- }
- }
-
- $this->row=0;
- }
-
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Close Excel file
- *
- * @return int <0 if KO, >0 if OK
- */
- public function close_file()
- {
- // phpcs:enable
- global $conf;
-
- if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL))
- {
- $this->workbook->close();
- }
- else
- {
- require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php';
- $objWriter = new PHPExcel_Writer_Excel2007($this->workbook);
- $objWriter->save($this->file);
- $this->workbook->disconnectWorksheets();
- unset($this->workbook);
- }
- return 1;
- }
-}
diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
index ef05b9b2df9..01070a6a6c7 100644
--- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
+++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php
@@ -41,7 +41,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
{
/**
* Issuer
- * @var Company object that emits
+ * @var Societe Object that emits
*/
public $emetteur;
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 64aa3c52e25..7154fcc5836 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -117,7 +117,7 @@ class pdf_crabe extends ModelePDFFactures
/**
* Issuer
- * @var Societe object that emits
+ * @var Societe Object that emits
*/
public $emetteur;
@@ -171,8 +171,6 @@ class pdf_crabe extends ModelePDFFactures
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 1; // Support add of a watermark on drafts
- $this->franchise = !$mysoc->tva_assuj;
-
// Get source company
$this->emetteur = $mysoc;
if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
@@ -494,7 +492,12 @@ class pdf_crabe extends ModelePDFFactures
$pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
- $showpricebeforepagebreak = 0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
if (isset($imglinesize['width']) && isset($imglinesize['height']))
@@ -534,7 +537,12 @@ class pdf_crabe extends ModelePDFFactures
else
{
// We found a page break
- $showpricebeforepagebreak = 0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
@@ -903,6 +911,8 @@ class pdf_crabe extends ModelePDFFactures
$i++;
}
+
+ return $tab3_top + $y + 3;
}
else
{
@@ -965,14 +975,14 @@ class pdf_crabe extends ModelePDFFactures
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{
// phpcs:enable
- global $conf;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
{
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1040,13 +1050,28 @@ class pdf_crabe extends ModelePDFFactures
$lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
+ // Show online payment link
+ $useonlinepayment = ((!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)) && !empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT));
+ if (($object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') && $object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+ global $langs;
+
+ $langs->loadLangs(array('payment', 'paybox'));
+ $servicename = $langs->transnoentities('Online');
+ $paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, '', '', '');
+ $linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' '.$outputlangs->transnoentities("ClickHere").' ';
+
+ $pdf->writeHTMLCell(80, 10, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
+ }
+
+
$posy = $pdf->GetY() + 2;
}
// Show payment mode CHQ
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
{
- // If unregulated or forced payment mode to CHQ
+ // If payment mode unregulated or payment mode forced to CHQ
if (!empty($conf->global->FACTURE_CHQ_NUMBER))
{
$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
@@ -1619,7 +1644,7 @@ class pdf_crabe extends ModelePDFFactures
if ($this->emetteur->logo)
{
$logodir = $conf->mycompany->dir_output;
- if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
@@ -1682,6 +1707,30 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
+ }
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
+ }
+ }
+
$objectidnext = $object->getIdReplacingInvoice('validated');
if ($object->type == 0 && $objectidnext)
{
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index 3e00e2cab68..4fb6a55362e 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -78,7 +78,7 @@ class pdf_sponge extends ModelePDFFactures
* Dolibarr version of the loaded document
* @var string
*/
- public $version = 'development';
+ public $version = 'dolibarr';
/**
* @var int page_largeur
@@ -117,7 +117,7 @@ class pdf_sponge extends ModelePDFFactures
/**
* Issuer
- * @var Societe
+ * @var Societe Object that emits
*/
public $emetteur;
@@ -147,50 +147,48 @@ class pdf_sponge extends ModelePDFFactures
$this->db = $db;
$this->name = "sponge";
$this->description = $langs->trans('PDFSpongeDescription');
- $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
+ $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
// Dimension page
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
+ $formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+ $this->format = array($this->page_largeur, $this->page_hauteur);
+ $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
+ $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
+ $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
+ $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
- $this->option_logo = 1; // Display logo
- $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
- $this->option_modereg = 1; // Display payment mode
- $this->option_condreg = 1; // Display payment terms
- $this->option_codeproduitservice = 1; // Display product-service code
- $this->option_multilang = 1; // Available in several languages
- $this->option_escompte = 1; // Displays if there has been a discount
- $this->option_credit_note = 1; // Support credit notes
- $this->option_freetext = 1; // Support add of a personalised text
- $this->option_draft_watermark = 1; // Support add of a watermark on drafts
-
- $this->franchise=!$mysoc->tva_assuj;
+ $this->option_logo = 1; // Display logo
+ $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Display payment mode
+ $this->option_condreg = 1; // Display payment terms
+ $this->option_codeproduitservice = 1; // Display product-service code
+ $this->option_multilang = 1; // Available in several languages
+ $this->option_escompte = 1; // Displays if there has been a discount
+ $this->option_credit_note = 1; // Support credit notes
+ $this->option_freetext = 1; // Support add of a personalised text
+ $this->option_draft_watermark = 1; // Support add of a watermark on drafts
// Get source company
- $this->emetteur=$mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined
+ $this->emetteur = $mysoc;
+ if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
// Define position of columns
- $this->posxdesc=$this->marge_gauche+1; // used for notes ans other stuff
+ $this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff
$this->tabTitleHeight = 5; // default height
// Use new system for position of columns, view $this->defineColumnField()
- $this->tva=array();
- $this->localtax1=array();
- $this->localtax2=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
- $this->situationinvoice=false;
+ $this->tva = array();
+ $this->localtax1 = array();
+ $this->localtax2 = array();
+ $this->atleastoneratenotnull = 0;
+ $this->atleastonediscount = 0;
+ $this->situationinvoice = false;
}
@@ -209,50 +207,59 @@ class pdf_sponge extends ModelePDFFactures
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines;
+ global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
+
+ if (!is_object($outputlangs)) $outputlangs = $langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
- // Translations
+ // Load translation files required by the page
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ global $outputlangsbis;
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies"));
+ }
+
$nblines = count($object->lines);
- $hidetop=0;
- if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){
- $hidetop=$conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
+ $hidetop = 0;
+ if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
+ $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
}
// Loop on each lines to detect if there is at least one image to show
- $realpatharray=array();
+ $realpatharray = array();
$this->atleastonephoto = false;
- if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
+ if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
{
$objphoto = new Product($this->db);
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto->fetch($object->lines[$i]->fk_product);
//var_dump($objphoto->ref);exit;
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
- $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/";
- $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/';
+ $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
+ $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
}
else
{
- $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default
- $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; // alternative
+ $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
+ $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
}
$arephoto = false;
foreach ($pdir as $midir)
{
- if (! $arephoto)
+ if (!$arephoto)
{
$dir = $conf->product->dir_output.'/'.$midir;
@@ -319,28 +326,28 @@ class pdf_sponge extends ModelePDFFactures
if (file_exists($dir))
{
// Add pdfgeneration hook
- if (! is_object($hookmanager))
+ if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager=new HookManager($this->db);
+ $hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Set nblines with the new facture lines content after hook
$nblines = count($object->lines);
$nbpayments = count($object->getListOfPayments());
// Create pdf instance
- $pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1, 0);
- $heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part
- $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)?12:22); // Height reserved to output the footer (value include bottom margin)
+ $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
if (class_exists('TCPDF'))
{
@@ -350,14 +357,14 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
- if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
$pdf->Open();
- $pagenb=0;
+ $pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
@@ -365,9 +372,9 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
- if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Does we have at least one line with discount $this->atleastonediscount
foreach ($object->lines as $line) {
@@ -389,7 +396,7 @@ class pdf_sponge extends ModelePDFFactures
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
- $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
+ $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);
@@ -410,30 +417,30 @@ class pdf_sponge extends ModelePDFFactures
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = max($pdf->GetY(), $nexY);
- $height_incoterms=$nexY-$tab_top;
+ $height_incoterms = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
$height_incoterms += 4;
}
}
// Display notes
- $notetoshow=empty($object->note_public)?'':$object->note_public;
- if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
{
// Get first sale rep
if (is_object($object->thirdparty))
{
- $salereparray=$object->thirdparty->getSalesRepresentatives($user);
- $salerepobj=new User($this->db);
+ $salereparray = $object->thirdparty->getSalesRepresentatives($user);
+ $salerepobj = new User($this->db);
$salerepobj->fetch($salereparray[0]['id']);
- if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
+ if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
}
}
@@ -570,44 +577,49 @@ class pdf_sponge extends ModelePDFFactures
$nexY = $tab_top + $this->tabTitleHeight + 2;
// Loop on each lines
- $pageposbeforeprintlines=$pdf->getPage();
+ $pageposbeforeprintlines = $pdf->getPage();
$pagenb = $pageposbeforeprintlines;
for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
- $imglinesize=array();
- if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
+ $imglinesize = array();
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
$pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore=$pdf->getPage();
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
- $showpricebeforepagebreak=1;
- $posYAfterImage=0;
- $posYAfterDescription=0;
+ $showpricebeforepagebreak = 1;
+ $posYAfterImage = 0;
+ $posYAfterDescription = 0;
- if($this->getColumnStatus('photo'))
+ if ($this->getColumnStatus('photo'))
{
// We start with Photo of product line
- if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page
+ if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
- $pdf->setPage($pageposbefore+1);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ $pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
{
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
- $posYAfterImage=$curY+$imglinesize['height'];
+ $posYAfterImage = $curY + $imglinesize['height'];
}
}
@@ -616,51 +628,55 @@ class pdf_sponge extends ModelePDFFactures
{
$pdf->startTransaction();
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
- $posyafter=$pdf->GetY();
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
- $pdf->setPage($pageposafter+1);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ $pdf->setPage($pageposafter + 1);
}
}
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
{
$pdf->commitTransaction();
}
- $posYAfterDescription=$pdf->GetY();
+ $posYAfterDescription = $pdf->GetY();
}
$nexY = $pdf->GetY();
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description or photo were moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
// VAT Rate
if ($this->getColumnStatus('vat'))
@@ -742,86 +758,86 @@ class pdf_sponge extends ModelePDFFactures
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
} else {
- if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva;
- else $tvaligne= $sign * $object->lines[$i]->total_tva;
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $sign * $object->lines[$i]->total_tva;
}
- $localtax1ligne=$object->lines[$i]->total_localtax1;
- $localtax2ligne=$object->lines[$i]->total_localtax2;
- $localtax1_rate=$object->lines[$i]->localtax1_tx;
- $localtax2_rate=$object->lines[$i]->localtax2_tx;
- $localtax1_type=$object->lines[$i]->localtax1_type;
- $localtax2_type=$object->lines[$i]->localtax2_type;
+ $localtax1ligne = $object->lines[$i]->total_localtax1;
+ $localtax2ligne = $object->lines[$i]->total_localtax2;
+ $localtax1_rate = $object->lines[$i]->localtax1_tx;
+ $localtax2_rate = $object->lines[$i]->localtax2_tx;
+ $localtax1_type = $object->lines[$i]->localtax1_type;
+ $localtax2_type = $object->lines[$i]->localtax2_type;
- if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
+ if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
- $vatrate=(string) $object->lines[$i]->tva_tx;
+ $vatrate = (string) $object->lines[$i]->tva_tx;
// Retrieve type from database for backward compatibility with old records
- if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
- && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
+ if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
{
- $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
+ $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
$localtax1_type = $localtaxtmp_array[0];
$localtax2_type = $localtaxtmp_array[2];
}
// retrieve global local tax
if ($localtax1_type && $localtax1ligne != 0) {
- $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
+ $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
}
if ($localtax2_type && $localtax2ligne != 0) {
- $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
+ $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
}
- if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
- if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0;
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
+ if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
$this->tva[$vatrate] += $tvaligne;
$nexY = max($nexY, $posYAfterImage);
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
$pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
+ $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Add space between lines
+ $nexY += 2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter) {
$pdf->setPage($pagenb);
if ($pagenb == $pageposbeforeprintlines) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
}
else
{
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pagenb++;
$pdf->setPage($pagenb);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
- if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) {
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
if ($pagenb == $pageposafter) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
}
else
{
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
@@ -830,25 +846,25 @@ class pdf_sponge extends ModelePDFFactures
// Show square
if ($pagenb == $pageposbeforeprintlines)
{
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
else
{
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
// Display infos area
- $posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
+ $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
// Display total zone
- $posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+ $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Display payment area
if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
{
- $posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
+ $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
}
// Pagefoot
@@ -944,7 +960,7 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetFont('', '', $default_font_size - 4);
- // Loop on each deposits and credit notes included
+ // Loop on each discount available (deposits and credit notes and excess of payment included)
$sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,";
$sql .= " re.description, re.fk_facture_source,";
$sql .= " f.type, f.datef";
@@ -961,9 +977,10 @@ class pdf_sponge extends ModelePDFFactures
$y += 3;
$obj = $this->db->fetch_object($resql);
- if ($obj->type == 2) $text = $outputlangs->trans("CreditNote");
- elseif ($obj->type == 3) $text = $outputlangs->trans("Deposit");
- else $text = $outputlangs->trans("UnknownType");
+ if ($obj->type == 2) $text = $outputlangs->transnoentities("CreditNote");
+ elseif ($obj->type == 3) $text = $outputlangs->transnoentities("Deposit");
+ elseif ($obj->type == 0) $text = $outputlangs->transnoentities("ExcessReceived");
+ else $text = $outputlangs->transnoentities("UnknownType");
$invoice->fetch($obj->fk_facture_source);
@@ -1021,6 +1038,8 @@ class pdf_sponge extends ModelePDFFactures
$i++;
}
+
+ return $tab3_top + $y + 3;
}
else
{
@@ -1037,18 +1056,18 @@ class pdf_sponge extends ModelePDFFactures
* @param Object $object Object to show
* @param int $posy Y
* @param Translate $outputlangs Langs object
- * @return void
+ * @return int Pos y
*/
protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
{
- global $conf;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
{
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1113,19 +1132,33 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
+ $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
- $posy=$pdf->GetY()+2;
+ // Show online payment link
+ $useonlinepayment = ((!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)) && !empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT));
+ if (($object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') && $object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+ global $langs;
+
+ $langs->loadLangs(array('payment', 'paybox'));
+ $servicename = $langs->transnoentities('Online');
+ $paiement_url = getOnlinePaymentUrl('', 'invoice', $object->ref, '', '', '');
+ $linktopay = $langs->trans("ToOfferALinkForOnlinePayment", $servicename).' '.$outputlangs->transnoentities("ClickHere").' ';
+
+ $pdf->writeHTMLCell(80, 10, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
+ }
+
+ $posy = $pdf->GetY() + 2;
}
// Show payment mode CHQ
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
{
- // If payment mode not forced or forced to CHQ
- if (! empty($conf->global->FACTURE_CHQ_NUMBER))
+ // If payment mode unregulated or payment mode forced to CHQ
+ if (!empty($conf->global->FACTURE_CHQ_NUMBER))
{
- $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
+ $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
if ($conf->global->FACTURE_CHQ_NUMBER > 0)
{
@@ -1190,9 +1223,9 @@ class pdf_sponge extends ModelePDFFactures
/**
* Show total to pay
*
- * @param PDF $pdf Object PDF
+ * @param PDF $pdf Object PDF
* @param Facture $object Object invoice
- * @param int $deja_regle Montant deja regle
+ * @param int $deja_regle Amount already paid (in the currency of invoice)
* @param int $posy Position depart
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
@@ -1214,29 +1247,34 @@ class pdf_sponge extends ModelePDFFactures
$col1x = 120; $col2x = 170;
if ($this->page_largeur < 210) // To work with US executive format
{
- $col2x-=20;
+ $col2x -= 20;
}
$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
- $useborder=0;
+ $useborder = 0;
$index = 0;
-
+ $outputlangsbis = null;
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
+ }
// overall percentage of advancement
$percent = 0;
- $i=0;
+ $i = 0;
foreach ($object->lines as $line)
{
- if(!class_exists('TSubtotal') || !TSubtotal::isModSubtotalLine($line)){
+ if (!class_exists('TSubtotal') || !TSubtotal::isModSubtotalLine($line)) {
$percent += $line->situation_percent;
$i++;
}
}
- if(!empty($i)){
- $avancementGlobal = $percent/$i;
+ if (!empty($i)) {
+ $avancementGlobal = $percent / $i;
}
- else{
+ else {
$avancementGlobal = 0;
}
@@ -1245,18 +1283,18 @@ class pdf_sponge extends ModelePDFFactures
$total_a_payer = 0;
$total_a_payer_ttc = 0;
- foreach ($TPreviousIncoice as &$fac){
+ foreach ($TPreviousIncoice as &$fac) {
$total_a_payer += $fac->total_ht;
$total_a_payer_ttc += $fac->total_ttc;
}
$total_a_payer += $object->total_ht;
$total_a_payer_ttc += $object->total_ttc;
- if(!empty($avancementGlobal)){
+ if (!empty($avancementGlobal)) {
$total_a_payer = $total_a_payer * 100 / $avancementGlobal;
- $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
+ $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
}
- else{
+ else {
$total_a_payer = 0;
$total_a_payer_ttc = 0;
}
@@ -1268,7 +1306,7 @@ class pdf_sponge extends ModelePDFFactures
$posy = $pdf->GetY();
foreach ($TPreviousIncoice as &$fac) {
- if($posy > $this->page_hauteur - 4 ) {
+ if ($posy > $this->page_hauteur - 4) {
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pdf->addPage();
$pdf->setY($this->marge_haute);
@@ -1279,13 +1317,13 @@ class pdf_sponge extends ModelePDFFactures
$index++;
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
$pdf->SetXY($col2x, $posy);
$facSign = '';
- if ($i>1) {
- $facSign = $fac->total_ht>=0?'+':'';
+ if ($i > 1) {
+ $facSign = $fac->total_ht >= 0 ? '+' : '';
}
$displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
@@ -1302,12 +1340,12 @@ class pdf_sponge extends ModelePDFFactures
// Display current total
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
$pdf->SetXY($col2x, $posy);
$facSign = '';
- if ($i>1) {
- $facSign = $object->total_ht>=0?'+':''; // management of a particular customer case
+ if ($i > 1) {
+ $facSign = $object->total_ht >= 0 ? '+' : ''; // management of a particular customer case
}
if ($fac->type === facture::TYPE_CREDIT_NOTE) {
@@ -1324,22 +1362,22 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
$pdf->SetXY($col2x, $posy);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer*$avancementGlobal/100, 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0, 'R', 1);
$pdf->SetFont('', '', $default_font_size - 2);
$posy += $tab2_hl;
- if($posy > $this->page_hauteur - 4 ) {
+ if ($posy > $this->page_hauteur - 4) {
$pdf->addPage();
$pdf->setY($this->marge_haute);
$posy = $pdf->GetY();
}
$tab2_top = $posy;
- $index=0;
+ $index = 0;
}
$tab2_top += 3;
@@ -1348,27 +1386,27 @@ class pdf_sponge extends ModelePDFFactures
$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
// Total remise
- $total_line_remise=0;
- foreach($object->lines as $i => $line) {
- $total_line_remise+= pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib
+ $total_line_remise = 0;
+ foreach ($object->lines as $i => $line) {
+ $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib
// Gestion remise sous forme de ligne négative
- if($line->total_ht < 0) $total_line_remise += -$line->total_ht;
+ if ($line->total_ht < 0) $total_line_remise += -$line->total_ht;
}
- if($total_line_remise > 0) {
- if (! empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
+ if ($total_line_remise > 0) {
+ if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount"), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
$index++;
}
// Show total NET before discount
- if (! empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
+ if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount"), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
@@ -1379,21 +1417,22 @@ class pdf_sponge extends ModelePDFFactures
// Total HT
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
+ $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
// Show VAT by rates and total
$pdf->SetFillColor(248, 248, 248);
$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
- $this->atleastoneratenotnull=0;
+ $this->atleastoneratenotnull = 0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
- $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
+ $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
{
// Nothing to do
}
@@ -1404,29 +1443,30 @@ class pdf_sponge extends ModelePDFFactures
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
+ $totalvat .= ' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1437,28 +1477,29 @@ class pdf_sponge extends ModelePDFFactures
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
+ $totalvat .= ' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1471,12 +1512,12 @@ class pdf_sponge extends ModelePDFFactures
// Situations totals migth be wrong on huge amounts
if ($object->situation_cycle_ref && $object->situation_counter > 1) {
$sum_pdf_tva = 0;
- foreach($this->tva as $tvakey => $tvaval){
- $sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object
+ foreach ($this->tva as $tvakey => $tvaval) {
+ $sum_pdf_tva += $tvaval; // sum VAT amounts to compare to object
}
- if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one)
- if(!empty($sum_pdf_tva))
+ if ($sum_pdf_tva != $object->total_tva) { // apply coef to recover the VAT object amount (the good one)
+ if (!empty($sum_pdf_tva))
{
$coef_fix_tva = $object->total_tva / $sum_pdf_tva;
}
@@ -1485,13 +1526,13 @@ class pdf_sponge extends ModelePDFFactures
}
- foreach($this->tva as $tvakey => $tvaval) {
- $this->tva[$tvakey]=$tvaval * $coef_fix_tva;
+ foreach ($this->tva as $tvakey => $tvaval) {
+ $this->tva[$tvakey] = $tvaval * $coef_fix_tva;
}
}
}
- foreach($this->tva as $tvakey => $tvaval)
+ foreach ($this->tva as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -1506,7 +1547,8 @@ class pdf_sponge extends ModelePDFFactures
$tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
+ $totalvat .= ' ';
$totalvat .= vatrate($tvakey, 1).$tvacompl;
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
@@ -1518,11 +1560,11 @@ class pdf_sponge extends ModelePDFFactures
//Local tax 1 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -1531,16 +1573,17 @@ class pdf_sponge extends ModelePDFFactures
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
+ $totalvat .= ' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
}
@@ -1550,11 +1593,11 @@ class pdf_sponge extends ModelePDFFactures
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
// retrieve global local tax
if ($tvakey != 0) // On affiche pas taux 0
@@ -1564,16 +1607,17 @@ class pdf_sponge extends ModelePDFFactures
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
+ $totalvat .= ' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1587,7 +1631,7 @@ class pdf_sponge extends ModelePDFFactures
{
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RevenueStamp", $mysoc->country_code) : ''), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
@@ -1598,7 +1642,7 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalTTC") : ''), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
@@ -1619,36 +1663,36 @@ class pdf_sponge extends ModelePDFFactures
// Retained warranty
- if( !empty($object->situation_final) && ( $object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty) ) ) )
+ if (!empty($object->situation_final) && ($object->type == Facture::TYPE_SITUATION && (!empty($object->retained_warranty))))
{
$displayWarranty = false;
// Check if this situation invoice is 100% for real
- if(!empty($object->situation_final)){
+ if (!empty($object->situation_final)) {
$displayWarranty = true;
}
- elseif(!empty($object->lines) && $object->status == Facture::STATUS_DRAFT ){
+ elseif (!empty($object->lines) && $object->status == Facture::STATUS_DRAFT) {
// $object->situation_final need validation to be done so this test is need for draft
$displayWarranty = true;
- foreach($object->lines as $i => $line){
- if($line->product_type < 2 && $line->situation_percent < 100){
+ foreach ($object->lines as $i => $line) {
+ if ($line->product_type < 2 && $line->situation_percent < 100) {
$displayWarranty = false;
break;
}
}
}
- if($displayWarranty){
+ if ($displayWarranty) {
$pdf->SetTextColor(40, 40, 40);
$pdf->SetFillColor(255, 255, 255);
$retainedWarranty = $total_a_payer_ttc * $object->retained_warranty / 100;
- $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty ;
+ $billedWithRetainedWarranty = $object->total_ttc - $retainedWarranty;
// Billed - retained warranty
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFEVOLToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFEVOLToPayOn", dol_print_date($object->date_lim_reglement, 'day')), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($billedWithRetainedWarranty), $useborder, 'R', 1);
@@ -1657,10 +1701,10 @@ class pdf_sponge extends ModelePDFFactures
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $retainedWarrantyToPayOn = $outputlangs->transnoentities("PDFEVOLRetainedWarranty") . ' ('.$object->retained_warranty.'%)';
- $retainedWarrantyToPayOn.= !empty($object->retained_warranty_date_limit)?' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')):'';
+ $retainedWarrantyToPayOn = $outputlangs->transnoentities("PDFEVOLRetainedWarranty").' ('.$object->retained_warranty.'%)';
+ $retainedWarrantyToPayOn .= !empty($object->retained_warranty_date_limit) ? ' '.$outputlangs->transnoentities("PDFEVOLtoPayOn", dol_print_date($object->retained_warranty_date_limit, 'day')) : '';
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($retainedWarranty), $useborder, 'R', 1);
}
@@ -1670,27 +1714,29 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetTextColor(0, 0, 0);
- $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
- $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $creditnoteamount = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
+ $depositsamount = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
- if ($object->paye) $resteapayer=0;
+ if (!empty($object->paye)) $resteapayer = 0;
if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
{
// Already paid + Deposits
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("Paid") : ''), 0, 'L', 0);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
// Credit note
if ($creditnoteamount)
{
+ $labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes");
+ $labeltouse .= (is_object($outputlangsbis) ? ' / '.($outputlangsbis->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities("CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities("CreditNotes") : '');
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0, 'L', 0);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
}
@@ -1702,7 +1748,7 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("EscompteOfferedShort") : ''), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
@@ -1713,7 +1759,7 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : ''), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
@@ -1751,9 +1797,10 @@ class pdf_sponge extends ModelePDFFactures
* @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int $hidebottom Hide bottom bar of array
* @param string $currency Currency code
+ * @param Translate $outputlangsbis Langs object bis
* @return void
*/
- protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
+ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
{
global $conf;
@@ -1771,24 +1818,30 @@ class pdf_sponge extends ModelePDFFactures
if (empty($hidetop))
{
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
+ $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
+ }
+
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
- if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
+ $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ }
}
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', '', $default_font_size - 1);
// Output Rect
- $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
- if (empty($hidetop)){
- $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
+ if (empty($hidetop)) {
+ $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
}
}
@@ -1800,13 +1853,14 @@ class pdf_sponge extends ModelePDFFactures
* @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
+ * @param Translate $outputlangsbis Object lang for output bis
* @return void
*/
- protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
{
global $conf, $langs;
- // Translations
+ // Load traductions files required by page
$outputlangs->loadLangs(array("main", "bills", "propal", "companies"));
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1824,8 +1878,8 @@ class pdf_sponge extends ModelePDFFactures
$w = 110;
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-$w;
+ $posy = $this->marge_haute;
+ $posx = $this->page_largeur - $this->marge_droite - $w;
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1835,7 +1889,7 @@ class pdf_sponge extends ModelePDFFactures
if ($this->emetteur->logo)
{
$logodir = $conf->mycompany->dir_output;
- if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
@@ -1845,8 +1899,8 @@ class pdf_sponge extends ModelePDFFactures
}
if (is_readable($logo))
{
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
}
else
{
@@ -1872,6 +1926,17 @@ class pdf_sponge extends ModelePDFFactures
if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit");
if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma");
if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation");
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
+ $title .= ' - ';
+ if ($object->type == 0) {
+ if ($this->situationinvoice) $title .= $outputlangsbis->transnoentities("InvoiceSituation");
+ $title .= $outputlangsbis->transnoentities("PdfInvoiceTitle");
+ }
+ elseif ($object->type == 1) $title .= $outputlangsbis->transnoentities("InvoiceReplacement");
+ elseif ($object->type == 2) $title .= $outputlangsbis->transnoentities("InvoiceAvoir");
+ elseif ($object->type == 3) $title .= $outputlangsbis->transnoentities("InvoiceDeposit");
+ elseif ($object->type == 4) $title .= $outputlangsbis->transnoentities("InvoiceProForma");
+ }
$pdf->MultiCell($w, 3, $title, '', 'R');
$pdf->SetFont('', 'B', $default_font_size);
@@ -1898,6 +1963,30 @@ class pdf_sponge extends ModelePDFFactures
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
+ }
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
+ }
+ }
+
$objectidnext = $object->getIdReplacingInvoice('validated');
if ($object->type == 0 && $objectidnext)
{
diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php
index ba65eeeca9c..56379a0c492 100644
--- a/htdocs/core/modules/facture/modules_facture.php
+++ b/htdocs/core/modules/facture/modules_facture.php
@@ -29,7 +29,7 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required because used in classes that inherit
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required because used in classes that inherit
/**
@@ -40,7 +40,11 @@ abstract class ModelePDFFactures extends CommonDocGenerator
/**
* @var string Error code (or message)
*/
- public $error='';
+ public $error = '';
+
+ public $atleastonediscount = 0;
+ public $atleastoneratenotnull = 0;
+
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
@@ -55,11 +59,11 @@ abstract class ModelePDFFactures extends CommonDocGenerator
// phpcs:enable
global $conf;
- $type='invoice';
- $liste=array();
+ $type = 'invoice';
+ $liste = array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- $liste=getListOfModels($db, $type, $maxfilenamelength);
+ $liste = getListOfModels($db, $type, $maxfilenamelength);
return $liste;
}
@@ -73,7 +77,7 @@ abstract class ModeleNumRefFactures
/**
* @var string Error code (or message)
*/
- public $error='';
+ public $error = '';
/**
* Return if a module can be used or not
diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
index ff7bff51230..ff913d724f8 100644
--- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
+++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
@@ -108,7 +108,7 @@ class pdf_soleil extends ModelePDFFicheinter
/**
* Issuer
- * @var Company object that emits
+ * @var Societe Object that emits
*/
public $emetteur;
diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php
index e8d2aeff63e..f2f3a135785 100644
--- a/htdocs/core/modules/fichinter/mod_arctic.php
+++ b/htdocs/core/modules/fichinter/mod_arctic.php
@@ -46,7 +46,7 @@ class mod_arctic extends ModeleNumRefFicheinter
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom = 'arctic';
diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php
index 97784ce0639..3ecd3d6833d 100644
--- a/htdocs/core/modules/fichinter/mod_pacific.php
+++ b/htdocs/core/modules/fichinter/mod_pacific.php
@@ -46,7 +46,7 @@ class mod_pacific extends ModeleNumRefFicheinter
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='pacific';
diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php
index d6c43edd5c3..6c9dd9062a8 100644
--- a/htdocs/core/modules/import/import_csv.modules.php
+++ b/htdocs/core/modules/import/import_csv.modules.php
@@ -123,7 +123,7 @@ class ImportCsv extends ModeleImports
* Output header of an example file for this format
*
* @param Translate $outputlangs Output language
- * @return string
+ * @return string Empty string
*/
public function write_header_example($outputlangs)
{
@@ -137,7 +137,7 @@ class ImportCsv extends ModeleImports
*
* @param Translate $outputlangs Output language
* @param array $headerlinefields Array of fields name
- * @return string$limittoachartaccount
+ * @return string String output
*/
public function write_title_example($outputlangs, $headerlinefields)
{
@@ -152,7 +152,7 @@ class ImportCsv extends ModeleImports
*
* @param Translate $outputlangs Output language
* @param array $contentlinevalues Array of lines
- * @return string
+ * @return string String output
*/
public function write_record_example($outputlangs, $contentlinevalues)
{
@@ -166,7 +166,7 @@ class ImportCsv extends ModeleImports
* Output footer of an example file for this format
*
* @param Translate $outputlangs Output language
- * @return string
+ * @return string Empty string
*/
public function write_footer_example($outputlangs)
{
@@ -175,7 +175,6 @@ class ImportCsv extends ModeleImports
}
-
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Open input file
@@ -426,6 +425,7 @@ class ImportCsv extends ModeleImports
// New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess.
$isidorref = 'id';
if (!is_numeric($newval) && $newval != '' && !preg_match('/^id:/i', $newval)) $isidorref = 'ref';
+
$newval = preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref
//print 'Val is now '.$newval.' and is type '.$isidorref." \n";
@@ -449,8 +449,7 @@ class ImportCsv extends ModeleImports
$classinstance = new $class($this->db);
// Try the fetch from code or ref
$param_array = array('', $newval);
- if ($class == 'AccountingAccount')
- {
+ if ($class == 'AccountingAccount') {
//var_dump($arrayrecord[0]['val']);
/*include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancysystem.class.php';
$tmpchartofaccount = new AccountancySystem($this->db);
@@ -465,6 +464,7 @@ class ImportCsv extends ModeleImports
}*/
$param_array = array('', $newval, 0, $arrayrecord[0]['val']); // Param to fetch parent from account, in chart.
}
+
call_user_func_array(array($classinstance, $method), $param_array);
// If not found, try the fetch from label
if (! ($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel')
diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php
index 03b3f941a1d..09628739494 100644
--- a/htdocs/core/modules/import/import_xlsx.modules.php
+++ b/htdocs/core/modules/import/import_xlsx.modules.php
@@ -130,7 +130,7 @@ class ImportXlsx extends ModeleImports
* Output header of an example file for this format
*
* @param Translate $outputlangs Output language
- * @return string
+ * @return string Empty string
*/
public function write_header_example($outputlangs)
{
@@ -164,7 +164,7 @@ class ImportXlsx extends ModeleImports
*
* @param Translate $outputlangs Output language
* @param array $headerlinefields Array of fields name
- * @return string
+ * @return string String output
*/
public function write_title_example($outputlangs, $headerlinefields)
{
@@ -190,7 +190,7 @@ class ImportXlsx extends ModeleImports
*
* @param Translate $outputlangs Output language
* @param array $contentlinevalues Array of lines
- * @return string
+ * @return string Empty string
*/
public function write_record_example($outputlangs, $contentlinevalues)
{
@@ -210,7 +210,7 @@ class ImportXlsx extends ModeleImports
* Output footer of an example file for this format
*
* @param Translate $outputlangs Output language
- * @return string
+ * @return string String output
*/
public function write_footer_example($outputlangs)
{
@@ -258,7 +258,7 @@ class ImportXlsx extends ModeleImports
* Return nb of records. File must be closed.
*
* @param string $file Path of filename
- * @return int <0 if KO, >=0 if OK
+ * @return int <0 if KO, >=0 if OK
*/
public function import_get_nb_of_lines($file)
{
diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php
index 00268810ce8..cdbb2cd0bb7 100644
--- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php
+++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php
@@ -107,7 +107,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
/**
* Issuer
- * @var Company object that emits
+ * @var Societe Object that emits
*/
public $emetteur;
@@ -118,7 +118,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
*/
public function __construct($db)
{
- global $conf,$langs,$mysoc;
+ global $conf, $langs, $mysoc;
// Translations
$langs->loadLangs(array("main", "bills", "sendings", "companies"));
@@ -129,47 +129,45 @@ class pdf_typhon extends ModelePDFDeliveryOrder
// Page size for A4 format
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
+ $formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+ $this->format = array($this->page_largeur, $this->page_hauteur);
+ $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
+ $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
+ $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
+ $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
- $this->option_logo = 1; // Display logo FAC_PDF_LOGO
- $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
- $this->option_codeproduitservice = 1; // Display product-service code
-
- $this->franchise=!$mysoc->tva_assuj;
+ $this->option_logo = 1; // Display logo FAC_PDF_LOGO
+ $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_codeproduitservice = 1; // Display product-service code
// Get source company
- $this->emetteur=$mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined
+ $this->emetteur = $mysoc;
+ if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
// Define position of columns
- $this->posxdesc=$this->marge_gauche+1;
- $this->posxcomm=112;
+ $this->posxdesc = $this->marge_gauche + 1;
+ $this->posxcomm = 112;
//$this->posxtva=112;
//$this->posxup=126;
- $this->posxqty=165;
- $this->posxremainingqty=185;
+ $this->posxqty = 165;
+ $this->posxremainingqty = 185;
//$this->posxdiscount=162;
//$this->postotalht=174;
if ($this->page_largeur < 210) // To work with US executive format
{
- $this->posxcomm-=20;
+ $this->posxcomm -= 20;
//$this->posxtva-=20;
//$this->posxup-=20;
- $this->posxqty-=20;
+ $this->posxqty -= 20;
//$this->posxdiscount-=20;
//$this->postotalht-=20;
}
- $this->tva=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
+ $this->tva = array();
+ $this->atleastoneratenotnull = 0;
+ $this->atleastonediscount = 0;
}
@@ -188,11 +186,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$mysoc,$hookmanager;
+ global $user, $langs, $conf, $mysoc, $hookmanager;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ if (!is_object($outputlangs)) $outputlangs = $langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "sendings", "deliveries"));
@@ -205,20 +203,20 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if ($object->specimen)
{
$dir = $conf->expedition->dir_output."/receipt";
- $file = $dir . "/SPECIMEN.pdf";
+ $file = $dir."/SPECIMEN.pdf";
}
else
{
$objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->expedition->dir_output."/receipt/" . $objectref;
- $file = $dir . "/" . $objectref . ".pdf";
+ $dir = $conf->expedition->dir_output."/receipt/".$objectref;
+ $file = $dir."/".$objectref.".pdf";
}
- if (! file_exists($dir))
+ if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
@@ -226,25 +224,25 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if (file_exists($dir))
{
// Add pdfgeneration hook
- if (! is_object($hookmanager))
+ if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager=new HookManager($this->db);
+ $hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$nblines = count($object->lines);
// Create pdf instance
- $pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $heightforinfotot = 30; // Height reserved to output the info and total part
- $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $heightforinfotot = 30; // Height reserved to output the info and total part
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF'))
@@ -254,14 +252,14 @@ class pdf_typhon extends ModelePDFDeliveryOrder
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
- if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
// We get the shipment that is the origin of delivery receipt
- $expedition=new Expedition($this->db);
+ $expedition = new Expedition($this->db);
$result = $expedition->fetch($object->origin_id);
// Now we get the order that is origin of shipment
$commande = new Commande($this->db);
@@ -269,12 +267,12 @@ class pdf_typhon extends ModelePDFDeliveryOrder
{
$commande->fetch($expedition->origin_id);
}
- $object->commande=$commande; // We set order of shipment onto delivery.
+ $object->commande = $commande; // We set order of shipment onto delivery.
$object->commande->loadExpeditions();
$pdf->Open();
- $pagenb=0;
+ $pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
@@ -282,9 +280,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("DeliveryOrder"));
- if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
/*
// Positionne $this->atleastonediscount si on a au moins une remise
@@ -308,15 +306,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);
$tab_top = 90;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
@@ -330,39 +328,39 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$tab_top = 88;
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
- $height_incoterms=$nexY-$tab_top;
+ $height_incoterms = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
$height_incoterms += 4;
}
}
// Affiche notes
- if (! empty($object->note_public))
+ if (!empty($object->note_public))
{
$tab_top = 88 + $height_incoterms;
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
$nexY = $pdf->GetY();
- $height_note=$nexY-$tab_top;
+ $height_note = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
$tab_height = $tab_height - $height_note;
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
}
else
{
- $height_note=0;
+ $height_note = 0;
}
$iniY = $tab_top + 11;
@@ -370,46 +368,50 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$nexY = $tab_top + 11;
// Loop on each lines
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
$pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore=$pdf->getPage();
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
// Description of product line
- $curX = $this->posxdesc-1;
+ $curX = $this->posxdesc - 1;
- $showpricebeforepagebreak=1;
+ $showpricebeforepagebreak = 1;
$pdf->startTransaction();
- pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm-$curX, 3, $curX, $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
+ pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 3, $curX, $curY, $hideref, $hidedesc);
+ $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
- pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm-$curX, 4, $curX, $curY, $hideref, $hidedesc);
- $posyafter=$pdf->GetY();
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 4, $curX, $curY, $hideref, $hidedesc);
+ $posyafter = $pdf->GetY();
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposafter+1);
+ $pdf->setPage($pageposafter + 1);
}
}
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
@@ -418,17 +420,17 @@ class pdf_typhon extends ModelePDFDeliveryOrder
}
$nexY = $pdf->GetY();
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
/*
// TVA
@@ -447,7 +449,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
// Remaining to ship
$pdf->SetXY($this->posxremainingqty, $curY);
$qtyRemaining = $object->lines[$i]->qty_asked - $object->commande->expeditions[$object->lines[$i]->fk_origin_line];
- $pdf->MultiCell($this->page_largeur-$this->marge_droite - $this->posxremainingqty, 3, $qtyRemaining, 0, 'R');
+ $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxremainingqty, 3, $qtyRemaining, 0, 'R');
/*
// Remise sur ligne
$pdf->SetXY($this->posxdiscount, $curY);
@@ -469,16 +471,16 @@ class pdf_typhon extends ModelePDFDeliveryOrder
*/
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
+ $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Add space between lines
+ $nexY += 2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -495,10 +497,10 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pagenb++;
$pdf->setPage($pagenb);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
- if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
{
if ($pagenb == 1)
{
@@ -511,7 +513,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$this->_pagefoot($pdf, $object, $outputlangs, 1);
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
@@ -521,12 +523,12 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
// Affiche zone infos
@@ -603,36 +605,36 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->Output($file, 'F');
// Add pdfgeneration hook
- if (! is_object($hookmanager))
+ if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager=new HookManager($this->db);
+ $hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
- if (! empty($conf->global->MAIN_UMASK))
+ if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
- return 1; // No error
+ return 1; // No error
}
else
{
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
- $this->error=$langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR");
+ $this->error = $langs->transnoentities("ErrorConstantNotDefined", "LIVRAISON_OUTPUTDIR");
return 0;
}
@@ -650,19 +652,19 @@ class pdf_typhon extends ModelePDFDeliveryOrder
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{
// phpcs:enable
- global $conf,$mysoc;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('', '', $default_font_size);
$pdf->SetXY($this->marge_gauche, $posy);
- $larg_sign = ($this->page_largeur-$this->marge_gauche-$this->marge_droite)/3;
+ $larg_sign = ($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 3;
$pdf->Rect($this->marge_gauche, $posy + 1, $larg_sign, 25);
$pdf->SetXY($this->marge_gauche + 2, $posy + 2);
$pdf->MultiCell($larg_sign, 2, $outputlangs->trans("For").' '.$outputlangs->convToOutputCharset($mysoc->name).":", '', 'L');
- $pdf->Rect(2*$larg_sign+$this->marge_gauche, $posy + 1, $larg_sign, 25);
- $pdf->SetXY(2*$larg_sign+$this->marge_gauche + 2, $posy + 2);
+ $pdf->Rect(2 * $larg_sign + $this->marge_gauche, $posy + 1, $larg_sign, 25);
+ $pdf->SetXY(2 * $larg_sign + $this->marge_gauche + 2, $posy + 2);
$pdf->MultiCell($larg_sign, 2, $outputlangs->trans("ForCustomer").':', '', 'L');
}
@@ -681,11 +683,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder
*/
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
{
- global $conf,$mysoc;
+ global $conf, $mysoc;
// Force to disable hidetop and hidebottom
- $hidebottom=0;
- if ($hidetop) $hidetop=-1;
+ $hidebottom = 0;
+ if ($hidetop) $hidetop = -1;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -694,11 +696,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetFont('', '', $default_font_size - 2);
// Output Rec
- $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
if (empty($hidetop))
{
- $pdf->line($this->marge_gauche, $tab_top+10, $this->page_largeur-$this->marge_droite, $tab_top+10);
+ $pdf->line($this->marge_gauche, $tab_top + 10, $this->page_largeur - $this->marge_droite, $tab_top + 10);
}
$pdf->SetDrawColor(128, 128, 128);
@@ -706,29 +708,29 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if (empty($hidetop))
{
- $pdf->SetXY($this->posxdesc-1, $tab_top+1);
+ $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
$pdf->MultiCell($this->posxcomm - $this->posxdesc, 2, $outputlangs->transnoentities("Designation"), '', 'L');
}
// Modif SEB pour avoir une col en plus pour les commentaires clients
$pdf->line($this->posxcomm, $tab_top, $this->posxcomm, $tab_top + $tab_height);
if (empty($hidetop)) {
- $pdf->SetXY($this->posxcomm, $tab_top+1);
+ $pdf->SetXY($this->posxcomm, $tab_top + 1);
$pdf->MultiCell($this->posxqty - $this->posxcomm, 2, $outputlangs->transnoentities("Comments"), '', 'L');
}
// Qty
$pdf->line($this->posxqty, $tab_top, $this->posxqty, $tab_top + $tab_height);
if (empty($hidetop)) {
- $pdf->SetXY($this->posxqty, $tab_top+1);
+ $pdf->SetXY($this->posxqty, $tab_top + 1);
$pdf->MultiCell($this->posxremainingqty - $this->posxqty, 2, $outputlangs->transnoentities("QtyShippedShort"), '', 'R');
}
// Remain to ship
$pdf->line($this->posxremainingqty, $tab_top, $this->posxremainingqty, $tab_top + $tab_height);
if (empty($hidetop)) {
- $pdf->SetXY($this->posxremainingqty, $tab_top+1);
- $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxremainingqty, 2, $outputlangs->transnoentities("KeepToShipShort"), '', 'R');
+ $pdf->SetXY($this->posxremainingqty, $tab_top + 1);
+ $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxremainingqty, 2, $outputlangs->transnoentities("KeepToShipShort"), '', 'R');
}
}
@@ -744,14 +746,14 @@ class pdf_typhon extends ModelePDFDeliveryOrder
*/
protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
- global $conf,$langs,$hookmanager;
+ global $conf, $langs, $hookmanager;
$default_font_size = pdf_getPDFFontSize($outputlangs);
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
+ if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
{
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
}
@@ -759,19 +761,19 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-100;
+ $posy = $this->marge_haute;
+ $posx = $this->page_largeur - $this->marge_droite - 100;
$pdf->SetXY($this->marge_gauche, $posy);
// Logo
- $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
+ $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (is_readable($logo))
{
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
}
else
{
@@ -790,12 +792,12 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetFont('', '', $default_font_size + 2);
- $posy+=5;
+ $posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
if ($object->date_valid)
{
- $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_delivery, "%d %b %Y", false, $outputlangs, true), '', 'R');
+ $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date_delivery, "%d %b %Y", false, $outputlangs, true), '', 'R');
}
else
{
@@ -806,15 +808,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if ($object->thirdparty->code_client)
{
- $posy+=5;
+ $posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
}
$pdf->SetTextColor(0, 0, 60);
- $posy+=2;
+ $posy += 2;
// Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
@@ -825,15 +827,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
- $posy=42;
- $posx=$this->marge_gauche;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
- $hautcadre=40;
+ $posy = 42;
+ $posx = $this->marge_gauche;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
+ $hautcadre = 40;
// Show sender frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx, $posy-5);
+ $pdf->SetXY($posx, $posy - 5);
$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
$pdf->SetXY($posx, $posy);
$pdf->SetFillColor(230, 230, 230);
@@ -841,32 +843,32 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetTextColor(0, 0, 60);
// Show sender name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
- $posy=$pdf->getY();
+ $posy = $pdf->getY();
// Show sender information
- $pdf->SetXY($posx+2, $posy);
+ $pdf->SetXY($posx + 2, $posy);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
// Client destinataire
- $posy=42;
- $posx=102;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ $posy = 42;
+ $posx = 102;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx, $posy-5);
+ $pdf->SetXY($posx, $posy - 5);
$pdf->MultiCell(80, 5, $outputlangs->transnoentities("DeliveryAddress").":", 0, 'L');
// If SHIPPING contact defined on order, we use it
- $usecontact=false;
- $arrayidcontact=$object->commande->getIdContact('external', 'SHIPPING');
+ $usecontact = false;
+ $arrayidcontact = $object->commande->getIdContact('external', 'SHIPPING');
if (count($arrayidcontact) > 0)
{
- $usecontact=true;
- $result=$object->fetch_contact($arrayidcontact[0]);
+ $usecontact = true;
+ $result = $object->fetch_contact($arrayidcontact[0]);
}
//Recipient name
@@ -877,26 +879,26 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$thirdparty = $object->thirdparty;
}
- $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
+ $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
- $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object);
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
// Show recipient
- $widthrecbox=100;
- if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
- $posy=42;
- $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ $widthrecbox = 100;
+ if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
+ $posy = 42;
+ $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
// Show recipient frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx+2, $posy-5);
+ $pdf->SetXY($posx + 2, $posy - 5);
//$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show recipient name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
@@ -904,7 +906,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
// Show recipient information
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->SetXY($posx+2, $posy);
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
}
@@ -924,7 +926,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
global $conf;
- $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
}
diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php
index d6cae560298..ffba2571d23 100644
--- a/htdocs/core/modules/mailings/modules_mailings.php
+++ b/htdocs/core/modules/mailings/modules_mailings.php
@@ -39,9 +39,9 @@ class MailingTargets // This can't be abstract as it is used for some method
/**
* @var string Error code (or message)
*/
- public $error='';
+ public $error = '';
- public $tooltip='';
+ public $tooltip = '';
/**
@@ -64,12 +64,12 @@ class MailingTargets // This can't be abstract as it is used for some method
global $langs, $form;
$langs->load("mails");
- $transstring="MailingModuleDesc".$this->name;
- $s='';
+ $transstring = "MailingModuleDesc".$this->name;
+ $s = '';
- if ($langs->trans($this->name) != $this->name) $s=$langs->trans($this->name);
- elseif ($langs->trans($transstring) != $transstring) $s=$langs->trans($transstring);
- else $s=$this->desc;
+ if ($langs->trans($this->name) != $this->name) $s = $langs->trans($this->name);
+ elseif ($langs->trans($transstring) != $transstring) $s = $langs->trans($transstring);
+ else $s = $this->desc;
if ($this->tooltip && is_object($form)) $s .= ' '.$form->textwithpicto('', $langs->trans($this->tooltip), 1, 1);
return $s;
@@ -93,7 +93,7 @@ class MailingTargets // This can't be abstract as it is used for some method
*/
public function getNbOfRecipients($sql)
{
- $result=$this->db->query($sql);
+ $result = $this->db->query($sql);
if ($result)
{
$obj = $this->db->fetch_object($result);
@@ -101,7 +101,7 @@ class MailingTargets // This can't be abstract as it is used for some method
}
else
{
- $this->error=$this->db->lasterror();
+ $this->error = $this->db->lasterror();
return -1;
}
}
@@ -130,18 +130,18 @@ class MailingTargets // This can't be abstract as it is used for some method
// Mise a jour nombre de destinataire dans table des mailings
$sql = "SELECT COUNT(*) nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " WHERE fk_mailing = ".$mailing_id;
- $result=$this->db->query($sql);
+ $result = $this->db->query($sql);
if ($result)
{
- $obj=$this->db->fetch_object($result);
- $nb=$obj->nb;
+ $obj = $this->db->fetch_object($result);
+ $nb = $obj->nb;
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing";
$sql .= " SET nbemail = ".$nb." WHERE rowid = ".$mailing_id;
if (!$this->db->query($sql))
{
dol_syslog($this->db->error());
- $this->error=$this->db->error();
+ $this->error = $this->db->error();
return -1;
}
}
@@ -169,26 +169,26 @@ class MailingTargets // This can't be abstract as it is used for some method
$num = count($cibles);
foreach ($cibles as $targetarray)
{
- if (! empty($targetarray['email'])) // avoid empty email address
+ if (!empty($targetarray['email'])) // avoid empty email address
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
- $sql.= " (fk_mailing,";
- $sql.= " fk_contact,";
- $sql.= " lastname, firstname, email, other, source_url, source_id,";
- $sql.= " tag,";
- $sql.= " source_type)";
- $sql.= " VALUES (".$mailing_id.",";
- $sql.= (empty($targetarray['fk_contact']) ? '0' : "'".$targetarray['fk_contact']."'") .",";
- $sql.= "'".$this->db->escape($targetarray['lastname'])."',";
- $sql.= "'".$this->db->escape($targetarray['firstname'])."',";
- $sql.= "'".$this->db->escape($targetarray['email'])."',";
- $sql.= "'".$this->db->escape($targetarray['other'])."',";
- $sql.= "'".$this->db->escape($targetarray['source_url'])."',";
- $sql.= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").",";
+ $sql .= " (fk_mailing,";
+ $sql .= " fk_contact,";
+ $sql .= " lastname, firstname, email, other, source_url, source_id,";
+ $sql .= " tag,";
+ $sql .= " source_type)";
+ $sql .= " VALUES (".$mailing_id.",";
+ $sql .= (empty($targetarray['fk_contact']) ? '0' : "'".$targetarray['fk_contact']."'").",";
+ $sql .= "'".$this->db->escape($targetarray['lastname'])."',";
+ $sql .= "'".$this->db->escape($targetarray['firstname'])."',";
+ $sql .= "'".$this->db->escape($targetarray['email'])."',";
+ $sql .= "'".$this->db->escape($targetarray['other'])."',";
+ $sql .= "'".$this->db->escape($targetarray['source_url'])."',";
+ $sql .= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").",";
$sql .= "'".$this->db->escape(dol_hash($targetarray['email'].';'.$targetarray['lastname'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',";
$sql .= "'".$this->db->escape($targetarray['source_type'])."')";
- dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
- $result=$this->db->query($sql);
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $result = $this->db->query($sql);
if ($result)
{
$j++;
@@ -199,7 +199,7 @@ class MailingTargets // This can't be abstract as it is used for some method
{
// Si erreur autre que doublon
dol_syslog($this->db->error().' : '.$targetarray['email']);
- $this->error=$this->db->error().' : '.$targetarray['email'];
+ $this->error = $this->db->error().' : '.$targetarray['email'];
$this->db->rollback();
return -1;
}
@@ -207,7 +207,7 @@ class MailingTargets // This can't be abstract as it is used for some method
}
}
- dol_syslog(get_class($this)."::".__METHOD__.": mailing ".$j." targets added");
+ dol_syslog(__METHOD__.": mailing ".$j." targets added");
/*
//Update the status to show thirdparty mail that don't want to be contacted anymore'
@@ -215,7 +215,7 @@ class MailingTargets // This can't be abstract as it is used for some method
$sql .= " SET statut=3";
$sql .= " WHERE fk_mailing=".$mailing_id." AND email in (SELECT email FROM ".MAIN_DB_PREFIX."societe where fk_stcomm=-1)";
$sql .= " AND source_type='thirdparty'";
- dol_syslog(get_class($this)."::".__METHOD__.": mailing update status to display thirdparty mail that do not want to be contacted");
+ dol_syslog(__METHOD__.": mailing update status to display thirdparty mail that do not want to be contacted");
$result=$this->db->query($sql);
//Update the status to show contact mail that don't want to be contacted anymore'
@@ -223,7 +223,7 @@ class MailingTargets // This can't be abstract as it is used for some method
$sql .= " SET statut=3";
$sql .= " WHERE fk_mailing=".$mailing_id." AND source_type='contact' AND (email in (SELECT sc.email FROM ".MAIN_DB_PREFIX."socpeople AS sc ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid=sc.fk_soc WHERE s.fk_stcomm=-1 OR no_email=1))";
- dol_syslog(get_class($this)."::".__METHOD__.": mailing update status to display contact mail that do not want to be contacted",LOG_DEBUG);
+ dol_syslog(__METHOD__.": mailing update status to display contact mail that do not want to be contacted",LOG_DEBUG);
$result=$this->db->query($sql);
*/
@@ -231,9 +231,9 @@ class MailingTargets // This can't be abstract as it is used for some method
$sql .= " SET statut=3";
$sql .= " WHERE fk_mailing=".$mailing_id." AND email IN (SELECT mu.email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe AS mu WHERE mu.entity IN ('".getEntity('mailing')."'))";
- dol_syslog(get_class($this)."::".__METHOD__.":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG);
- $result=$this->db->query($sql);
- if (! $result)
+ dol_syslog(__METHOD__.":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG);
+ $result = $this->db->query($sql);
+ if (!$result)
{
dol_print_error($this->db);
}
@@ -258,7 +258,7 @@ class MailingTargets // This can't be abstract as it is used for some method
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " WHERE fk_mailing = ".$mailing_id;
- if (! $this->db->query($sql))
+ if (!$this->db->query($sql))
{
dol_syslog($this->db->error());
}
diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php
index b013ff1be91..2184500db8c 100644
--- a/htdocs/core/modules/modAgenda.class.php
+++ b/htdocs/core/modules/modAgenda.class.php
@@ -30,7 +30,7 @@
* \ingroup agenda
* \brief File of class to describe and enable/disable module Agenda
*/
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
* Class to describe and enable/disable module Agenda
@@ -59,7 +59,7 @@ class modAgenda extends DolibarrModules
$this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
- $this->picto='action';
+ $this->picto = 'action';
// Data directories to create when module is enabled
$this->dirs = array("/agenda/temp");
@@ -68,12 +68,12 @@ class modAgenda extends DolibarrModules
$this->config_page_url = array("agenda_other.php");
// Dependencies
- $this->hidden = false; // A condition to hide module
- $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
- $this->requiredby = array(); // List of module ids to disable if this one is disabled
- $this->conflictwith = array(); // List of module class names as string this module is in conflict with
+ $this->hidden = false; // A condition to hide module
+ $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
+ $this->requiredby = array(); // List of module ids to disable if this one is disabled
+ $this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->langfiles = array("companies");
- $this->phpmin = array(5,4); // Minimum version of PHP required by module
+ $this->phpmin = array(5, 4); // Minimum version of PHP required by module
// Module parts
$this->module_parts = array();
@@ -86,14 +86,14 @@ class modAgenda extends DolibarrModules
// );
$this->const = array();
//$this->const[] = array('AGENDA_DEFAULT_FILTER_TYPE', 'chaine', 'AC_NON_AUTO', 'Default filter for type of event on agenda', 0, 'current');
- $sqlreadactions="SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang";
+ $sqlreadactions = "SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang";
$resql = $this->db->query($sqlreadactions);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
//if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue; // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation).
- if (preg_match('/^TASK_/', $obj->code)) continue; // We don't track such events by default.
+ if (preg_match('/^TASK_/', $obj->code)) continue; // We don't track such events by default.
//if (preg_match('/^_MODIFY/',$obj->code)) continue; // We don't track such events by default.
$this->const[] = array('MAIN_AGENDA_ACTIONAUTO_'.$obj->code, "chaine", "1", '', 0, 'current');
}
@@ -109,11 +109,11 @@ class modAgenda extends DolibarrModules
// Boxes
//------
- $this->boxes = array(0=>array('file'=>'box_actions.php','enabledbydefaulton'=>'Home'));
+ $this->boxes = array(0=>array('file'=>'box_actions.php', 'enabledbydefaulton'=>'Home'));
// Cronjobs
//------------
- $datestart=dol_now();
+ $datestart = dol_now();
$this->cronjobs = array(
0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>10, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'$conf->agenda->enabled', 'datestart'=>$datestart),
);
@@ -122,7 +122,7 @@ class modAgenda extends DolibarrModules
//------------
$this->rights = array();
$this->rights_class = 'agenda';
- $r=0;
+ $r = 0;
// $this->rights[$r][0] Id permission (unique tous modules confondus)
// $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
@@ -187,8 +187,8 @@ class modAgenda extends DolibarrModules
$this->rights[$r][4] = 'export';
// Main menu entries
- $this->menu = array(); // List of menus to add
- $r=0;
+ $this->menu = array(); // List of menus to add
+ $r = 0;
// Add here entries to declare new menus
// Example to declare the Top Menu entry:
@@ -204,7 +204,7 @@ class modAgenda extends DolibarrModules
// 'target'=>'',
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++;
- $this->menu[$r]=array(
+ $this->menu[$r] = array(
'fk_menu'=>0,
'type'=>'top',
'titre'=>'TMenuAgenda',
@@ -219,214 +219,255 @@ class modAgenda extends DolibarrModules
);
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=0',
- 'type'=>'left',
- 'titre'=>'Actions',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda',
- 'langs'=>'agenda',
- 'position'=>100,
- 'perms'=>'$user->rights->agenda->myactions->read',
- 'enabled'=>'$conf->agenda->enabled',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=0',
+ 'type'=>'left',
+ 'titre'=>'Actions',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/index.php?mainmenu=agenda&leftmenu=agenda',
+ 'langs'=>'agenda',
+ 'position'=>100,
+ 'perms'=>'$user->rights->agenda->myactions->read',
+ 'enabled'=>'$conf->agenda->enabled',
+ 'target'=>'',
+ 'user'=>2,
+ );
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=1',
- 'type'=>'left',
- 'titre'=>'NewAction',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create',
- 'langs'=>'commercial',
- 'position'=>101,
- 'perms'=>'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)',
- 'enabled'=>'$conf->agenda->enabled',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=1',
+ 'type'=>'left',
+ 'titre'=>'NewAction',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/card.php?mainmenu=agenda&leftmenu=agenda&action=create',
+ 'langs'=>'commercial',
+ 'position'=>101,
+ 'perms'=>'($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create)',
+ 'enabled'=>'$conf->agenda->enabled',
+ 'target'=>'',
+ 'user'=>2
+ );
$r++;
// Calendar
- $this->menu[$r]=array('fk_menu'=>'r=1',
- 'type'=>'left',
- 'titre'=>'Calendar',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda',
- 'langs'=>'agenda',
- 'position'=>140,
- 'perms'=>'$user->rights->agenda->myactions->read',
- 'enabled'=>'$conf->agenda->enabled',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=1',
+ 'type'=>'left',
+ 'titre'=>'Calendar',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda',
+ 'langs'=>'agenda',
+ 'position'=>140,
+ 'perms'=>'$user->rights->agenda->myactions->read',
+ 'enabled'=>'$conf->agenda->enabled',
+ 'target'=>'',
+ 'user'=>2
+ );
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=3',
- 'type'=>'left',
- 'titre'=>'MenuToDoMyActions',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
- 'langs'=>'agenda',
- 'position'=>141,
- 'perms'=>'$user->rights->agenda->myactions->read',
- 'enabled'=>'$conf->agenda->enabled',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=3',
+ 'type'=>'left',
+ 'titre'=>'MenuToDoMyActions',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
+ 'langs'=>'agenda',
+ 'position'=>141,
+ 'perms'=>'$user->rights->agenda->myactions->read',
+ 'enabled'=>'$conf->agenda->enabled',
+ 'target'=>'',
+ 'user'=>2
+ );
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=3',
- 'type'=>'left',
- 'titre'=>'MenuDoneMyActions',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
- 'langs'=>'agenda',
- 'position'=>142,
- 'perms'=>'$user->rights->agenda->myactions->read',
- 'enabled'=>'$conf->agenda->enabled',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=3',
+ 'type'=>'left',
+ 'titre'=>'MenuDoneMyActions',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
+ 'langs'=>'agenda',
+ 'position'=>142,
+ 'perms'=>'$user->rights->agenda->myactions->read',
+ 'enabled'=>'$conf->agenda->enabled',
+ 'target'=>'',
+ 'user'=>2
+ );
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=3',
- 'type'=>'left',
- 'titre'=>'MenuToDoActions',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
- 'langs'=>'agenda',
- 'position'=>143,
- 'perms'=>'$user->rights->agenda->allactions->read',
- 'enabled'=>'$user->rights->agenda->allactions->read',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=3',
+ 'type'=>'left',
+ 'titre'=>'MenuToDoActions',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
+ 'langs'=>'agenda',
+ 'position'=>143,
+ 'perms'=>'$user->rights->agenda->allactions->read',
+ 'enabled'=>'$user->rights->agenda->allactions->read',
+ 'target'=>'',
+ 'user'=>2
+ );
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=3',
- 'type'=>'left',
- 'titre'=>'MenuDoneActions',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
- 'langs'=>'agenda',
- 'position'=>144,
- 'perms'=>'$user->rights->agenda->allactions->read',
- 'enabled'=>'$user->rights->agenda->allactions->read',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=3',
+ 'type'=>'left',
+ 'titre'=>'MenuDoneActions',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
+ 'langs'=>'agenda',
+ 'position'=>144,
+ 'perms'=>'$user->rights->agenda->allactions->read',
+ 'enabled'=>'$user->rights->agenda->allactions->read',
+ 'target'=>'',
+ 'user'=>2
+ );
// List
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=1',
- 'type'=>'left',
- 'titre'=>'List',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda',
- 'langs'=>'agenda',
- 'position'=>110,
- 'perms'=>'$user->rights->agenda->myactions->read',
- 'enabled'=>'$conf->agenda->enabled',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=1',
+ 'type'=>'left',
+ 'titre'=>'List',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda',
+ 'langs'=>'agenda',
+ 'position'=>110,
+ 'perms'=>'$user->rights->agenda->myactions->read',
+ 'enabled'=>'$conf->agenda->enabled',
+ 'target'=>'',
+ 'user'=>2
+ );
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=8',
- 'type'=>'left',
- 'titre'=>'MenuToDoMyActions',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
- 'langs'=>'agenda',
- 'position'=>111,
- 'perms'=>'$user->rights->agenda->myactions->read',
- 'enabled'=>'$conf->agenda->enabled',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=8',
+ 'type'=>'left',
+ 'titre'=>'MenuToDoMyActions',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine',
+ 'langs'=>'agenda',
+ 'position'=>111,
+ 'perms'=>'$user->rights->agenda->myactions->read',
+ 'enabled'=>'$conf->agenda->enabled',
+ 'target'=>'',
+ 'user'=>2
+ );
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=8',
- 'type'=>'left',
- 'titre'=>'MenuDoneMyActions',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
- 'langs'=>'agenda',
- 'position'=>112,
- 'perms'=>'$user->rights->agenda->myactions->read',
- 'enabled'=>'$conf->agenda->enabled',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=8',
+ 'type'=>'left',
+ 'titre'=>'MenuDoneMyActions',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=done&filter=mine',
+ 'langs'=>'agenda',
+ 'position'=>112,
+ 'perms'=>'$user->rights->agenda->myactions->read',
+ 'enabled'=>'$conf->agenda->enabled',
+ 'target'=>'',
+ 'user'=>2
+ );
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=8',
- 'type'=>'left',
- 'titre'=>'MenuToDoActions',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
- 'langs'=>'agenda',
- 'position'=>113,
- 'perms'=>'$user->rights->agenda->allactions->read',
- 'enabled'=>'$user->rights->agenda->allactions->read',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=8',
+ 'type'=>'left',
+ 'titre'=>'MenuToDoActions',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1',
+ 'langs'=>'agenda',
+ 'position'=>113,
+ 'perms'=>'$user->rights->agenda->allactions->read',
+ 'enabled'=>'$user->rights->agenda->allactions->read',
+ 'target'=>'',
+ 'user'=>2
+ );
$r++;
- $this->menu[$r]=array('fk_menu'=>'r=8',
- 'type'=>'left',
- 'titre'=>'MenuDoneActions',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
- 'langs'=>'agenda',
- 'position'=>114,
- 'perms'=>'$user->rights->agenda->allactions->read',
- 'enabled'=>'$user->rights->agenda->allactions->read',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=8',
+ 'type'=>'left',
+ 'titre'=>'MenuDoneActions',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/list.php?mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1',
+ 'langs'=>'agenda',
+ 'position'=>114,
+ 'perms'=>'$user->rights->agenda->allactions->read',
+ 'enabled'=>'$user->rights->agenda->allactions->read',
+ 'target'=>'',
+ 'user'=>2
+ );
$r++;
// Reports
- $this->menu[$r]=array('fk_menu'=>'r=1',
- 'type'=>'left',
- 'titre'=>'Reportings',
- 'mainmenu'=>'agenda',
- 'url'=>'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda',
- 'langs'=>'agenda',
- 'position'=>160,
- 'perms'=>'$user->rights->agenda->allactions->read',
- 'enabled'=>'$conf->agenda->enabled',
- 'target'=>'',
- 'user'=>2);
+ $this->menu[$r] = array(
+ 'fk_menu'=>'r=1',
+ 'type'=>'left',
+ 'titre'=>'Reportings',
+ 'mainmenu'=>'agenda',
+ 'url'=>'/comm/action/rapport/index.php?mainmenu=agenda&leftmenu=agenda',
+ 'langs'=>'agenda',
+ 'position'=>160,
+ 'perms'=>'$user->rights->agenda->allactions->read',
+ 'enabled'=>'$conf->agenda->enabled',
+ 'target'=>'',
+ 'user'=>2
+ );
+ $r++;
+ // Categories
+ $this->menu[$r] = array(
+ 'fk_menu' => 'r=1',
+ 'type' => 'left',
+ 'titre' => 'Categories',
+ 'mainmenu' => 'agenda',
+ 'url'=>'/categories/index.php?mainmenu=agenda&leftmenu=agenda&type=10',
+ 'langs' => 'agenda',
+ 'position' => 170,
+ 'perms' => '$user->rights->agenda->allactions->read',
+ 'enabled' => '$conf->categorie->enabled&&$conf->categorie->enabled',
+ 'target' => '',
+ 'user' => 2
+ );
$r++;
// Exports
//--------
- $r=0;
+ $r = 0;
$r++;
- $this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]="ExportDataset_event1";
- $this->export_permission[$r]=array(array("agenda","export"));
- $this->export_fields_array[$r]=array('ac.id'=>"IdAgenda",'ac.ref_ext'=>"ExternalRef",'ac.datec'=>"DateCreation",'ac.datep'=>"DateActionBegin",
- 'ac.datep2'=>"DateActionEnd",'ac.label'=>"Title",'ac.note'=>"Note",'ac.percent'=>"Percent",'ac.durationp'=>"Duration",
+ $this->export_code[$r] = $this->rights_class.'_'.$r;
+ $this->export_label[$r] = "ExportDataset_event1";
+ $this->export_permission[$r] = array(array("agenda", "export"));
+ $this->export_fields_array[$r] = array('ac.id'=>"IdAgenda", 'ac.ref_ext'=>"ExternalRef", 'ac.datec'=>"DateCreation", 'ac.datep'=>"DateActionBegin",
+ 'ac.datep2'=>"DateActionEnd", 'ac.label'=>"Title", 'ac.note'=>"Note", 'ac.percent'=>"Percent", 'ac.durationp'=>"Duration",
'cac.libelle'=>"ActionType",
- 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town',
- 'co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
- 's.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra',
+ 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town',
+ 'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
+ 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
'p.ref' => 'ProjectRef',
);
- $this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date",
- 'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric",
+ $this->export_TypeFields_array[$r] = array('ac.ref_ext'=>"Text", 'ac.datec'=>"Date", 'ac.datep'=>"Date",
+ 'ac.datep2'=>"Date", 'ac.label'=>"Text", 'ac.note'=>"Text", 'ac.percent'=>"Numeric",
'ac.durationp'=>"Duree",
'cac.libelle'=>"List:c_actioncomm:libelle:libelle",
- 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text',
- 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text',
- 's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text',
+ 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text',
+ 'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text',
+ 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
'p.ref' => 'Text',
);
- $this->export_entities_array[$r]=array('ac.id'=>"action",'ac.ref_ext'=>"action",'ac.datec'=>"action",'ac.datep'=>"action",
- 'ac.datep2'=>"action",'ac.label'=>"action",'ac.note'=>"action",'ac.percent'=>"action",'ac.durationp'=>"action",
+ $this->export_entities_array[$r] = array('ac.id'=>"action", 'ac.ref_ext'=>"action", 'ac.datec'=>"action", 'ac.datep'=>"action",
+ 'ac.datep2'=>"action", 'ac.label'=>"action", 'ac.note'=>"action", 'ac.percent'=>"action", 'ac.durationp'=>"action",
'cac.libelle'=>"action",
- 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company',
- 'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company',
- 's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company',
+ 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company',
+ 'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company',
+ 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company',
'p.ref' => 'project',
);
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
- if (! empty($user) && empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
- if (! empty($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
- $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet as p ON p.rowid = ac.fk_project";
- $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda').')';
- if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)';
- if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id);
- $this->export_sql_order[$r] =' ORDER BY ac.datep';
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
+ if (!empty($user) && empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
+ if (!empty($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
+ $this->export_sql_end[$r] .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = ac.fk_project";
+ $this->export_sql_end[$r] .= ' WHERE ac.entity IN ('.getEntity('agenda').')';
+ if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';
+ if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
+ $this->export_sql_order[$r] = ' ORDER BY ac.datep';
}
}
diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php
index afb5185fb51..9bff4afdaf8 100644
--- a/htdocs/core/modules/modCashDesk.class.php
+++ b/htdocs/core/modules/modCashDesk.class.php
@@ -22,7 +22,7 @@
* \ingroup pos
* \brief File to enable/disable module Point Of Sales
*/
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
@@ -64,13 +64,13 @@ class modCashDesk extends DolibarrModules
$this->config_page_url = array("cashdesk.php@cashdesk");
// Dependencies
- $this->hidden = false; // A condition to hide module
- $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog'); // List of modules id that must be enabled if this module is enabled
- $this->requiredby = array(); // List of modules id to disable if this one is disabled
- $this->phpmin = array(5,4); // Minimum version of PHP required by module
- $this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module
+ $this->hidden = false; // A condition to hide module
+ $this->depends = array('always'=>"modBanque", 'always'=>"modFacture", 'always'=>"modProduct", 'FR'=>'modBlockedLog'); // List of modules id that must be enabled if this module is enabled
+ $this->requiredby = array(); // List of modules id to disable if this one is disabled
+ $this->phpmin = array(5, 4); // Minimum version of PHP required by module
+ $this->need_dolibarr_version = array(2, 4); // Minimum version of Dolibarr required by module
$this->langfiles = array("cashdesk");
- $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
+ $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
//$this->warnings_activation_ext = array('FR'=>'WarningInstallationMayBecomeNotCompliantWithLaw'); // Warning to show when we activate an external module. array('always'='text') or array('FR'='text')
// Constants
@@ -81,7 +81,7 @@ class modCashDesk extends DolibarrModules
// Permissions
$this->rights = array();
- $r=0;
+ $r = 0;
$r++;
$this->rights[$r][0] = 50101;
@@ -91,21 +91,21 @@ class modCashDesk extends DolibarrModules
$this->rights[$r][4] = 'run';
// Main menu entries
- $this->menus = array(); // List of menus to add
- $r=0;
+ $this->menus = array(); // List of menus to add
+ $r = 0;
// This is to declare the Top Menu entry:
- $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu
- 'type'=>'top', // This is a Top menu entry
+ $this->menu[$r] = array('fk_menu'=>0, // Put 0 if this is a top menu
+ 'type'=>'top', // This is a Top menu entry
'titre'=>'PointOfSaleShort',
'mainmenu'=>'cashdesk',
'url'=>'/cashdesk/index.php?user=__USER_LOGIN__',
- 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>900,
'enabled'=>'$conf->cashdesk->enabled',
- 'perms'=>'$user->rights->cashdesk->run', // Use 'perms'=>'1' if you want your menu with no permission rules
+ 'perms'=>'$user->rights->cashdesk->run', // Use 'perms'=>'1' if you want your menu with no permission rules
'target'=>'pointofsale',
- 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
+ 'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
$r++;
diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php
index b53a9630598..61a4dd67d5c 100644
--- a/htdocs/core/modules/modCategorie.class.php
+++ b/htdocs/core/modules/modCategorie.class.php
@@ -24,7 +24,7 @@
* \ingroup category
* \brief Fichier de description et activation du module Categorie
*/
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
@@ -64,11 +64,11 @@ class modCategorie extends DolibarrModules
// Config pages
$this->config_page_url = array('categorie.php@categories');
- $this->langfiles = array("products","companies","categories","members");
+ $this->langfiles = array("products", "companies", "categories", "members");
// Constants
$this->const = array();
- $r=0;
+ $r = 0;
$this->const[$r][0] = "CATEGORIE_RECURSIV_ADD";
$this->const[$r][1] = "yesno";
$this->const[$r][2] = "0";
@@ -83,7 +83,7 @@ class modCategorie extends DolibarrModules
$this->rights = array();
$this->rights_class = 'categorie';
- $r=0;
+ $r = 0;
$this->rights[$r][0] = 241; // id de la permission
$this->rights[$r][1] = 'Lire les categories'; // libelle de la permission
@@ -109,115 +109,115 @@ class modCategorie extends DolibarrModules
// Menus
//-------
- $this->menu = 1; // This module add menu entries. They are coded into menu manager.
+ $this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports
//--------
- $r=0;
+ $r = 0;
$r++;
- $this->export_code[$r]='category_'.$r;
- $this->export_label[$r]='CatSupList';
- $this->export_icon[$r]='category';
- $this->export_enabled[$r]='$conf->fournisseur->enabled';
- $this->export_permission[$r]=array(array("categorie","lire"),array("fournisseur","lire"));
- $this->export_fields_array[$r]=array(
- 'u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'s.rowid'=>'IdThirdParty','s.nom'=>'Name','s.prefix_comm'=>"Prefix",
- 's.client'=>"Customer",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.address'=>"Address",
- 's.zip'=>"Zip",'s.town'=>"Town",'c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",
- 's.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",
+ $this->export_code[$r] = 'category_'.$r;
+ $this->export_label[$r] = 'CatSupList';
+ $this->export_icon[$r] = 'category';
+ $this->export_enabled[$r] = '$conf->fournisseur->enabled';
+ $this->export_permission[$r] = array(array("categorie", "lire"), array("fournisseur", "lire"));
+ $this->export_fields_array[$r] = array(
+ 'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix",
+ 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address",
+ 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email",
+ 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital",
's.note_public'=>"NotePublic"
);
- $this->export_TypeFields_array[$r]=array(
- 'u.label'=>"Text",'u.description'=>"Text",'s.rowid'=>'List:societe:nom','s.nom'=>'Text','s.prefix_comm'=>"Text",'s.client'=>"Text",'s.datec'=>"Date",
- 's.tms'=>"Date",'s.code_client'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",
- 's.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",
- 's.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_public'=>"Text"
+ $this->export_TypeFields_array[$r] = array(
+ 'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", 's.datec'=>"Date",
+ 's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text",
+ 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text",
+ 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text"
);
- $this->export_entities_array[$r]=array(
- 's.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company",
- 's.code_client'=>"company",'s.address'=>"company",'s.zip'=>"company",'s.town'=>"company",'c.label'=>"company",'c.code'=>"company",
- 's.phone'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",
- 's.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note_public'=>"company"
- ); // We define here only fields that use another picto
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, ';
+ $this->export_entities_array[$r] = array(
+ 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company",
+ 's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company",
+ 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company",
+ 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company"
+ ); // We define here only fields that use another picto
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, ';
$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_fournisseur as cf, ';
$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
- $this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';
- $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')';
- $this->export_sql_end[$r] .=' AND u.type = 1'; // Supplier categories
+ $this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';
+ $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';
+ $this->export_sql_end[$r] .= ' AND u.type = 1'; // Supplier categories
$r++;
- $this->export_code[$r]='category_'.$r;
- $this->export_label[$r]='CatCusList';
- $this->export_icon[$r]='category';
- $this->export_enabled[$r]='$conf->societe->enabled';
- $this->export_permission[$r]=array(array("categorie","lire"),array("societe","lire"));
- $this->export_fields_array[$r]=array(
- 'u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'s.rowid'=>'IdThirdParty','s.nom'=>'Name','s.prefix_comm'=>"Prefix",
- 's.client'=>"Customer",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.address'=>"Address",
- 's.zip'=>"Zip",'s.town'=>"Town",'c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",
- 's.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",
- 's.note_public'=>"NotePublic",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus'
+ $this->export_code[$r] = 'category_'.$r;
+ $this->export_label[$r] = 'CatCusList';
+ $this->export_icon[$r] = 'category';
+ $this->export_enabled[$r] = '$conf->societe->enabled';
+ $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire"));
+ $this->export_fields_array[$r] = array(
+ 'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix",
+ 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address",
+ 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email",
+ 's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital",
+ 's.note_public'=>"NotePublic", 's.fk_prospectlevel'=>'ProspectLevel', 's.fk_stcomm'=>'ProspectStatus'
);
- $this->export_TypeFields_array[$r]=array(
- 'u.label'=>"Text",'u.description'=>"Text",'s.rowid'=>'List:societe:nom','s.nom'=>'Text','s.prefix_comm'=>"Text",'s.client'=>"Text",
- 's.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",
- 'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",
- 's.idprof4'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_public'=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
+ $this->export_TypeFields_array[$r] = array(
+ 'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text",
+ 's.datec'=>"Date", 's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label",
+ 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text",
+ 's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
's.fk_stcomm'=>'List:c_stcomm:libelle:code'
);
- $this->export_entities_array[$r]=array(
- 's.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company",
- 's.code_client'=>"company",'s.address'=>"company",'s.zip'=>"company",'s.town'=>"company",'c.label'=>"company",'c.code'=>"company",
- 's.phone'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",
- 's.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note_public'=>"company",'s.fk_prospectlevel'=>'company',
+ $this->export_entities_array[$r] = array(
+ 's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company",
+ 's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company",
+ 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company",
+ 's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", 's.fk_prospectlevel'=>'company',
's.fk_stcomm'=>'company'
- ); // We define here only fields that use another picto
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, ';
+ ); // We define here only fields that use another picto
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, ';
$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_societe as cf, ';
$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object ';
- $this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';
- $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')';
- $this->export_sql_end[$r] .=' AND u.type = 2'; // Customer/Prospect categories
+ $this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';
+ $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';
+ $this->export_sql_end[$r] .= ' AND u.type = 2'; // Customer/Prospect categories
// Add extra fields
- $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")";
- $resql=$this->db->query($sql);
+ $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")";
+ $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
- $fieldname='extra.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $typeFilter="Text";
- switch($obj->type)
+ $fieldname = 'extra.'.$obj->name;
+ $fieldlabel = ucfirst($obj->label);
+ $typeFilter = "Text";
+ switch ($obj->type)
{
case 'int':
case 'double':
case 'price':
- $typeFilter="Numeric";
+ $typeFilter = "Numeric";
break;
case 'date':
case 'datetime':
- $typeFilter="Date";
+ $typeFilter = "Date";
break;
case 'boolean':
- $typeFilter="Boolean";
+ $typeFilter = "Boolean";
break;
case 'sellist':
- $typeFilter="List:".$obj->param;
+ $typeFilter = "List:".$obj->param;
break;
case 'select':
- $typeFilter="Select:".$obj->param;
+ $typeFilter = "Select:".$obj->param;
break;
}
- $this->export_fields_array[$r][$fieldname]=$fieldlabel;
- $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
- $this->export_entities_array[$r][$fieldname]='company';
+ $this->export_fields_array[$r][$fieldname] = $fieldlabel;
+ $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
+ $this->export_entities_array[$r][$fieldname] = 'company';
}
}
// End add axtra fields
@@ -227,42 +227,42 @@ class modCategorie extends DolibarrModules
$r++;
- $this->export_code[$r]='category_'.$r;
- $this->export_label[$r]='CatProdList';
- $this->export_icon[$r]='category';
- $this->export_enabled[$r]='$conf->product->enabled || $conf->service->enabled';
- $this->export_permission[$r]=array(array("categorie","lire"),array("produit","lire"));
- $this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'p.rowid'=>'ProductId','p.ref'=>'Ref');
- $this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'p.ref'=>'Text');
- $this->export_entities_array[$r]=array('p.rowid'=>'product','p.ref'=>'product'); // We define here only fields that use another picto
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p';
- $this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid';
- $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')';
- $this->export_sql_end[$r] .=' AND u.type = 0'; // Supplier categories
+ $this->export_code[$r] = 'category_'.$r;
+ $this->export_label[$r] = 'CatProdList';
+ $this->export_icon[$r] = 'category';
+ $this->export_enabled[$r] = '$conf->product->enabled || $conf->service->enabled';
+ $this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "lire"));
+ $this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref');
+ $this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.ref'=>'Text');
+ $this->export_entities_array[$r] = array('p.rowid'=>'product', 'p.ref'=>'product'); // We define here only fields that use another picto
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p';
+ $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid';
+ $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';
+ $this->export_sql_end[$r] .= ' AND u.type = 0'; // Supplier categories
$r++;
- $this->export_code[$r]='category_'.$r;
- $this->export_label[$r]='CatMemberList';
- $this->export_icon[$r]='category';
- $this->export_enabled[$r]='$conf->adherent->enabled';
- $this->export_permission[$r]=array(array("categorie","lire"),array("adherent","lire"));
- $this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'p.rowid'=>'MemberId','p.lastname'=>'LastName','p.firstname'=>'Firstname');
- $this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'p.lastname'=>'Text','p.firstname'=>'Text');
- $this->export_entities_array[$r]=array('p.rowid'=>'member','p.lastname'=>'member','p.firstname'=>'member'); // We define here only fields that use another picto
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p';
- $this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid';
- $this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')';
- $this->export_sql_end[$r] .=' AND u.type = 3'; // Member categories
+ $this->export_code[$r] = 'category_'.$r;
+ $this->export_label[$r] = 'CatMemberList';
+ $this->export_icon[$r] = 'category';
+ $this->export_enabled[$r] = '$conf->adherent->enabled';
+ $this->export_permission[$r] = array(array("categorie", "lire"), array("adherent", "lire"));
+ $this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'MemberId', 'p.lastname'=>'LastName', 'p.firstname'=>'Firstname');
+ $this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.lastname'=>'Text', 'p.firstname'=>'Text');
+ $this->export_entities_array[$r] = array('p.rowid'=>'member', 'p.lastname'=>'member', 'p.firstname'=>'member'); // We define here only fields that use another picto
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p';
+ $this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid';
+ $this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';
+ $this->export_sql_end[$r] .= ' AND u.type = 3'; // Member categories
$r++;
- $this->export_code[$r]='category_'.$r;
- $this->export_label[$r]='CatContactList';
- $this->export_icon[$r]='category';
- $this->export_enabled[$r]='$conf->societe->enabled';
- $this->export_permission[$r]=array(array("categorie", "lire"), array ("societe", "lire"));
- $this->export_fields_array[$r]=array (
+ $this->export_code[$r] = 'category_'.$r;
+ $this->export_label[$r] = 'CatContactList';
+ $this->export_icon[$r] = 'category';
+ $this->export_enabled[$r] = '$conf->societe->enabled';
+ $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire"));
+ $this->export_fields_array[$r] = array(
'u.rowid' => "CategId",
'u.label' => "Label",
'u.description' => "Description",
@@ -297,7 +297,7 @@ class modCategorie extends DolibarrModules
's.url'=>"Url",
's.email'=>"Email"
);
- $this->export_TypeFields_array[$r] = array (
+ $this->export_TypeFields_array[$r] = array(
'u.label' => "Text",
'u.description' => "Text",
'p.lastname' => 'Text',
@@ -313,7 +313,7 @@ class modCategorie extends DolibarrModules
's.url'=>"Text",
's.email'=>"Text"
);
- $this->export_entities_array[$r] = array (
+ $this->export_entities_array[$r] = array(
'u.rowid' => "category",
'u.label' => "category",
'u.description' => "category",
@@ -350,67 +350,67 @@ class modCategorie extends DolibarrModules
); // We define here only fields that use another picto
// Add extra fields
- $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")";
- $resql=$this->db->query($sql);
+ $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")";
+ $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
- $fieldname='extra.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $typeFilter="Text";
- switch($obj->type)
+ $fieldname = 'extra.'.$obj->name;
+ $fieldlabel = ucfirst($obj->label);
+ $typeFilter = "Text";
+ switch ($obj->type)
{
case 'int':
case 'double':
case 'price':
- $typeFilter="Numeric";
+ $typeFilter = "Numeric";
break;
case 'date':
case 'datetime':
- $typeFilter="Date";
+ $typeFilter = "Date";
break;
case 'boolean':
- $typeFilter="Boolean";
+ $typeFilter = "Boolean";
break;
case 'sellist':
- $typeFilter="List:".$obj->param;
+ $typeFilter = "List:".$obj->param;
break;
case 'select':
- $typeFilter="Select:".$obj->param;
+ $typeFilter = "Select:".$obj->param;
break;
}
- $this->export_fields_array[$r][$fieldname]=$fieldlabel;
- $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
- $this->export_entities_array[$r][$fieldname]='contact';
+ $this->export_fields_array[$r][$fieldname] = $fieldlabel;
+ $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
+ $this->export_entities_array[$r][$fieldname] = 'contact';
}
}
// End add axtra fields
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
- $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, '.MAIN_DB_PREFIX . 'categorie_contact as cp, '.MAIN_DB_PREFIX . 'socpeople as p';
- $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid';
- $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc';
- $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople_extrafields as extra ON extra.fk_object = p.rowid';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_contact as cp, '.MAIN_DB_PREFIX.'socpeople as p';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as country ON p.fk_pays = country.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = p.rowid';
$this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category').')';
$this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories
// Imports
//--------
- $r=0;
+ $r = 0;
$r++;
- $this->import_code[$r]=$this->rights_class.'_'.$r;
- $this->import_label[$r]="CatList"; // Translation key
- $this->import_icon[$r]=$this->picto;
- $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
- $this->import_tables_array[$r]=array('ca'=>MAIN_DB_PREFIX.'categorie');
- $this->import_fields_array[$r]=array(
- 'ca.label'=>"Label*",'ca.type'=>"Type*",'ca.description'=>"Description",
+ $this->import_code[$r] = $this->rights_class.'_'.$r;
+ $this->import_label[$r] = "CatList"; // Translation key
+ $this->import_icon[$r] = $this->picto;
+ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
+ $this->import_tables_array[$r] = array('ca'=>MAIN_DB_PREFIX.'categorie');
+ $this->import_fields_array[$r] = array(
+ 'ca.label'=>"Label*", 'ca.type'=>"Type*", 'ca.description'=>"Description",
'ca.fk_parent' => 'Parent'
);
- $this->import_regex_array[$r]=array('ca.type'=>'^[0|1|2|3]');
+ $this->import_regex_array[$r] = array('ca.type'=>'^[0|1|2|3]');
$this->import_convertvalue_array[$r] = array(
'ca.fk_parent' => array(
'rule' => 'fetchidfromcodeandlabel',
@@ -421,77 +421,96 @@ class modCategorie extends DolibarrModules
'codefromfield' => 'ca.type'
)
);
- $typeexample="";
- if ($conf->product->enabled) { $typeexample.=($typeexample?"/":"")."0=Product"; }
- if ($conf->fournisseur->enabled) { $typeexample.=($typeexample?"/":"")."1=Supplier"; }
- if ($conf->societe->enabled) { $typeexample.=($typeexample?"/":"")."2=Customer-Prospect"; }
- if ($conf->adherent->enabled) { $typeexample.=($typeexample?"/":"")."3=Member"; }
+ $typeexample = "";
+ if ($conf->product->enabled) { $typeexample .= ($typeexample ? "/" : "")."0=Product"; }
+ if ($conf->fournisseur->enabled) { $typeexample .= ($typeexample ? "/" : "")."1=Supplier"; }
+ if ($conf->societe->enabled) { $typeexample .= ($typeexample ? "/" : "")."2=Customer-Prospect"; }
+ if ($conf->adherent->enabled) { $typeexample .= ($typeexample ? "/" : "")."3=Member"; }
$this->import_examplevalues_array[$r] = array(
- 'ca.label'=>"Supplier Category",'ca.type'=>$typeexample,'ca.description'=>"My Category description",
+ 'ca.label'=>"Supplier Category", 'ca.type'=>$typeexample, 'ca.description'=>"My Category description",
'ca.fk_parent' => '0'
);
- if (! empty($conf->product->enabled))
+ if (!empty($conf->product->enabled))
{
//Products
$r++;
- $this->import_code[$r]=$this->rights_class.'_'.$r;
- $this->import_label[$r]="CatProdLinks"; // Translation key
- $this->import_icon[$r]=$this->picto;
- $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
- $this->import_tables_array[$r]=array('cp'=>MAIN_DB_PREFIX.'categorie_product');
- $this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*");
- $this->import_regex_array[$r]=array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=0');
+ $this->import_code[$r] = $this->rights_class.'_'.$r;
+ $this->import_label[$r] = "CatProdLinks"; // Translation key
+ $this->import_icon[$r] = $this->picto;
+ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
+ $this->import_tables_array[$r] = array('cp'=>MAIN_DB_PREFIX.'categorie_product');
+ $this->import_fields_array[$r] = array('cp.fk_categorie'=>"Category*", 'cp.fk_product'=>"Product*");
+ $this->import_regex_array[$r] = array('cp.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=0');
- $this->import_convertvalue_array[$r]=array(
- 'cp.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'),
- 'cp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product')
+ $this->import_convertvalue_array[$r] = array(
+ 'cp.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
+ 'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'product')
);
- $this->import_examplevalues_array[$r]=array('cp.fk_categorie'=>"Imported category",'cp.fk_product'=>"PREF123456");
+ $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"Imported category", 'cp.fk_product'=>"PREF123456");
}
- if (! empty($conf->societe->enabled))
+ if (!empty($conf->societe->enabled))
{
- //Customers
+ // Customers
$r++;
- $this->import_code[$r]=$this->rights_class.'_'.$r;
- $this->import_label[$r]="CatCusLinks"; // Translation key
- $this->import_icon[$r]=$this->picto;
- $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
- $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_societe');
- $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"ThirdParty*");
- $this->import_regex_array[$r]=array(
+ $this->import_code[$r] = $this->rights_class.'_'.$r;
+ $this->import_label[$r] = "CatCusLinks"; // Translation key
+ $this->import_icon[$r] = $this->picto;
+ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
+ $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_societe');
+ $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"ThirdParty*");
+ $this->import_regex_array[$r] = array(
'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=2',
'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:client>0'
);
- $this->import_convertvalue_array[$r]=array(
- 'cs.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'),
- 'cs.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty')
+ $this->import_convertvalue_array[$r] = array(
+ 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
+ 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty')
);
- $this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_soc'=>"MyBigCompany");
+ $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany");
+
+ // Contacts/Addresses
+ $r++;
+ $this->import_code[$r] = $this->rights_class.'_'.$r;
+ $this->import_label[$r] = "CatContactsLinks"; // Translation key
+ $this->import_icon[$r] = $this->picto;
+ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
+ $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_contact');
+ $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_socpeople'=>"Contact ID*");
+ $this->import_regex_array[$r] = array(
+ 'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=4'
+ //'cs.fk_socpeople'=>'rowid@'.MAIN_DB_PREFIX.'socpeople'
+ );
+
+ $this->import_convertvalue_array[$r] = array(
+ 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category')
+ //'cs.fk_socpeople'=>array('rule'=>'fetchidfromref','classfile'=>'/contact/class/contact.class.php','class'=>'Contact','method'=>'fetch','element'=>'Contact')
+ );
+ $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_socpeople'=>"123");
}
- if (! empty($conf->fournisseur->enabled))
+ if (!empty($conf->fournisseur->enabled))
{
// Suppliers
$r++;
- $this->import_code[$r]=$this->rights_class.'_'.$r;
- $this->import_label[$r]="CatSupLinks"; // Translation key
- $this->import_icon[$r]=$this->picto;
- $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
- $this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur');
- $this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"Supplier*");
- $this->import_regex_array[$r]=array(
+ $this->import_code[$r] = $this->rights_class.'_'.$r;
+ $this->import_label[$r] = "CatSupLinks"; // Translation key
+ $this->import_icon[$r] = $this->picto;
+ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
+ $this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur');
+ $this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"Supplier*");
+ $this->import_regex_array[$r] = array(
'cs.fk_categorie'=>'rowid@'.MAIN_DB_PREFIX.'categorie:type=1',
'cs.fk_soc'=>'rowid@'.MAIN_DB_PREFIX.'societe:fournisseur>0'
);
- $this->import_convertvalue_array[$r]=array(
- 'cs.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'),
- 'cs.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty')
+ $this->import_convertvalue_array[$r] = array(
+ 'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
+ 'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty')
);
- $this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_soc'=>"MyBigCompany");
+ $this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany");
}
}
diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php
index fe846c1fd4c..3b8a7aa3f8b 100644
--- a/htdocs/core/modules/modContrat.class.php
+++ b/htdocs/core/modules/modContrat.class.php
@@ -165,7 +165,7 @@ class modContrat extends DolibarrModules
$this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode',
's.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode',
's.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra',
- 'co.rowid'=>"Id",'co.ref'=>"Ref",'co.datec'=>"DateCreation",'co.date_contrat'=>"DateContract",'co.mise_en_service'=>"ContractStartDate",
+ 'co.rowid'=>"Id",'co.ref'=>"Ref",'co.datec'=>"DateCreation",'co.date_contrat'=>"DateContract",
'co.fin_validite'=>"ContractEndDate",'co.date_cloture'=>"Closing",'co.note_private'=>"NotePrivate",'co.note_public'=>"NotePublic",
'cod.rowid'=>'LineId','cod.label'=>"LineLabel",'cod.description'=>"LineDescription",'cod.price_ht'=>"LineUnitPrice",'cod.tva_tx'=>"LineVATRate",
'cod.qty'=>"LineQty",'cod.total_ht'=>"LineTotalHT",'cod.total_tva'=>"LineTotalVAT",'cod.total_ttc'=>"LineTotalTTC",
@@ -175,7 +175,7 @@ class modContrat extends DolibarrModules
$this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company',
's.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company',
's.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company',
- 'co.rowid'=>"contract",'co.ref'=>"contract",'co.datec'=>"contract",'co.date_contrat'=>"contract",'co.mise_en_service'=>"contract",
+ 'co.rowid'=>"contract",'co.ref'=>"contract",'co.datec'=>"contract",'co.date_contrat'=>"contract",
'co.fin_validite'=>"contract",'co.date_cloture'=>"contract",'co.note_private'=>"contract",'co.note_public'=>"contract",
'cod.rowid'=>'contract_line','cod.label'=>"contract_line",'cod.description'=>"contract_line",'cod.price_ht'=>"contract_line",'cod.tva_tx'=>"contract_line",
'cod.qty'=>"contract_line",'cod.total_ht'=>"contract_line",'cod.total_tva'=>"contract_line",'cod.total_ttc'=>"contract_line",
@@ -185,7 +185,7 @@ class modContrat extends DolibarrModules
$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text',
's.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text',
's.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text',
- 'co.ref'=>"Text",'co.datec'=>"Date",'co.date_contrat'=>"Date",'co.mise_en_service'=>"Date",
+ 'co.ref'=>"Text",'co.datec'=>"Date",'co.date_contrat'=>"Date",
'co.fin_validite'=>"Date",'co.date_cloture'=>"Date",'co.note_private'=>"Text",'co.note_public'=>"Text",
'cod.label'=>"Text",'cod.description'=>"Text",'cod.price_ht'=>"Numeric",'cod.tva_tx'=>"Numeric",
'cod.qty'=>"Numeric",'cod.total_ht'=>"Numeric",'cod.total_tva'=>"Numeric",'cod.total_ttc'=>"Numeric",
diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php
index 42b4a8ef2b2..f4999f309c2 100644
--- a/htdocs/core/modules/modDon.class.php
+++ b/htdocs/core/modules/modDon.class.php
@@ -91,10 +91,10 @@ class modDon extends DolibarrModules
$this->const[$r][4] = 0;
$r++;
- $this->const[$r][0] = "DONATION_ART885";
+ $this->const[$r][0] = "DONATION_ART978";
$this->const[$r][1] = "yesno";
$this->const[$r][2] = "0";
- $this->const[$r][3] = 'Option Française - Eligibilité Art885-0 V bis du CGI';
+ $this->const[$r][3] = 'Option Française - Eligibilité Art978 du CGI';
$this->const[$r][4] = 0;
$r++;
diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php
index b0f7dd94ae8..984e28f4e31 100644
--- a/htdocs/core/modules/modFacture.class.php
+++ b/htdocs/core/modules/modFacture.class.php
@@ -216,7 +216,8 @@ class modFacture extends DolibarrModules
's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer',
'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT",
- 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LocalTax1', 'f.localtax2'=>'LocalTax2', 'none.rest'=>'Rest', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus',
+ 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LocalTax1', 'f.localtax2'=>'LocalTax2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment',
+ 'none.rest'=>'Rest',
'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',
'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
'fd.subprice'=>"LineUnitPrice", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.total_ht'=>"LineTotalHT", 'fd.total_tva'=>"LineTotalVAT",
@@ -241,7 +242,8 @@ class modFacture extends DolibarrModules
's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',
's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
'f.rowid'=>'Numeric', 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",
- 'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'none.rest'=>"NumericCompute", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric',
+ 'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', 'f.close_code'=>'Text', 'f.close_note'=>'Text',
+ 'none.rest'=>"NumericCompute",
'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
'pj.ref'=>'Text', 'pj.title'=>'Text', 'fd.rowid'=>'Numeric', 'fd.label'=>'Text', 'fd.description'=>"Text", 'fd.subprice'=>"Numeric", 'fd.tva_tx'=>"Numeric",
'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_tva'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.date_start'=>"Date", 'fd.date_end'=>"Date",
@@ -263,7 +265,7 @@ class modFacture extends DolibarrModules
'f.fk_user_author'=>'user', 'uc.login'=>'user', 'f.fk_user_valid'=>'user', 'uv.login'=>'user'
);
$this->export_special_array[$r] = array('none.rest'=>'getRemainToPay');
- $this->export_dependencies_array[$r] = array('invoice_line'=>'fd.rowid', 'product'=>'fd.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
+ $this->export_dependencies_array[$r] = array('invoice_line'=>'fd.rowid', 'product'=>'fd.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc', 'f.close_code')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
$keyforselect = 'facture'; $keyforelement = 'invoice'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$keyforselect = 'facturedet'; $keyforelement = 'invoice_line'; $keyforaliasextra = 'extra2';
@@ -289,6 +291,7 @@ class modFacture extends DolibarrModules
if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
$r++;
+
$this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r] = 'CustomersInvoicesAndPayments'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r] = 'invoice';
@@ -300,7 +303,8 @@ class modFacture extends DolibarrModules
's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer',
'f.type'=>"Type", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>"DateDue", 'f.total'=>"TotalHT",
- 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LocalTax1', 'f.localtax2'=>'LocalTax2', 'none.rest'=>'Rest', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus',
+ 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.localtax1'=>'LocalTax1', 'f.localtax2'=>'LocalTax2', 'f.paye'=>"InvoicePaidCompletely", 'f.fk_statut'=>'InvoiceStatus', 'f.close_code'=>'EarlyClosingReason', 'f.close_note'=>'EarlyClosingComment',
+ 'none.rest'=>'Rest',
'f.note_private'=>"NotePrivate", 'f.note_public'=>"NotePublic", 'f.fk_user_author'=>'CreatedById', 'uc.login'=>'CreatedByLogin',
'f.fk_user_valid'=>'ValidatedById', 'uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', 'p.rowid'=>'PaymentId', 'p.ref'=>'PaymentRef',
'p.amount'=>'AmountPayment', 'pf.amount'=>'AmountPaymentDistributedOnInvoice', 'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber',
@@ -325,9 +329,10 @@ class modFacture extends DolibarrModules
's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text',
's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
'f.rowid'=>"Numeric", 'f.ref'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date",
- 'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'none.rest'=>'NumericCompute', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status',
+ 'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'f.localtax1'=>'Numeric', 'f.localtax2'=>'Numeric', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.close_code'=>'Text', 'f.close_note'=>'Text',
+ 'none.rest'=>'NumericCompute',
'f.note_private'=>"Text", 'f.note_public'=>"Text", 'f.fk_user_author'=>'Numeric', 'uc.login'=>'Text', 'f.fk_user_valid'=>'Numeric', 'uv.login'=>'Text',
- 'pj.ref'=>'Text', 'p.amount'=>'Numeric', 'pf.amount'=>'Numeric', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 'p.title'=>'Text', 'p.datep'=>'Date', 'p.num_paiement'=>'Numeric',
+ 'pj.ref'=>'Text', 'pj.title'=>'Text', 'p.amount'=>'Numeric', 'pf.amount'=>'Numeric', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 'p.title'=>'Text', 'p.datep'=>'Date', 'p.num_paiement'=>'Numeric',
'p.fk_bank'=>'Numeric', 'p.note'=>'Text', 'pt.code'=>'Text', 'pt.libelle'=>'text', 'ba.ref'=>'Text'
);
if (! empty($conf->cashdesk->enabled) || ! empty($conf->takepos->enabled) || ! empty($conf->global->INVOICE_SHOW_POS))
@@ -338,12 +343,12 @@ class modFacture extends DolibarrModules
$this->export_entities_array[$r] = array(
's.rowid'=>"company", 's.nom'=>'company', 's.code_client'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 'cd.nom'=>'company', 's.phone'=>'company',
's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company',
- 's.tva_intra'=>'company', 'pj.ref'=>'project', 'p.title'=>'project', 'p.rowid'=>'payment', 'p.ref'=>'payment', 'p.amount'=>'payment', 'pf.amount'=>'payment', 'p.datep'=>'payment',
+ 's.tva_intra'=>'company', 'pj.ref'=>'project', 'pj.title'=>'project', 'p.rowid'=>'payment', 'p.ref'=>'payment', 'p.amount'=>'payment', 'pf.amount'=>'payment', 'p.datep'=>'payment',
'p.num_paiement'=>'payment', 'pt.code'=>'payment', 'pt.libelle'=>'payment', 'p.note'=>'payment', 'f.fk_user_author'=>'user', 'uc.login'=>'user',
'f.fk_user_valid'=>'user', 'uv.login'=>'user', 'p.fk_bank'=>'account', 'ba.ref'=>'account'
);
$this->export_special_array[$r] = array('none.rest'=>'getRemainToPay');
- $this->export_dependencies_array[$r] = array('payment'=>'p.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
+ $this->export_dependencies_array[$r] = array('payment'=>'p.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc', 'f.close_code')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them, or just to have field we need
$keyforselect = 'facture'; $keyforelement = 'invoice'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_sql_start[$r]='SELECT DISTINCT ';
diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php
index 2042e8b35da..779f60e26da 100644
--- a/htdocs/core/modules/modFournisseur.class.php
+++ b/htdocs/core/modules/modFournisseur.class.php
@@ -25,7 +25,7 @@
* \ingroup fournisseur
* \brief Description and activation file for module Supplier
*/
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
@@ -58,7 +58,7 @@ class modFournisseur extends DolibarrModules
$this->version = 'dolibarr';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
- $this->picto='company';
+ $this->picto = 'company';
// Data directories to create when module is enabled
$this->dirs = array(
@@ -79,7 +79,7 @@ class modFournisseur extends DolibarrModules
// Constants
$this->const = array();
- $r=0;
+ $r = 0;
$this->const[$r][0] = "COMMANDE_SUPPLIER_ADDON_PDF";
$this->const[$r][1] = "chaine";
@@ -120,19 +120,19 @@ class modFournisseur extends DolibarrModules
// Boxes
$this->boxes = array(
- 0=>array('file'=>'box_graph_invoices_supplier_permonth.php','enabledbydefaulton'=>'Home'),
- 1=>array('file'=>'box_graph_orders_supplier_permonth.php','enabledbydefaulton'=>'Home'),
- 2=>array('file'=>'box_fournisseurs.php','enabledbydefaulton'=>'Home'),
- 3=>array('file'=>'box_factures_fourn_imp.php','enabledbydefaulton'=>'Home'),
- 4=>array('file'=>'box_factures_fourn.php','enabledbydefaulton'=>'Home'),
- 5=>array('file'=>'box_supplier_orders.php','enabledbydefaulton'=>'Home'),
- 6=>array('file'=>'box_supplier_orders_awaiting_reception.php','enabledbydefaulton'=>'Home'),
+ 0=>array('file'=>'box_graph_invoices_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),
+ 1=>array('file'=>'box_graph_orders_supplier_permonth.php', 'enabledbydefaulton'=>'Home'),
+ 2=>array('file'=>'box_fournisseurs.php', 'enabledbydefaulton'=>'Home'),
+ 3=>array('file'=>'box_factures_fourn_imp.php', 'enabledbydefaulton'=>'Home'),
+ 4=>array('file'=>'box_factures_fourn.php', 'enabledbydefaulton'=>'Home'),
+ 5=>array('file'=>'box_supplier_orders.php', 'enabledbydefaulton'=>'Home'),
+ 6=>array('file'=>'box_supplier_orders_awaiting_reception.php', 'enabledbydefaulton'=>'Home'),
);
// Permissions
$this->rights = array();
$this->rights_class = 'fournisseur';
- $r=0;
+ $r = 0;
$r++;
$this->rights[$r][0] = 1181;
@@ -205,11 +205,11 @@ class modFournisseur extends DolibarrModules
$this->rights[$r][4] = 'commande';
$this->rights[$r][5] = 'supprimer';
- if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
+ if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
{
$r++;
$this->rights[$r][0] = 1190;
- $this->rights[$r][1] = 'Approve supplier order (second level)'; // $langs->trans("Permission1190");
+ $this->rights[$r][1] = 'Approve supplier order (second level)'; // $langs->trans("Permission1190");
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'commande';
@@ -275,27 +275,28 @@ class modFournisseur extends DolibarrModules
// Menus
//-------
- $this->menu = 1; // This module add menu entries. They are coded into menu manager.
+ $this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports
//--------
- $r=0;
+ $r = 0;
$r++;
- $this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='Vendor invoices and lines of invoices';
- $this->export_icon[$r]='bill';
- $this->export_permission[$r]=array(array("fournisseur","facture","export"));
- $this->export_fields_array[$r]=array(
- 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
- 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra',
- 'f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>'DateMaxPayment',
- 'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",
- 'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",
- 'fd.total_ttc'=>"LineTotalTTC",'fd.tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId',
- 'p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_buy'=>'ProductAccountancyBuyCode','project.rowid'=>'ProjectId',
- 'project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
+ $this->export_code[$r] = $this->rights_class.'_'.$r;
+ $this->export_label[$r] = 'Vendor invoices and lines of invoices';
+ $this->export_icon[$r] = 'bill';
+ $this->export_permission[$r] = array(array("fournisseur", "facture", "export"));
+ $this->export_fields_array[$r] = array(
+ 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
+ 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
+ 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
+ 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_supplier'=>"RefSupplier", 'f.datec'=>"InvoiceDateCreation", 'f.datef'=>"DateInvoice", 'f.date_lim_reglement'=>'DateMaxPayment',
+ 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.paye'=>"InvoicePaid", 'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote",
+ 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT",
+ 'fd.total_ttc'=>"LineTotalTTC", 'fd.tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.fk_product'=>'ProductId',
+ 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'p.accountancy_code_buy'=>'ProductAccountancyBuyCode', 'project.rowid'=>'ProjectId',
+ 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
);
//$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text',
@@ -303,122 +304,123 @@ class modFournisseur extends DolibarrModules
// 'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",
// 'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text'
//);
- $this->export_TypeFields_array[$r]=array(
- 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text',
- 's.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>'Date','f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",
- 'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",
- 'fd.total_ttc'=>"Numeric",'fd.tva'=>"Numeric",'fd.product_type'=>'Numeric','fd.fk_product'=>'List:product:label',
- 'p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text'
+ $this->export_TypeFields_array[$r] = array(
+ 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text',
+ 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>'Date',
+ 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text", 'fd.description'=>"Text", 'fd.tva_tx'=>"Text",
+ 'fd.qty'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.tva'=>"Numeric", 'fd.product_type'=>'Numeric', 'fd.fk_product'=>'List:product:label',
+ 'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text'
);
- $this->export_entities_array[$r]=array(
- 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company',
- 's.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",
- 'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>'invoice','f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice',
- 'f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.remise_percent'=>"invoice_line",
- 'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product',
- 'p.ref'=>'product','p.label'=>'product','p.accountancy_code_buy'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'
+ $this->export_entities_array[$r] = array(
+ 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company',
+ 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company', 'f.rowid'=>"invoice",
+ 'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice", 'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.date_lim_reglement'=>'invoice', 'f.total_ht'=>"invoice", 'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice",
+ 'f.paye'=>"invoice", 'f.fk_statut'=>'invoice', 'f.note_public'=>"invoice", 'fd.rowid'=>'invoice_line', 'fd.description'=>"invoice_line", 'fd.tva_tx'=>"invoice_line", 'fd.qty'=>"invoice_line",
+ 'fd.remise_percent'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva'=>"invoice_line", 'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product',
+ 'p.ref'=>'product', 'p.label'=>'product', 'p.accountancy_code_buy'=>'product', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'
);
- $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
+ $this->export_dependencies_array[$r] = array('invoice_line'=>'fd.rowid', 'product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields object
- $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")";
- $resql=$this->db->query($sql);
+ $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")";
+ $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
- $fieldname='extra.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $typeFilter="Text";
- switch($obj->type)
+ $fieldname = 'extra.'.$obj->name;
+ $fieldlabel = ucfirst($obj->label);
+ $typeFilter = "Text";
+ switch ($obj->type)
{
case 'int':
case 'double':
case 'price':
- $typeFilter="Numeric";
+ $typeFilter = "Numeric";
break;
case 'date':
case 'datetime':
- $typeFilter="Date";
+ $typeFilter = "Date";
break;
case 'boolean':
- $typeFilter="Boolean";
+ $typeFilter = "Boolean";
break;
case 'sellist':
- $tmp='';
- $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
- if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
- if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
+ $tmp = '';
+ $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
+ if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
+ if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
break;
}
- $this->export_fields_array[$r][$fieldname]=$fieldlabel;
- $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
- $this->export_entities_array[$r][$fieldname]='invoice';
+ $this->export_fields_array[$r][$fieldname] = $fieldlabel;
+ $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
+ $this->export_entities_array[$r][$fieldname] = 'invoice';
}
}
// End add extra fields
// Add extra fields line
- $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")";
- $resql=$this->db->query($sql);
+ $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")";
+ $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
- $fieldname='extraline.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $typeFilter="Text";
- switch($obj->type)
+ $fieldname = 'extraline.'.$obj->name;
+ $fieldlabel = ucfirst($obj->label);
+ $typeFilter = "Text";
+ switch ($obj->type)
{
case 'int':
case 'double':
case 'price':
- $typeFilter="Numeric";
+ $typeFilter = "Numeric";
break;
case 'date':
case 'datetime':
- $typeFilter="Date";
+ $typeFilter = "Date";
break;
case 'boolean':
- $typeFilter="Boolean";
+ $typeFilter = "Boolean";
break;
case 'sellist':
- $tmp='';
- $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
- if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
- if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
+ $tmp = '';
+ $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
+ if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
+ if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
break;
}
- $this->export_fields_array[$r][$fieldname]=$fieldlabel;
- $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
- $this->export_entities_array[$r][$fieldname]='invoice_line';
+ $this->export_fields_array[$r][$fieldname] = $fieldlabel;
+ $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
+ $this->export_entities_array[$r][$fieldname] = 'invoice_line';
}
}
// End add extra fields line
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
- if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
- $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
- $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
- $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
- $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')';
- if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
+ if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
+ $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture_fourn as f';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
+ $this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'facture_fourn_det as fd';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_det_extrafields as extraline ON fd.rowid = extraline.fk_object';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
+ $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture_fourn';
+ $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';
+ if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
$r++;
- $this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='Factures fournisseurs et reglements';
- $this->export_icon[$r]='bill';
- $this->export_permission[$r]=array(array("fournisseur","facture","export"));
- $this->export_fields_array[$r]=array(
- 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
- 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
- 's.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.ref_supplier'=>"RefSupplier",'f.datec'=>"InvoiceDateCreation",
- 'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.total_tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",
- 'f.fk_statut'=>'InvoiceStatus','f.note_public'=>"InvoiceNote",'p.rowid'=>'PaymentId','pf.amount'=>'AmountPayment',
- 'p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
+ $this->export_code[$r] = $this->rights_class.'_'.$r;
+ $this->export_label[$r] = 'Factures fournisseurs et reglements';
+ $this->export_icon[$r] = 'bill';
+ $this->export_permission[$r] = array(array("fournisseur", "facture", "export"));
+ $this->export_fields_array[$r] = array(
+ 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
+ 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
+ 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
+ 'f.rowid'=>"InvoiceId", 'f.ref'=>"InvoiceRef", 'f.ref_supplier'=>"RefSupplier", 'f.datec'=>"InvoiceDateCreation",
+ 'f.datef'=>"DateInvoice", 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.total_tva'=>"TotalVAT", 'f.paye'=>"InvoicePaid",
+ 'f.fk_statut'=>'InvoiceStatus', 'f.note_public'=>"InvoiceNote", 'p.rowid'=>'PaymentId', 'pf.amount'=>'AmountPayment',
+ 'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
);
//$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:CompanyName",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text',
@@ -426,200 +428,201 @@ class modFournisseur extends DolibarrModules
// 'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",
// 'pf.amount'=>'Numeric','p.datep'=>'Date','p.num_paiement'=>'Numeric'
//);
- $this->export_TypeFields_array[$r]=array(
- 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text',
- 's.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Numeric",
- 'f.total_ttc'=>"Numeric",'f.total_tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Numeric',
- 'p.datep'=>'Date','p.num_paiement'=>'Numeric','project.ref'=>'Text','project.title'=>'Text'
+ $this->export_TypeFields_array[$r] = array(
+ 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text',
+ 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.total_ht'=>"Numeric",
+ 'f.total_ttc'=>"Numeric", 'f.total_tva'=>"Numeric", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', 'f.note_public'=>"Text", 'pf.amount'=>'Numeric',
+ 'p.datep'=>'Date', 'p.num_paiement'=>'Numeric', 'project.ref'=>'Text', 'project.title'=>'Text'
);
- $this->export_entities_array[$r]=array(
- 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company',
- 's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company',
- 'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",
- 'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment',
- 'p.datep'=>'payment','p.num_paiement'=>'payment','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project');
- $this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
+ $this->export_entities_array[$r] = array(
+ 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company',
+ 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company',
+ 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company',
+ 'f.rowid'=>"invoice", 'f.ref'=>"invoice", 'f.ref_supplier'=>"invoice", 'f.datec'=>"invoice", 'f.datef'=>"invoice", 'f.total_ht'=>"invoice",
+ 'f.total_ttc'=>"invoice", 'f.total_tva'=>"invoice", 'f.paye'=>"invoice", 'f.fk_statut'=>'invoice', 'f.note_public'=>"invoice", 'p.rowid'=>'payment', 'pf.amount'=>'payment',
+ 'p.datep'=>'payment', 'p.num_paiement'=>'payment', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project');
+ $this->export_dependencies_array[$r] = array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields object
- $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")";
- $resql=$this->db->query($sql);
+ $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")";
+ $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
- $fieldname='extra.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $typeFilter="Text";
- switch($obj->type)
+ $fieldname = 'extra.'.$obj->name;
+ $fieldlabel = ucfirst($obj->label);
+ $typeFilter = "Text";
+ switch ($obj->type)
{
case 'int':
case 'double':
case 'price':
- $typeFilter="Numeric";
+ $typeFilter = "Numeric";
break;
case 'date':
case 'datetime':
- $typeFilter="Date";
+ $typeFilter = "Date";
break;
case 'boolean':
- $typeFilter="Boolean";
+ $typeFilter = "Boolean";
break;
case 'sellist':
- $tmp='';
- $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
- if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift(array_keys($tmpparam['options']));
- if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
+ $tmp = '';
+ $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
+ if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift(array_keys($tmpparam['options']));
+ if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
break;
}
- $this->export_fields_array[$r][$fieldname]=$fieldlabel;
- $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
- $this->export_entities_array[$r][$fieldname]='invoice';
+ $this->export_fields_array[$r][$fieldname] = $fieldlabel;
+ $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
+ $this->export_entities_array[$r][$fieldname] = 'invoice';
}
}
// End add extra fields object
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
- if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
- $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture_fourn as f';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
- $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid';
- $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice').')';
- if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
+ if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
+ $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture_fourn as f';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn_extrafields as extra ON f.rowid = extra.fk_object';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn as p ON pf.fk_paiementfourn = p.rowid';
+ $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';
+ $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_invoice').')';
+ if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
// Order
$r++;
- $this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='Purchase Orders and lines of purchase orders';
- $this->export_icon[$r]='order';
- $this->export_permission[$r]=array(array("fournisseur","commande","export"));
- $this->export_fields_array[$r]=array(
- 's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone',
- 's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra',
- 'f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.date_livraison'=>"DateDeliveryPlanned",
- 'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.date_approve'=>'DateApprove','f.date_approve2'=>'DateApprove2',
- 'f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'ua1.login'=>'ApprovedBy','ua2.login'=>'ApprovedBy2','fd.rowid'=>'LineId','fd.description'=>"LineDescription",
- 'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",
- 'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.ref'=>'RefSupplier','fd.fk_product'=>'ProductId',
- 'p.ref'=>'ProductRef','p.label'=>'ProductLabel','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'
+ $this->export_code[$r] = $this->rights_class.'_'.$r;
+ $this->export_label[$r] = 'Purchase Orders and lines of purchase orders';
+ $this->export_icon[$r] = 'order';
+ $this->export_permission[$r] = array(array("fournisseur", "commande", "export"));
+ $this->export_fields_array[$r] = array(
+ 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone',
+ 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6', 's.tva_intra'=>'VATIntra',
+ 'f.rowid'=>"OrderId", 'f.ref'=>"Ref", 'f.ref_supplier'=>"RefSupplier", 'f.date_creation'=>"DateCreation", 'f.date_commande'=>"OrderDate", 'f.date_livraison'=>"DateDeliveryPlanned",
+ 'f.total_ht'=>"TotalHT", 'f.total_ttc'=>"TotalTTC", 'f.tva'=>"TotalVAT", 'f.fk_statut'=>'Status', 'f.date_approve'=>'DateApprove', 'f.date_approve2'=>'DateApprove2',
+ 'f.note_public'=>"NotePublic", 'f.note_private'=>"NotePrivate", 'ua1.login'=>'ApprovedBy', 'ua2.login'=>'ApprovedBy2', 'fd.rowid'=>'LineId', 'fd.description'=>"LineDescription",
+ 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.remise_percent'=>"Discount", 'fd.total_ht'=>"LineTotalHT", 'fd.total_ttc'=>"LineTotalTTC",
+ 'fd.total_tva'=>"LineTotalVAT", 'fd.product_type'=>'TypeOfLineServiceOrProduct', 'fd.ref'=>'RefSupplier', 'fd.fk_product'=>'ProductId',
+ 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'project.rowid'=>'ProjectId', 'project.ref'=>'ProjectRef', 'project.title'=>'ProjectLabel'
);
if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED))
{
unset($this->export_fields_array['f.date_approve2']);
unset($this->export_fields_array['ua2.login']);
}
- $this->export_TypeFields_array[$r]=array(
- 's.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text',
- 's.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",
- 'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.date_livraison'=>"Date",'f.total_ht'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",
- 'f.fk_statut'=>'Status','f.date_approve'=>'Date','f.date_approve2'=>'Date','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",
- 'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.remise_percent'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.total_tva'=>"Numeric",
- 'fd.product_type'=>'Numeric','fd.ref'=>'Text','fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','project.ref'=>'Text','project.title'=>'Text'
+ $this->export_TypeFields_array[$r] = array(
+ 's.rowid'=>"company", 's.nom'=>'Text', 's.address'=>'Text', 's.cp'=>'Text', 's.ville'=>'Text', 'c.code'=>'Text', 's.tel'=>'Text', 's.siren'=>'Text',
+ 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text', 's.tva_intra'=>'Text', 'f.ref'=>"Text", 'f.ref_supplier'=>"Text",
+ 'f.date_creation'=>"Date", 'f.date_commande'=>"Date", 'f.date_livraison'=>"Date", 'f.total_ht'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric",
+ 'f.fk_statut'=>'Status', 'f.date_approve'=>'Date', 'f.date_approve2'=>'Date', 'f.note_public'=>"Text", 'f.note_private'=>"Text", 'fd.description'=>"Text",
+ 'fd.tva_tx'=>"Numeric", 'fd.qty'=>"Numeric", 'fd.remise_percent'=>"Numeric", 'fd.total_ht'=>"Numeric", 'fd.total_ttc'=>"Numeric", 'fd.total_tva'=>"Numeric",
+ 'fd.product_type'=>'Numeric', 'fd.ref'=>'Text', 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text', 'project.ref'=>'Text', 'project.title'=>'Text'
);
- $this->export_entities_array[$r]=array(
- 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company',
- 's.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','ua1.login'=>'user',
- 'ua2.login'=>'user','fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",
- 'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.ref'=>'order_line','fd.fk_product'=>'product',
- 'p.ref'=>'product','p.label'=>'product','project.rowid'=>'project','project.ref'=>'project','project.title'=>'project'
+ $this->export_entities_array[$r] = array(
+ 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'c.code'=>'company', 's.phone'=>'company', 's.siren'=>'company',
+ 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company', 's.tva_intra'=>'company', 'ua1.login'=>'user',
+ 'ua2.login'=>'user', 'fd.rowid'=>'order_line', 'fd.description'=>"order_line", 'fd.tva_tx'=>"order_line", 'fd.qty'=>"order_line", 'fd.remise_percent'=>"order_line",
+ 'fd.total_ht'=>"order_line", 'fd.total_ttc'=>"order_line", 'fd.total_tva'=>"order_line", 'fd.product_type'=>'order_line', 'fd.ref'=>'order_line', 'fd.fk_product'=>'product',
+ 'p.ref'=>'product', 'p.label'=>'product', 'project.rowid'=>'project', 'project.ref'=>'project', 'project.title'=>'project'
);
- $this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
+ $this->export_dependencies_array[$r] = array('order_line'=>'fd.rowid', 'product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Add extra fields object
- $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")";
- $resql=$this->db->query($sql);
+ $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")";
+ $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
- $fieldname='extra.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $typeFilter="Text";
- switch($obj->type)
+ $fieldname = 'extra.'.$obj->name;
+ $fieldlabel = ucfirst($obj->label);
+ $typeFilter = "Text";
+ switch ($obj->type)
{
case 'int':
case 'double':
case 'price':
- $typeFilter="Numeric";
+ $typeFilter = "Numeric";
break;
case 'date':
case 'datetime':
- $typeFilter="Date";
+ $typeFilter = "Date";
break;
case 'boolean':
- $typeFilter="Boolean";
+ $typeFilter = "Boolean";
break;
case 'sellist':
- $tmp='';
- $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
- $tmpkey=array_keys($tmpparam['options']);
- if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp=array_shift($tmpkey);
- if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
+ $tmp = '';
+ $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
+ $tmpkey = array_keys($tmpparam['options']);
+ if ($tmpparam['options'] && is_array($tmpparam['options'])) $tmp = array_shift($tmpkey);
+ if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
break;
}
- $this->export_fields_array[$r][$fieldname]=$fieldlabel;
- $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
- $this->export_entities_array[$r][$fieldname]='order';
+ $this->export_fields_array[$r][$fieldname] = $fieldlabel;
+ $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
+ $this->export_entities_array[$r][$fieldname] = 'order';
}
}
// End add extra fields object
// Add extra fields line
- $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.")";
- $resql=$this->db->query($sql);
+ $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.")";
+ $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
- $fieldname='extraline.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $typeFilter="Text";
- switch($obj->type)
+ $fieldname = 'extraline.'.$obj->name;
+ $fieldlabel = ucfirst($obj->label);
+ $typeFilter = "Text";
+ switch ($obj->type)
{
case 'int':
case 'double':
case 'price':
- $typeFilter="Numeric";
+ $typeFilter = "Numeric";
break;
case 'date':
case 'datetime':
- $typeFilter="Date";
+ $typeFilter = "Date";
break;
case 'boolean':
- $typeFilter="Boolean";
+ $typeFilter = "Boolean";
break;
case 'sellist':
- $tmp='';
- $tmpparam=unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
+ $tmp = '';
+ $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
if ($tmpparam['options'] && is_array($tmpparam['options'])) {
- $tmpparam_param_key=array_keys($tmpparam['options']);
- $tmp=array_shift($tmpparam_param_key);
+ $tmpparam_param_key = array_keys($tmpparam['options']);
+ $tmp = array_shift($tmpparam_param_key);
}
- if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
+ if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
break;
}
- $this->export_fields_array[$r][$fieldname]=$fieldlabel;
- $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
- $this->export_entities_array[$r][$fieldname]='order_line';
+ $this->export_fields_array[$r][$fieldname] = $fieldlabel;
+ $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
+ $this->export_entities_array[$r][$fieldname] = 'order_line';
}
}
// End add extra fields line
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
- if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
- $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua1 ON ua1.rowid = f.fk_user_approve';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua2 ON ua2.rowid = f.fk_user_approve2';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
- $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
- $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
- $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order').')';
- if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
+ if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,';
+ $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseur as f';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as project on (f.fk_projet = project.rowid)';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua1 ON ua1.rowid = f.fk_user_approve';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua2 ON ua2.rowid = f.fk_user_approve2';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,';
+ $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet_extrafields as extraline ON fd.rowid = extraline.fk_object';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
+ $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande';
+ $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('supplier_order').')';
+ if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
}
@@ -638,19 +641,19 @@ class modFournisseur extends DolibarrModules
$this->remove($options);
//ODT template
- $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_orders/template_supplier_order.odt';
- $dirodt=DOL_DATA_ROOT.'/doctemplates/supplier_orders';
- $dest=$dirodt.'/template_supplier_order.odt';
+ $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_orders/template_supplier_order.odt';
+ $dirodt = DOL_DATA_ROOT.'/doctemplates/supplier_orders';
+ $dest = $dirodt.'/template_supplier_order.odt';
- if (file_exists($src) && ! file_exists($dest))
+ if (file_exists($src) && !file_exists($dest))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt);
- $result=dol_copy($src, $dest, 0, 0);
+ $result = dol_copy($src, $dest, 0, 0);
if ($result < 0)
{
$langs->load("errors");
- $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
+ $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0;
}
}
diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php
index c387ed69e6e..5edd3bd3200 100644
--- a/htdocs/core/modules/modLabel.class.php
+++ b/htdocs/core/modules/modLabel.class.php
@@ -47,7 +47,7 @@ class modLabel extends DolibarrModules
$this->module_position = '75';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
- $this->description = "Gestion des etiquettes";
+ $this->description = "Management of stickers";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'development';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
@@ -77,17 +77,17 @@ class modLabel extends DolibarrModules
$this->rights_class = 'label';
$this->rights[1][0] = 601; // id de la permission
- $this->rights[1][1] = 'Lire les etiquettes'; // libelle de la permission
+ $this->rights[1][1] = 'Read stickers';
$this->rights[1][3] = 1; // La permission est-elle une permission par defaut
$this->rights[1][4] = 'lire';
$this->rights[2][0] = 602; // id de la permission
- $this->rights[2][1] = 'Creer/modifier les etiquettes'; // libelle de la permission
+ $this->rights[2][1] = 'Create/modify stickers';
$this->rights[2][3] = 0; // La permission est-elle une permission par defaut
$this->rights[2][4] = 'creer';
$this->rights[4][0] = 609; // id de la permission
- $this->rights[4][1] = 'Supprimer les etiquettes'; // libelle de la permission
+ $this->rights[4][1] = 'Delete stickers';
$this->rights[4][3] = 0; // La permission est-elle une permission par defaut
$this->rights[4][4] = 'supprimer';
}
diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php
index 16ee16984d8..1c52ad866c2 100644
--- a/htdocs/core/modules/modModuleBuilder.class.php
+++ b/htdocs/core/modules/modModuleBuilder.class.php
@@ -45,6 +45,7 @@ class modModuleBuilder extends DolibarrModules
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
$this->family = "technic";
+ $this->module_position = '90';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "A RAD (Rapid Application Development) tool to help developers to build their own module.";
@@ -82,6 +83,21 @@ class modModuleBuilder extends DolibarrModules
//------
$this->boxes = array();
+ // Permissions
+ //------------
+ $this->rights = array(); // Permission array used by this module
+ $this->rights_class = 'modulebuilder';
+
+ $r=0;
+
+ $r++;
+ $this->rights[$r][0] = 3301;
+ $this->rights[$r][1] = 'Generate new modules';
+ $this->rights[$r][2] = 'a';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'run';
+
+
// Main menu entries
//------------------
$this->menu = array();
diff --git a/htdocs/core/modules/modMrp.class.php b/htdocs/core/modules/modMrp.class.php
index a5d58bd8333..73df7523843 100644
--- a/htdocs/core/modules/modMrp.class.php
+++ b/htdocs/core/modules/modMrp.class.php
@@ -26,7 +26,7 @@
* \ingroup mrp
* \brief Description and activation file for module Mrp
*/
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
* Description and activation class for module Mrp
@@ -40,7 +40,7 @@ class modMrp extends DolibarrModules
*/
public function __construct($db)
{
- global $langs,$conf;
+ global $langs, $conf;
$this->db = $db;
// Id for module (must be unique).
@@ -62,7 +62,7 @@ class modMrp extends DolibarrModules
// Used only if file README.md and README-LL.md not found.
$this->descriptionlong = "Module to Manage Manufacturing Orders (MO)";
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
- $this->version = 'experimental';
+ $this->version = 'dolibarr';
// Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
@@ -71,7 +71,7 @@ class modMrp extends DolibarrModules
// Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
- $this->picto='mrp';
+ $this->picto = 'mrp';
// Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
$this->module_parts = array(
// Set this to 1 if module has its own trigger directory (core/triggers)
@@ -119,13 +119,13 @@ class modMrp extends DolibarrModules
$this->hidden = false;
// List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)
$this->depends = array('modBom');
- $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
- $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
+ $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
+ $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
$this->langfiles = array("mrp");
- $this->phpmin = array(5,5); // Minimum version of PHP required by module
- $this->need_dolibarr_version = array(8,0); // Minimum version of Dolibarr required by module
- $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
- $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
+ $this->phpmin = array(5, 5); // Minimum version of PHP required by module
+ $this->need_dolibarr_version = array(8, 0); // Minimum version of Dolibarr required by module
+ $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
+ $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
//$this->automatic_activation = array('FR'=>'MrpWasAutomaticallyActivatedBecauseOfYourCountryChoice');
//$this->always_enabled = true; // If true, can't be disabled
@@ -146,9 +146,9 @@ class modMrp extends DolibarrModules
'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
)*/
- if (! isset($conf->mrp) || ! isset($conf->mrp->enabled)) {
- $conf->mrp=new stdClass();
- $conf->mrp->enabled=0;
+ if (!isset($conf->mrp) || !isset($conf->mrp->enabled)) {
+ $conf->mrp = new stdClass();
+ $conf->mrp->enabled = 0;
}
// Array to add new pages in new tabs
@@ -180,7 +180,7 @@ class modMrp extends DolibarrModules
// 'user' to add a tab in user view
// Dictionaries
- $this->dictionaries=array();
+ $this->dictionaries = array();
/* Example:
$this->dictionaries=array(
'langs'=>'mylangfile@mrp',
@@ -236,35 +236,35 @@ class modMrp extends DolibarrModules
// Permissions provided by this module
$this->rights = array();
- $r=0;
+ $r = 0;
// Add here entries to declare new permissions
/* BEGIN MODULEBUILDER PERMISSIONS */
- $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
- $this->rights[$r][1] = 'Read Manufacturing Order'; // Permission label
- $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
- $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
+ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Read Manufacturing Order'; // Permission label
+ $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
+ $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
$r++;
- $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
- $this->rights[$r][1] = 'Create/Update Manufacturing Order'; // Permission label
- $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
- $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
+ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Create/Update Manufacturing Order'; // Permission label
+ $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
+ $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
$r++;
- $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
- $this->rights[$r][1] = 'Delete Manufacturing Order'; // Permission label
- $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
- $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
+ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Delete Manufacturing Order'; // Permission label
+ $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
+ $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mrp->level1->level2)
$r++;
/* END MODULEBUILDER PERMISSIONS */
// Main menu entries to add
$this->menu = array();
- $r=0;
+ $r = 0;
// Add here entries to declare new menus
/* BEGIN MODULEBUILDER TOPMENU */
/* END MODULEBUILDER LEFTMENU MO */
// Exports profiles provided by this module
- $r=1;
+ $r = 1;
/* BEGIN MODULEBUILDER EXPORT MO */
/*
$langs->load("mrp");
@@ -284,7 +284,7 @@ class modMrp extends DolibarrModules
/* END MODULEBUILDER EXPORT MO */
// Imports profiles provided by this module
- $r=1;
+ $r = 1;
/* BEGIN MODULEBUILDER IMPORT MO */
/*
$langs->load("mrp");
@@ -316,7 +316,7 @@ class modMrp extends DolibarrModules
{
global $conf, $langs;
- $result=$this->_load_tables('/mrp/sql/');
+ $result = $this->_load_tables('/mrp/sql/');
if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
// Create extrafields during init
@@ -334,19 +334,19 @@ class modMrp extends DolibarrModules
$sql = array();
// ODT template
- $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt';
- $dirodt=DOL_DATA_ROOT.'/doctemplates/mrps';
- $dest=$dirodt.'/template_mo.odt';
+ $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mrps/template_mo.odt';
+ $dirodt = DOL_DATA_ROOT.'/doctemplates/mrps';
+ $dest = $dirodt.'/template_mo.odt';
- if (file_exists($src) && ! file_exists($dest))
+ if (file_exists($src) && !file_exists($dest))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt);
- $result=dol_copy($src, $dest, 0, 0);
+ $result = dol_copy($src, $dest, 0, 0);
if ($result < 0)
{
$langs->load("errors");
- $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
+ $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0;
}
}
diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php
index 5489e2b92ca..77d339da035 100644
--- a/htdocs/core/modules/modProjet.class.php
+++ b/htdocs/core/modules/modProjet.class.php
@@ -28,7 +28,7 @@
* \ingroup projet
* \brief Fichier de description et activation du module Projet
*/
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
@@ -58,22 +58,22 @@ class modProjet extends DolibarrModules
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->config_page_url = array("project.php@projet");
- $this->picto='project';
+ $this->picto = 'project';
// Data directories to create when module is enabled
$this->dirs = array("/projet/temp");
// Dependencies
- $this->hidden = false; // A condition to hide module
- $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
- $this->requiredby = array(); // List of module ids to disable if this one is disabled
- $this->conflictwith = array(); // List of module class names as string this module is in conflict with
- $this->phpmin = array(5,4); // Minimum version of PHP required by module
+ $this->hidden = false; // A condition to hide module
+ $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
+ $this->requiredby = array(); // List of module ids to disable if this one is disabled
+ $this->conflictwith = array(); // List of module class names as string this module is in conflict with
+ $this->phpmin = array(5, 4); // Minimum version of PHP required by module
$this->langfiles = array('projects');
// Constants
$this->const = array();
- $r=0;
+ $r = 0;
$this->const[$r][0] = "PROJECT_ADDON_PDF";
$this->const[$r][1] = "chaine";
@@ -139,7 +139,7 @@ class modProjet extends DolibarrModules
// Boxes
$this->boxes = array();
- $r=0;
+ $r = 0;
$this->boxes[$r][1] = "box_project.php";
$r++;
$this->boxes[$r][1] = "box_task.php";
@@ -148,7 +148,7 @@ class modProjet extends DolibarrModules
// Permissions
$this->rights = array();
$this->rights_class = 'projet';
- $r=0;
+ $r = 0;
$r++;
$this->rights[$r][0] = 41; // id de la permission
@@ -205,34 +205,43 @@ class modProjet extends DolibarrModules
// Menus
//-------
- $this->menu = 1; // This module add menu entries. They are coded into menu manager.
+ $this->menu = 1; // This module add menu entries. They are coded into menu manager.
//Exports
//--------
- $r=1;
+ $r = 1;
- $this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
- $this->export_permission[$r]=array(array("projet","export"));
- $this->export_dependencies_array[$r]=array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
+ $this->export_code[$r] = $this->rights_class.'_'.$r;
+ $this->export_label[$r] = 'ProjectsAndTasksLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
+ $this->export_permission[$r] = array(array("projet", "export"));
+ $this->export_dependencies_array[$r] = array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid');
- $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom::thirdparty",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label',
- 's.phone'=>'Text','s.email'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text',
- 'p.rowid'=>"List:projet:ref::project",'p.ref'=>"Text",'p.title'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.opp_amount'=>'Numeric','p.description'=>"Text",'p.entity'=>'Numeric',
- 'pt.rowid'=>'Numeric','pt.ref'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text",
- 'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text");
- $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company',
- 's.phone'=>'company','s.email'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company');
-
- $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country',
- 's.phone'=>'Phone','s.email'=>'Email','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode',
- 'p.rowid'=>"ProjectId",'p.ref'=>"RefProject",'p.title'=>'ProjectLabel', 'p.datec'=>"DateCreation",'p.dateo'=>"DateStart",'p.datee'=>"DateEnd",'p.fk_statut'=>'ProjectStatus','cls.code'=>'OpportunityStatus','p.opp_percent'=>'OpportunityProbability','p.opp_amount'=>'OpportunityAmount','p.description'=>"Description");
+ $this->export_TypeFields_array[$r] = array(
+ 's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 's.fk_pays'=>'List:c_country:label',
+ 's.phone'=>'Text', 's.email'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text',
+ 'p.rowid'=>"List:projet:ref::project", 'p.ref'=>"Text", 'p.title'=>"Text",
+ 'p.usage_opportunity'=>'Boolean', 'p.usage_task'=>'Boolean', 'p.usage_bill_time'=>'Boolean',
+ 'p.datec'=>"Date", 'p.dateo'=>"Date", 'p.datee'=>"Date", 'p.fk_statut'=>'Status', 'cls.code'=>"Text", 'p.opp_percent'=>'Numeric', 'p.opp_amount'=>'Numeric', 'p.description'=>"Text", 'p.entity'=>'Numeric',
+ 'pt.rowid'=>'Numeric', 'pt.ref'=>'Text', 'pt.label'=>'Text', 'pt.dateo'=>"Date", 'pt.datee'=>"Date", 'pt.duration_effective'=>"Duree", 'pt.planned_workload'=>"Numeric", 'pt.progress'=>"Numeric", 'pt.description'=>"Text",
+ 'ptt.rowid'=>'Numeric', 'ptt.task_date'=>'Date', 'ptt.task_duration'=>"Duree", 'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)", 'ptt.note'=>"Text"
+ );
+ $this->export_entities_array[$r] = array(
+ 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 's.fk_pays'=>'company',
+ 's.phone'=>'company', 's.email'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company'
+ );
+ $this->export_fields_array[$r] = array(
+ 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 's.fk_pays'=>'Country',
+ 's.phone'=>'Phone', 's.email'=>'Email', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode',
+ 'p.rowid'=>"ProjectId", 'p.ref'=>"RefProject", 'p.title'=>'ProjectLabel',
+ 'p.usage_opportunity'=>'ProjectFollowOpportunity', 'p.usage_task'=>'ProjectFollowTasks', 'p.usage_bill_time'=>'BillTime',
+ 'p.datec'=>"DateCreation", 'p.dateo'=>"DateStart", 'p.datee'=>"DateEnd", 'p.fk_statut'=>'ProjectStatus', 'cls.code'=>'OpportunityStatus', 'p.opp_percent'=>'OpportunityProbability', 'p.opp_amount'=>'OpportunityAmount', 'p.description'=>"Description"
+ );
// Add multicompany field
- if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
+ if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
{
- $nbofallowedentities=count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1
- if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('p.entity'=>'Entity');
+ $nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1
+ if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('p.entity'=>'Entity');
}
if (empty($conf->global->PROJECT_USE_OPPORTUNITIES))
{
@@ -242,62 +251,68 @@ class modProjet extends DolibarrModules
}
// Add fields for project
- $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array());
+ $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array());
// Add extra fields for project
- $keyforselect='projet'; $keyforelement='project'; $keyforaliasextra='extra';
+ $keyforselect = 'projet'; $keyforelement = 'project'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
// Add fields for tasks
- $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pt.rowid'=>'TaskId', 'pt.ref'=>'RefTask', 'pt.label'=>'LabelTask', 'pt.dateo'=>"TaskDateStart", 'pt.datee'=>"TaskDateEnd", 'pt.duration_effective'=>"DurationEffective", 'pt.planned_workload'=>"PlannedWorkload", 'pt.progress'=>"Progress", 'pt.description'=>"TaskDescription"));
- $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask', 'pt.ref'=>'projecttask', 'pt.label'=>'projecttask', 'pt.dateo'=>"projecttask", 'pt.datee'=>"projecttask", 'pt.duration_effective'=>"projecttask", 'pt.planned_workload'=>"projecttask", 'pt.progress'=>"projecttask", 'pt.description'=>"projecttask"));
+ $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pt.rowid'=>'TaskId', 'pt.ref'=>'RefTask', 'pt.label'=>'LabelTask', 'pt.dateo'=>"TaskDateStart", 'pt.datee'=>"TaskDateEnd", 'pt.duration_effective'=>"DurationEffective", 'pt.planned_workload'=>"PlannedWorkload", 'pt.progress'=>"Progress", 'pt.description'=>"TaskDescription"));
+ $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask', 'pt.ref'=>'projecttask', 'pt.label'=>'projecttask', 'pt.dateo'=>"projecttask", 'pt.datee'=>"projecttask", 'pt.duration_effective'=>"projecttask", 'pt.planned_workload'=>"projecttask", 'pt.progress'=>"projecttask", 'pt.description'=>"projecttask"));
// Add extra fields for task
- $keyforselect='projet_task'; $keyforelement='projecttask'; $keyforaliasextra='extra2';
+ $keyforselect = 'projet_task'; $keyforelement = 'projecttask'; $keyforaliasextra = 'extra2';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
// End add extra fields
- $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime','ptt.task_date'=>'TaskTimeDate','ptt.task_duration'=>"TimesSpent",'ptt.fk_user'=>"TaskTimeUser",'ptt.note'=>"TaskTimeNote"));
- $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time','ptt.task_date'=>'task_time','ptt.task_duration'=>"task_time",'ptt.fk_user'=>"task_time",'ptt.note'=>"task_time"));
-
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'projet as p';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task";
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
- $this->export_sql_end[$r] .=" WHERE p.entity IN (".getEntity('project').")";
+ $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.task_date'=>'TaskTimeDate', 'ptt.task_duration'=>"TimesSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote"));
+ $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('ptt.rowid'=>'task_time', 'ptt.task_date'=>'task_time', 'ptt.task_duration'=>"task_time", 'ptt.fk_user'=>"task_time", 'ptt.note'=>"task_time"));
+ if (empty($conf->global->PROJECT_HIDE_TASKS)) {
+ $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('f.ref'=>"Billed"));
+ $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('f.ref'=>"task_time"));
+ }
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'projet as p';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_extrafields as extra ON p.rowid = extra.fk_object';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_lead_status as cls ON p.fk_opp_status = cls.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task as pt ON p.rowid = pt.fk_projet";
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet_task_extrafields as extra2 ON pt.rowid = extra2.fk_object';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet_task_time as ptt ON pt.rowid = ptt.fk_task";
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON p.fk_soc = s.rowid';
+ if (empty($conf->global->PROJECT_HIDE_TASKS)) {
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON ptt.invoice_id = f.rowid';
+ }
+ $this->export_sql_end[$r] .= " WHERE p.entity IN (".getEntity('project').")";
// Import list of tasks
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
$r++;
- $this->import_code[$r]='tasksofprojects';
- $this->import_label[$r]='ImportDatasetTasks';
- $this->import_icon[$r]='task';
- $this->import_entities_array[$r]=array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon
- $this->import_tables_array[$r]=array('t'=>MAIN_DB_PREFIX.'projet_task','extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order)
- $this->import_fields_array[$r]=array('t.fk_projet'=>'ProjectRef*','t.ref'=>'RefTask*','t.label'=>'LabelTask*','t.dateo'=>"DateStart",'t.datee'=>"DateEnd",'t.planned_workload'=>"PlannedWorkload",'t.progress'=>"Progress",'t.note_private'=>"NotePrivate",'t.note_public'=>"NotePublic",'t.datec'=>"DateCreation");
+ $this->import_code[$r] = 'tasksofprojects';
+ $this->import_label[$r] = 'ImportDatasetTasks';
+ $this->import_icon[$r] = 'task';
+ $this->import_entities_array[$r] = array('t.fk_projet'=>'project'); // We define here only fields that use another icon that the one defined into import_icon
+ $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order)
+ $this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation");
// Add extra fields
- $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
- $resql=$this->db->query($sql);
+ $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")";
+ $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
- $fieldname='extra.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
+ $fieldname = 'extra.'.$obj->name;
+ $fieldlabel = ucfirst($obj->label);
+ $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
}
}
// End add extra fields
- $this->import_fieldshidden_array[$r]=array('t.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
- $this->import_convertvalue_array[$r]=array(
- 't.fk_projet'=>array('rule'=>'fetchidfromref','classfile'=>'/projet/class/project.class.php','class'=>'Project','method'=>'fetch','element'=>'Project'),
+ $this->import_fieldshidden_array[$r] = array('t.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'projet_task'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
+ $this->import_convertvalue_array[$r] = array(
+ 't.fk_projet'=>array('rule'=>'fetchidfromref', 'classfile'=>'/projet/class/project.class.php', 'class'=>'Project', 'method'=>'fetch', 'element'=>'Project'),
't.ref'=>array('rule'=>'getrefifauto')
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
- $this->import_regex_array[$r]=array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','t.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
- $this->import_examplevalues_array[$r]=array('t.fk_projet'=>'MyProjectRef','t.ref'=>"auto or TK2010-1234",'t.label'=>"My task",'t.progress'=>"0 (not started) to 100 (finished)",'t.datec'=>'1972-10-10','t.note_private'=>"My private note",'t.note_public'=>"My public note");
+ $this->import_regex_array[$r] = array('t.dateo'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datee'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 't.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
+ $this->import_examplevalues_array[$r] = array('t.fk_projet'=>'MyProjectRef', 't.ref'=>"auto or TK2010-1234", 't.label'=>"My task", 't.progress'=>"0 (not started) to 100 (finished)", 't.datec'=>'1972-10-10', 't.note_private'=>"My private note", 't.note_public'=>"My public note");
}
}
@@ -312,54 +327,54 @@ class modProjet extends DolibarrModules
*/
public function init($options = '')
{
- global $conf,$langs;
+ global $conf, $langs;
// Permissions
$this->remove($options);
//ODT template for project
- $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
- $dirodt=DOL_DATA_ROOT.'/doctemplates/projects';
- $dest=$dirodt.'/template_project.odt';
+ $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/projects/template_project.odt';
+ $dirodt = DOL_DATA_ROOT.'/doctemplates/projects';
+ $dest = $dirodt.'/template_project.odt';
- if (file_exists($src) && ! file_exists($dest))
+ if (file_exists($src) && !file_exists($dest))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt);
- $result=dol_copy($src, $dest, 0, 0);
+ $result = dol_copy($src, $dest, 0, 0);
if ($result < 0)
{
$langs->load("errors");
- $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
+ $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0;
}
}
//ODT template for tasks
- $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
- $dirodt=DOL_DATA_ROOT.'/doctemplates/tasks';
- $dest=$dirodt.'/template_task_summary.odt';
+ $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/tasks/template_task_summary.odt';
+ $dirodt = DOL_DATA_ROOT.'/doctemplates/tasks';
+ $dest = $dirodt.'/template_task_summary.odt';
- if (file_exists($src) && ! file_exists($dest))
+ if (file_exists($src) && !file_exists($dest))
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt);
- $result=dol_copy($src, $dest, 0, 0);
+ $result = dol_copy($src, $dest, 0, 0);
if ($result < 0)
{
$langs->load("errors");
- $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
+ $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0;
}
}
$sql = array();
- $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity;
- $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")";
- $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity;
- $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")";
- $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity;
- $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")";
+ $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity;
+ $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")";
+ $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity;
+ $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")";
+ $sql[] = "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity;
+ $sql[] = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")";
return $this->_init($sql, $options);
diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php
index f2d207e1983..f2fc5183668 100644
--- a/htdocs/core/modules/modReceiptPrinter.class.php
+++ b/htdocs/core/modules/modReceiptPrinter.class.php
@@ -132,13 +132,15 @@ class modReceiptPrinter extends DolibarrModules
*/
public function init($options = '')
{
- global $conf;
+ global $conf, $langs;
// Clean before activation
$this->remove($options);
$sql = array(
"CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), fk_type integer, fk_profile integer, parameter varchar(128), entity integer) ENGINE=innodb;",
"CREATE TABLE IF NOT EXISTS ".MAIN_DB_PREFIX."printer_receipt_template (rowid integer AUTO_INCREMENT PRIMARY KEY, name varchar(128), template text, entity integer) ENGINE=innodb;",
- );
+ "DELETE FROM ".MAIN_DB_PREFIX."printer_receipt_template WHERE name = '".$langs->trans('Example')."';",
+ "INSERT INTO ".MAIN_DB_PREFIX."printer_receipt_template (name,template,entity) VALUES ('".$langs->trans('Example')."', '\r\n\r\n\r\n\r\n\r\nFacture \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n', 1);",
+ );
return $this->_init($sql, $options);
}
}
diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php
index 2cc525bd8aa..b40ca3df78c 100644
--- a/htdocs/core/modules/modSociete.class.php
+++ b/htdocs/core/modules/modSociete.class.php
@@ -247,39 +247,39 @@ class modSociete extends DolibarrModules
// Menus
//-------
- $this->menu = 1; // This module add menu entries. They are coded into menu manager.
+ $this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports
//--------
- $r=0;
+ $r = 0;
// Export list of third parties and attributes
$r++;
- $this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='ExportDataset_company_1';
- $this->export_icon[$r]='company';
- $this->export_permission[$r]=array(array("societe","export"));
- $this->export_fields_array[$r]=array(
- 's.rowid'=>"Id",'s.nom'=>"Name",'s.name_alias'=>"AliasNameShort",'s.status'=>"Status",'s.client'=>"Customer",'s.fournisseur'=>"Supplier",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",
- 's.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"AccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",
- 's.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'d.nom'=>'State','c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",
- 's.url'=>"Url",'s.email'=>"Email",'s.default_lang'=>"DefaultLang",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",
- 's.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",
- 't.libelle'=>"ThirdPartyType",'ce.code'=>"Staff","cfj.libelle"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel',
- 'st.code'=>'ProspectStatus','payterm.libelle'=>'PaymentConditions','paymode.libelle'=>'PaymentMode'
+ $this->export_code[$r] = $this->rights_class.'_'.$r;
+ $this->export_label[$r] = 'ExportDataset_company_1';
+ $this->export_icon[$r] = 'company';
+ $this->export_permission[$r] = array(array("societe", "export"));
+ $this->export_fields_array[$r] = array(
+ 's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification",
+ 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode",
+ 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax",
+ 's.url'=>"Url", 's.email'=>"Email", 's.default_lang'=>"DefaultLang", 's.siren'=>"ProfId1", 's.siret'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4",
+ 's.idprof5'=>"ProfId5", 's.idprof6'=>"ProfId6", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_private'=>"NotePrivate", 's.note_public'=>"NotePublic",
+ 't.libelle'=>"ThirdPartyType", 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus", 's.fk_prospectlevel'=>'ProspectLevel',
+ 'st.code'=>'ProspectStatus', 'payterm.libelle'=>'PaymentConditions', 'paymode.libelle'=>'PaymentMode'
);
- if (! empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix']='Prefix';
- if (! empty($conf->global->PRODUIT_MULTIPRICES)) $this->export_fields_array[$r]['s.price_level']='PriceLevel';
+ if (!empty($conf->global->SOCIETE_USEPREFIX)) $this->export_fields_array[$r]['s.prefix'] = 'Prefix';
+ if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->export_fields_array[$r]['s.price_level'] = 'PriceLevel';
// Add multicompany field
- if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
+ if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED))
{
- $nbofallowedentities=count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1
- if (! empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r]+=array('s.entity'=>'Entity');
+ $nbofallowedentities = count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1
+ if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) $this->export_fields_array[$r] += array('s.entity'=>'Entity');
}
- $keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extra';
+ $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
- $this->export_fields_array[$r]+=array('u.login'=>'SaleRepresentativeLogin','u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname');
+ $this->export_fields_array[$r] += array('u.login'=>'SaleRepresentativeLogin', 'u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname');
//$this->export_TypeFields_array[$r]=array(
// 's.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Text",'s.client'=>"Boolean",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",
// 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",
@@ -288,101 +288,104 @@ class modSociete extends DolibarrModules
// 't.libelle'=>"Text",'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
// 's.fk_stcomm'=>'List:c_stcomm:libelle:code','d.nom'=>'List:c_departements:nom:rowid'
//);
- $this->export_TypeFields_array[$r]=array(
- 's.rowid'=>"Numeric", 's.nom'=>"Text",'s.name_alias'=>"Text",'s.status'=>"Numeric",'s.client'=>"Numeric",'s.fournisseur'=>"Boolean",'s.datec'=>"Date",'s.tms'=>"Date",
- 's.code_client'=>"Text",'s.code_fournisseur'=>"Text",'s.code_compta'=>"Text",'s.code_compta_fournisseur'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",
- 's.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",
- 's.default_lang'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",'s.idprof5'=>"Text",'s.idprof6'=>"Text",
- 's.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_private'=>"Text",'s.note_public'=>"Text",'t.libelle'=>"Text",
- 'ce.code'=>"List:c_effectif:libelle:code","cfj.libelle"=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
- 'st.code'=>'List:c_stcomm:libelle:code','d.nom'=>'Text','u.login'=>'Text','u.firstname'=>'Text','u.lastname'=>'Text','payterm.libelle'=>'Text',
- 'paymode.libelle'=>'Text','s.entity'=>'Numeric',
+ $this->export_TypeFields_array[$r] = array(
+ 's.rowid'=>"Numeric", 's.nom'=>"Text", 's.name_alias'=>"Text", 's.status'=>"Numeric", 's.client'=>"Numeric", 's.fournisseur'=>"Boolean", 's.datec'=>"Date", 's.tms'=>"Date",
+ 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text", 's.address'=>"Text", 's.zip'=>"Text",
+ 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text",
+ 's.default_lang'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text",
+ 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text", 't.libelle'=>"Text",
+ 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
+ 'st.code'=>'List:c_stcomm:libelle:code', 'd.nom'=>'Text', 'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text', 'payterm.libelle'=>'Text',
+ 'paymode.libelle'=>'Text', 's.entity'=>'Numeric',
's.price_level'=>'Numeric'
);
- $this->export_entities_array[$r]=array('u.login'=>'user','u.firstname'=>'user','u.lastname'=>'user'); // We define here only fields that use another picto
- $this->export_examplevalues_array[$r]=array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 (not a supplier) or 1 (supplier)');
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id';
- $this->export_sql_end[$r] .=' WHERE s.entity IN ('.getEntity('societe').')';
+ $this->export_entities_array[$r] = array('u.login'=>'user', 'u.firstname'=>'user', 'u.lastname'=>'user'); // We define here only fields that use another picto
+ $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)');
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as paymode ON s.mode_reglement = paymode.id';
+ $this->export_sql_end[$r] .= ' WHERE s.entity IN ('.getEntity('societe').')';
if (is_object($user) && empty($user->rights->societe->client->voir)) {
- $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' ';
- if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
+ $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' ';
+ if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
$subordinatesids = $user->getAllChildIds();
- $this->export_sql_end[$r] .=count($subordinatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : '';
+ $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : '';
}
- $this->export_sql_end[$r] .=')';
+ $this->export_sql_end[$r] .= ')';
}
// Export list of contacts and attributes
$r++;
- $this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='ExportDataset_company_2';
- $this->export_icon[$r]='contact';
- $this->export_permission[$r]=array(array("societe","contact","export"));
- $this->export_fields_array[$r]=array(
- 'c.rowid'=>"IdContact",'c.civility'=>"CivilityCode",'c.lastname'=>'Lastname','c.firstname'=>'Firstname','c.poste'=>'PostOrFunction',
- 'c.datec'=>"DateCreation",'c.tms'=>"DateLastModification",'c.priv'=>"ContactPrivate",'c.address'=>"Address",'c.zip'=>"Zip",'c.town'=>"Town",
- 'd.nom'=>'State','co.label'=>"Country",'co.code'=>"CountryCode",'c.phone'=>"Phone",'c.fax'=>"Fax",'c.phone_mobile'=>"Mobile",'c.email'=>"EMail",
+ $this->export_code[$r] = $this->rights_class.'_'.$r;
+ $this->export_label[$r] = 'ExportDataset_company_2';
+ $this->export_icon[$r] = 'contact';
+ $this->export_permission[$r] = array(array("societe", "contact", "export"));
+ $this->export_fields_array[$r] = array(
+ 'c.rowid'=>"IdContact", 'c.civility'=>"CivilityCode", 'c.lastname'=>'Lastname', 'c.firstname'=>'Firstname', 'c.poste'=>'PostOrFunction',
+ 'c.datec'=>"DateCreation", 'c.tms'=>"DateLastModification", 'c.priv'=>"ContactPrivate", 'c.address'=>"Address", 'c.zip'=>"Zip", 'c.town'=>"Town",
+ 'd.nom'=>'State', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail",
'c.statut'=>"Status",
- 's.rowid'=>"IdCompany",'s.nom'=>"CompanyName",'s.status'=>"Status",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",
- 's.client'=>'Customer','s.fournisseur'=>'Supplier',
- 's.address'=>'Address','s.zip'=>"Zip",'s.town'=>"Town",'s.phone'=>'Phone','s.email'=>"Email",
+ 's.rowid'=>"IdCompany", 's.nom'=>"CompanyName", 's.status'=>"Status", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode",
+ 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode",
+ 's.client'=>'Customer', 's.fournisseur'=>'Supplier',
+ 's.address'=>'Address', 's.zip'=>"Zip", 's.town'=>"Town", 's.phone'=>'Phone', 's.email'=>"Email",
't.libelle'=>"ThirdPartyType"
);
- $this->export_examplevalues_array[$r]=array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 (not a supplier) or 1 (supplier)');
- $this->export_TypeFields_array[$r]=array(
- 'c.civility'=>"List:c_civility:label:code",'c.lastname'=>'Text','c.firstname'=>'Text','c.poste'=>'Text','c.datec'=>"Date",'c.priv'=>"Boolean",
- 'c.address'=>"Text",'c.zip'=>"Text",'c.town'=>"Text",'d.nom'=>'Text','co.label'=>"List:c_country:label:rowid",'co.code'=>"Text",'c.phone'=>"Text",
- 'c.fax'=>"Text",'c.email'=>"Text",
+ $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)');
+ $this->export_TypeFields_array[$r] = array(
+ 'c.civility'=>"List:c_civility:label:code", 'c.lastname'=>'Text', 'c.firstname'=>'Text', 'c.poste'=>'Text', 'c.datec'=>"Date", 'c.priv'=>"Boolean",
+ 'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text",
+ 'c.fax'=>"Text", 'c.email'=>"Text",
'c.statut'=>"Status",
- 's.rowid'=>"List:societe:nom::thirdparty",'s.nom'=>"Text",'s.status'=>"Status",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text",
- 's.client'=>"Text",'s.fournisseur'=>"Text",
- 's.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'s.phone'=>"Text",'s.email'=>"Text",
+ 's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text",
+ 's.code_compta'=>"Text", 's.code_compta_fournisseur'=>"Text",
+ 's.client'=>"Text", 's.fournisseur'=>"Text",
+ 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 's.phone'=>"Text", 's.email'=>"Text",
't.libelle'=>"Text"
);
- $this->export_entities_array[$r]=array(
- 's.rowid'=>"company",'s.nom'=>"company", 's.status'=>'company', 's.code_client'=>"company",'s.code_fournisseur'=>"company", 's.client'=>"company",
- 's.fournisseur'=>"company",
+ $this->export_entities_array[$r] = array(
+ 's.rowid'=>"company", 's.nom'=>"company", 's.status'=>'company', 's.code_client'=>"company", 's.code_fournisseur'=>"company",
+ 's.code_compta'=>"company", 's.code_compta_fournisseur'=>"company",
+ 's.client'=>"company", 's.fournisseur'=>"company",
's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 's.phone'=>"company", 's.email'=>"company",
't.libelle'=>"company"
- ); // We define here only fields that use another picto
+ ); // We define here only fields that use another picto
if (empty($conf->fournisseur->enabled))
{
unset($this->export_fields_array[$r]['s.code_fournisseur']);
unset($this->export_entities_array[$r]['s.code_fournisseur']);
}
- $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra';
+ $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
- $keyforselect='societe'; $keyforelement='company'; $keyforaliasextra='extrasoc';
+ $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'socpeople as c';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object';
- if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
- $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
- $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity('socpeople').')';
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'socpeople as c';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON c.fk_soc = s.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object';
+ if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id';
+ $this->export_sql_end[$r] .= ' WHERE c.entity IN ('.getEntity('socpeople').')';
if (is_object($user) && empty($user->rights->societe->client->voir)) {
- $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' ';
- if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
+ $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.$user->id.' ';
+ if (!empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) {
$subordinatesids = $user->getAllChildIds();
- $this->export_sql_end[$r] .=count($subordinatesids)>0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : '';
+ $this->export_sql_end[$r] .= count($subordinatesids) > 0 ? ' OR (sc.fk_user IN ('.implode(',', $subordinatesids).')' : '';
}
- $this->export_sql_end[$r] .=')';
+ $this->export_sql_end[$r] .= ')';
}
diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php
index 6b2dc11605c..bc1971ee3ed 100644
--- a/htdocs/core/modules/modStock.class.php
+++ b/htdocs/core/modules/modStock.class.php
@@ -348,6 +348,7 @@ class modStock extends DolibarrModules
$this->import_examplevalues_array[$r]=array(
'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10"
);
+ $this->import_updatekeys_array[$r]=array('ps.fk_product'=>'Product', 'ps.fk_entrepot'=>"Warehouse");
$this->import_run_sql_after_array[$r]=array( // Because we may change data that are denormalized, we must update dernormalized data after.
'UPDATE '.MAIN_DB_PREFIX.'product p SET p.stock= (SELECT SUM(ps.reel) FROM '.MAIN_DB_PREFIX.'product_stock ps WHERE ps.fk_product = p.rowid);'
);
diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php
index 515f18cf690..4671f40dd40 100644
--- a/htdocs/core/modules/modTakePos.class.php
+++ b/htdocs/core/modules/modTakePos.class.php
@@ -24,7 +24,7 @@
* \ingroup takepos
* \brief Description and activation file for module TakePos
*/
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
@@ -39,7 +39,7 @@ class modTakePos extends DolibarrModules
*/
public function __construct($db)
{
- global $langs,$conf;
+ global $langs, $conf;
$this->db = $db;
@@ -71,21 +71,21 @@ class modTakePos extends DolibarrModules
// Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
- $this->picto='list';
+ $this->picto = 'list';
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
// for default path (eg: /takepos/core/xxxxx) (0=disable, 1=enable)
// for specific path of parts (eg: /takepos/core/modules/barcode)
// for specific css file (eg: /takepos/css/takepos.css.php)
$this->module_parts = array(
- 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)
- 'login' => 0, // Set this to 1 if module has its own login method file (core/login)
- 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions)
- 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)
- 'theme' => 0, // Set this to 1 if module has its own theme directory (theme)
- 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)
- 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode)
- 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)
+ 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)
+ 'login' => 0, // Set this to 1 if module has its own login method file (core/login)
+ 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions)
+ 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)
+ 'theme' => 0, // Set this to 1 if module has its own theme directory (theme)
+ 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)
+ 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode)
+ 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)
'hooks' => array() // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'
);
@@ -97,15 +97,15 @@ class modTakePos extends DolibarrModules
$this->config_page_url = array("setup.php@takepos");
// Dependencies
- $this->hidden = false; // A condition to hide module
- $this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog'); // List of module class names as string that must be enabled if this module is enabled
- $this->requiredby = array(); // List of module ids to disable if this one is disabled
- $this->conflictwith = array(); // List of module class names as string this module is in conflict with
+ $this->hidden = false; // A condition to hide module
+ $this->depends = array('always1'=>"modBanque", 'always2'=>"modFacture", 'always3'=>"modProduct", 'always4'=>'modCategorie', 'FR1'=>'modBlockedLog'); // List of module class names as string that must be enabled if this module is enabled
+ $this->requiredby = array(); // List of module ids to disable if this one is disabled
+ $this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->langfiles = array("cashdesk");
- $this->phpmin = array(5,4); // Minimum version of PHP required by module
- $this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module
- $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
- $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
+ $this->phpmin = array(5, 4); // Minimum version of PHP required by module
+ $this->need_dolibarr_version = array(4, 0); // Minimum version of Dolibarr required by module
+ $this->warnings_activation = array('FR'=>'WarningNoteModulePOSForFrenchLaw'); // Warning to show when we activate module. array('always'='text') or array('FR'='text')
+ $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
//$this->automatic_activation = array('FR'=>'TakePosWasAutomaticallyActivatedBecauseOfYourCountryChoice');
//$this->always_enabled = true; // If true, can't be disabled
@@ -119,10 +119,10 @@ class modTakePos extends DolibarrModules
);
- if (! isset($conf->takepos) || ! isset($conf->takepos->enabled))
+ if (!isset($conf->takepos) || !isset($conf->takepos->enabled))
{
- $conf->takepos=new stdClass();
- $conf->takepos->enabled=0;
+ $conf->takepos = new stdClass();
+ $conf->takepos->enabled = 0;
}
@@ -156,7 +156,7 @@ class modTakePos extends DolibarrModules
// Dictionaries
- $this->dictionaries=array();
+ $this->dictionaries = array();
/* Example:
$this->dictionaries=array(
'langs'=>'mylangfile@takepos',
@@ -193,9 +193,9 @@ class modTakePos extends DolibarrModules
// Permissions
- $this->rights = array(); // Permission array used by this module
+ $this->rights = array(); // Permission array used by this module
- $r=0;
+ $r = 0;
$r++;
$this->rights[$r][0] = 50151;
@@ -206,24 +206,24 @@ class modTakePos extends DolibarrModules
// Main menu entries
- $this->menu = array(); // List of menus to add
- $r=0;
+ $this->menu = array(); // List of menus to add
+ $r = 0;
// Add here entries to declare new menus
/* BEGIN MODULEBUILDER TOPMENU */
- $this->menu[$r++]=array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
- 'type'=>'top', // This is a Top menu entry
+ $this->menu[$r++] = array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+ 'type'=>'top', // This is a Top menu entry
'titre'=>'PointOfSaleShort',
'mainmenu'=>'takepos',
'leftmenu'=>'',
'url'=>'/takepos/takepos.php',
- 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
- 'position'=>1000+$r,
- 'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.
- 'perms'=>'$user->rights->takepos->run', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules
+ 'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1000 + $r,
+ 'enabled'=>'$conf->takepos->enabled', // Define condition to show or hide menu entry. Use '$conf->takepos->enabled' if entry must be visible if module is enabled.
+ 'perms'=>'$user->rights->takepos->run', // Use 'perms'=>'$user->rights->takepos->level1->level2' if you want your menu with a permission rules
'target'=>'takepos',
- 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
+ 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
/* END MODULEBUILDER TOPMENU */
@@ -265,6 +265,10 @@ class modTakePos extends DolibarrModules
*/
public function init($options = '')
{
+ global $conf,$db;
+
+ dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", "browser", 'chaine', 0, '', $conf->entity);
+
$this->_load_tables('/takepos/sql/');
$sql = array();
diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php
index 8d7f16fcaf7..fbf560565ee 100644
--- a/htdocs/core/modules/modTicket.class.php
+++ b/htdocs/core/modules/modTicket.class.php
@@ -120,16 +120,16 @@ class modTicket extends DolibarrModules
}
$this->dictionaries = array(
'langs' => 'ticket',
- 'tabname' => array(MAIN_DB_PREFIX . "c_ticket_type", MAIN_DB_PREFIX . "c_ticket_severity", MAIN_DB_PREFIX . "c_ticket_category"),
- 'tablib' => array("TicketDictType", "TicketDictSeverity", "TicketDictCategory"),
- 'tabsql' => array('SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticket_type as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticket_severity as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticket_category as f'),
- 'tabsqlsort' => array("pos ASC", "pos ASC", "pos ASC"),
- 'tabfield' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"),
- 'tabfieldvalue' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"),
- 'tabfieldinsert' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"),
- 'tabrowid' => array("rowid", "rowid", "rowid"),
- 'tabcond' => array($conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled),
- 'tabhelp' => array(array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1"))),
+ 'tabname' => array(MAIN_DB_PREFIX."c_ticket_type", MAIN_DB_PREFIX."c_ticket_severity", MAIN_DB_PREFIX."c_ticket_category", MAIN_DB_PREFIX."c_ticket_resolution"),
+ 'tablib' => array("TicketDictType", "TicketDictSeverity", "TicketDictCategory", "TicketDictResolution"),
+ 'tabsql' => array('SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_type as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_severity as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_category as f', 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM '.MAIN_DB_PREFIX.'c_ticket_resolution as f'),
+ 'tabsqlsort' => array("pos ASC", "pos ASC", "pos ASC", "pos ASC"),
+ 'tabfield' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"),
+ 'tabfieldvalue' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"),
+ 'tabfieldinsert' => array("pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default", "pos,code,label,use_default"),
+ 'tabrowid' => array("rowid", "rowid", "rowid", "rowid"),
+ 'tabcond' => array($conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled, $conf->ticket->enabled),
+ 'tabhelp' => array(array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1")), array('code'=>$langs->trans("EnterAnyCode"), 'use_default'=>$langs->trans("Enter0or1"))),
);
// Boxes
diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php
index 6e5924945c9..c2ce0fec86f 100644
--- a/htdocs/core/modules/modUser.class.php
+++ b/htdocs/core/modules/modUser.class.php
@@ -25,7 +25,7 @@
* \brief Fichier de description et activation du module Utilisateur
*/
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
* Class to describe and enable module User
@@ -45,7 +45,7 @@ class modUser extends DolibarrModules
$this->db = $db;
$this->numero = 0;
- $this->family = "hr"; // Family for module (or "base" if core module)
+ $this->family = "hr"; // Family for module (or "base" if core module)
$this->module_position = '05';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
@@ -55,7 +55,7 @@ class modUser extends DolibarrModules
$this->version = 'dolibarr';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
- $this->picto='group';
+ $this->picto = 'group';
// Data directories to create when module is enabled
$this->dirs = array("/users/temp");
@@ -64,28 +64,28 @@ class modUser extends DolibarrModules
$this->config_page_url = array("user.php");
// Dependencies
- $this->hidden = false; // A condition to hide module
- $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
- $this->requiredby = array(); // List of module ids to disable if this one is disabled
- $this->conflictwith = array(); // List of module class names as string this module is in conflict with
- $this->phpmin = array(5,4); // Minimum version of PHP required by module
- $this->langfiles = array("main","users","companies","members","salaries","hrm");
- $this->always_enabled = true; // Can't be disabled
+ $this->hidden = false; // A condition to hide module
+ $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
+ $this->requiredby = array(); // List of module ids to disable if this one is disabled
+ $this->conflictwith = array(); // List of module class names as string this module is in conflict with
+ $this->phpmin = array(5, 4); // Minimum version of PHP required by module
+ $this->langfiles = array("main", "users", "companies", "members", "salaries", "hrm");
+ $this->always_enabled = true; // Can't be disabled
// Constants
$this->const = array();
// Boxes
$this->boxes = array(
- 0=>array('file'=>'box_lastlogin.php','enabledbydefaulton'=>'Home'),
- 1=>array('file'=>'box_birthdays.php','enabledbydefaulton'=>'Home')
+ 0=>array('file'=>'box_lastlogin.php', 'enabledbydefaulton'=>'Home'),
+ 1=>array('file'=>'box_birthdays.php', 'enabledbydefaulton'=>'Home')
);
// Permissions
$this->rights = array();
$this->rights_class = 'user';
- $this->rights_admin_allowed = 1; // Admin is always granted of permission (even when module is disabled)
- $r=0;
+ $this->rights_admin_allowed = 1; // Admin is always granted of permission (even when module is disabled)
+ $r = 0;
$r++;
$this->rights[$r][0] = 251;
@@ -140,7 +140,7 @@ class modUser extends DolibarrModules
$this->rights[$r][1] = 'Consulter ses propres permissions';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
+ $this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'readperms';
$r++;
@@ -164,7 +164,7 @@ class modUser extends DolibarrModules
$this->rights[$r][1] = 'Modifier ses propres permissions';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
+ $this->rights[$r][4] = 'self_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'writeperms';
$r++;
@@ -172,7 +172,7 @@ class modUser extends DolibarrModules
$this->rights[$r][1] = 'Consulter les groupes';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
+ $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'read';
$r++;
@@ -180,7 +180,7 @@ class modUser extends DolibarrModules
$this->rights[$r][1] = 'Consulter les permissions des groupes';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
+ $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'readperms';
$r++;
@@ -188,7 +188,7 @@ class modUser extends DolibarrModules
$this->rights[$r][1] = 'Creer/modifier les groupes et leurs permissions';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
+ $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'write';
$r++;
@@ -196,7 +196,7 @@ class modUser extends DolibarrModules
$this->rights[$r][1] = 'Supprimer ou desactiver les groupes';
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
+ $this->rights[$r][4] = 'group_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'delete';
$r++;
@@ -209,118 +209,119 @@ class modUser extends DolibarrModules
// Menus
- $this->menu = 1; // This module add menu entries. They are coded into menu manager.
+ $this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports
- $r=0;
+ $r = 0;
$r++;
- $this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='List of users and attributes';
- $this->export_permission[$r]=array(array("user","user","export"));
- $this->export_fields_array[$r]=array(
- 'u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.employee'=>"Employee",'u.job'=>"PostOrFunction",'u.gender'=>"Gender",
+ $this->export_code[$r] = $this->rights_class.'_'.$r;
+ $this->export_label[$r] = 'List of users and attributes';
+ $this->export_permission[$r] = array(array("user", "user", "export"));
+ $this->export_fields_array[$r] = array(
+ 'u.rowid'=>"Id", 'u.login'=>"Login", 'u.lastname'=>"Lastname", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender",
'u.accountancy_code'=>"UserAccountancyCode",
- 'u.address'=>"Address",'u.zip'=>"Zip",'u.town'=>"Town",
- 'u.office_phone'=>'Phone','u.user_mobile'=>"Mobile",'u.office_fax'=>'Fax',
- 'u.email'=>"Email",'u.note'=>"Note",'u.signature'=>'Signature',
- 'u.fk_user'=>'HierarchicalResponsible','u.thm'=>'THM','u.tjm'=>'TJM','u.weeklyhours'=>'WeeklyHours',
- 'u.dateemployment'=>'DateEmployment','u.salary'=>'Salary','u.color'=>'Color','u.api_key'=>'ApiKey',
+ 'u.address'=>"Address", 'u.zip'=>"Zip", 'u.town'=>"Town",
+ 'u.office_phone'=>'Phone', 'u.user_mobile'=>"Mobile", 'u.office_fax'=>'Fax',
+ 'u.email'=>"Email", 'u.note'=>"Note", 'u.signature'=>'Signature',
+ 'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours',
+ 'u.dateemployment'=>'DateEmployment', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey',
'u.birth'=>'BirthdayDate',
- 'u.datec'=>"DateCreation",'u.tms'=>"DateLastModification",
- 'u.admin'=>"Administrator",'u.statut'=>'Status','u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion',
- 'u.fk_socpeople'=>"IdContact",'u.fk_soc'=>"IdCompany",'u.fk_member'=>"MemberId"
+ 'u.datec'=>"DateCreation", 'u.tms'=>"DateLastModification",
+ 'u.admin'=>"Administrator", 'u.statut'=>'Status', 'u.datelastlogin'=>'LastConnexion', 'u.datepreviouslogin'=>'PreviousConnexion',
+ 'u.fk_socpeople'=>"IdContact", 'u.fk_soc'=>"IdCompany", 'u.fk_member'=>"MemberId"
);
- $this->export_TypeFields_array[$r]=array(
- 'u.rowid'=>'Numeric', 'u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.employee'=>'Boolean','u.job'=>'Text',
+ $this->export_TypeFields_array[$r] = array(
+ 'u.rowid'=>'Numeric', 'u.login'=>"Text", 'u.lastname'=>"Text", 'u.firstname'=>"Text", 'u.employee'=>'Boolean', 'u.job'=>'Text',
'u.accountancy_code'=>'Text',
- 'u.address'=>"Text",'u.zip'=>"Text",'u.town'=>"Text",
- 'u.office_phone'=>'Text','u.user_mobile'=>'Text','u.office_fax'=>'Text',
- 'u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date',
+ 'u.address'=>"Text", 'u.zip'=>"Text", 'u.town'=>"Text",
+ 'u.office_phone'=>'Text', 'u.user_mobile'=>'Text', 'u.office_fax'=>'Text',
+ 'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note'=>"Text", 'u.datelastlogin'=>'Date',
'u.fk_user'=>"List:user:login",
'u.birth'=>'Date',
- 'u.datepreviouslogin'=>'Date','u.fk_soc'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:firstname"
+ 'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname"
);
- $this->export_entities_array[$r]=array(
- 'u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.employee'=>'user','u.job'=>'user','u.gender'=>'user',
+ $this->export_entities_array[$r] = array(
+ 'u.rowid'=>"user", 'u.login'=>"user", 'u.lastname'=>"user", 'u.firstname'=>"user", 'u.employee'=>'user', 'u.job'=>'user', 'u.gender'=>'user',
'u.accountancy_code'=>'user',
- 'u.address'=>"user",'u.zip'=>"user",'u.town'=>"user",
- 'u.office_phone'=>'user','u.user_mobile'=>'user','u.office_fax'=>'user',
- 'u.email'=>'user','u.note'=>"user",'u.signature'=>'user',
- 'u.fk_user'=>'user','u.thm'=>'user','u.tjm'=>'user','u.weeklyhours'=>'user',
- 'u.dateemployment'=>'user','u.salary'=>'user','u.color'=>'user','u.api_key'=>'user',
+ 'u.address'=>"user", 'u.zip'=>"user", 'u.town'=>"user",
+ 'u.office_phone'=>'user', 'u.user_mobile'=>'user', 'u.office_fax'=>'user',
+ 'u.email'=>'user', 'u.note'=>"user", 'u.signature'=>'user',
+ 'u.fk_user'=>'user', 'u.thm'=>'user', 'u.tjm'=>'user', 'u.weeklyhours'=>'user',
+ 'u.dateemployment'=>'user', 'u.salary'=>'user', 'u.color'=>'user', 'u.api_key'=>'user',
'u.birth'=>'user',
- 'u.datec'=>"user",'u.tms'=>"user",
- 'u.admin'=>"user",'u.statut'=>'user','u.datelastlogin'=>'user','u.datepreviouslogin'=>'user',
- 'u.fk_socpeople'=>"contact",'u.fk_soc'=>"company",'u.fk_member'=>"member"
+ 'u.datec'=>"user", 'u.tms'=>"user",
+ 'u.admin'=>"user", 'u.statut'=>'user', 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user',
+ 'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member"
);
if (empty($conf->adherent->enabled))
{
unset($this->export_fields_array[$r]['u.fk_member']);
unset($this->export_entities_array[$r]['u.fk_member']);
}
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'user as u';
- $this->export_sql_end[$r] .=' WHERE u.entity IN ('.getEntity('user').')';
+ $this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'user as u';
+ $this->export_sql_end[$r] .= ' WHERE u.entity IN ('.getEntity('user').')';
// Imports
- $r=0;
+ $r = 0;
// Import list of users attributes
$r++;
- $this->import_code[$r]=$this->rights_class.'_'.$r;
- $this->import_label[$r]='ImportDataset_user_1';
- $this->import_icon[$r]='user';
- $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon
- $this->import_tables_array[$r]=array('u'=>MAIN_DB_PREFIX.'user','extra'=>MAIN_DB_PREFIX.'user_extrafields'); // List of tables to insert into (insert done in same order)
- $this->import_fields_array[$r]=array(
- 'u.login'=>"Login*",'u.lastname'=>"Name*",'u.firstname'=>"Firstname",'u.employee'=>"Employee*",'u.job'=>"PostOrFunction",'u.gender'=>"Gender",
+ $this->import_code[$r] = $this->rights_class.'_'.$r;
+ $this->import_label[$r] = 'ImportDataset_user_1';
+ $this->import_icon[$r] = 'user';
+ $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
+ $this->import_tables_array[$r] = array('u'=>MAIN_DB_PREFIX.'user', 'extra'=>MAIN_DB_PREFIX.'user_extrafields'); // List of tables to insert into (insert done in same order)
+ $this->import_fields_array[$r] = array(
+ 'u.login'=>"Login*", 'u.lastname'=>"Name*", 'u.firstname'=>"Firstname", 'u.employee'=>"Employee*", 'u.job'=>"PostOrFunction", 'u.gender'=>"Gender",
'u.accountancy_code'=>"UserAccountancyCode",
- 'u.pass_crypted'=>"Password",'u.admin'=>"Administrator",'u.fk_soc'=>"Company*",'u.address'=>"Address",'u.zip'=>"Zip",'u.town'=>"Town",
- 'u.fk_state'=>"StateId",'u.fk_country'=>"CountryCode",
- 'u.office_phone'=>"Phone",'u.user_mobile'=>"Mobile",'u.office_fax'=>"Fax",
- 'u.email'=>"Email",'u.note'=>"Note",'u.signature'=>'Signature',
- 'u.fk_user'=>'HierarchicalResponsible','u.thm'=>'THM','u.tjm'=>'TJM','u.weeklyhours'=>'WeeklyHours',
- 'u.dateemployment'=>'DateEmployment','u.salary'=>'Salary','u.color'=>'Color','u.api_key'=>'ApiKey',
+ 'u.pass_crypted'=>"Password", 'u.admin'=>"Administrator", 'u.fk_soc'=>"Company*", 'u.address'=>"Address", 'u.zip'=>"Zip", 'u.town'=>"Town",
+ 'u.fk_state'=>"StateId", 'u.fk_country'=>"CountryCode",
+ 'u.office_phone'=>"Phone", 'u.user_mobile'=>"Mobile", 'u.office_fax'=>"Fax",
+ 'u.email'=>"Email", 'u.note'=>"Note", 'u.signature'=>'Signature',
+ 'u.fk_user'=>'HierarchicalResponsible', 'u.thm'=>'THM', 'u.tjm'=>'TJM', 'u.weeklyhours'=>'WeeklyHours',
+ 'u.dateemployment'=>'DateEmployment', 'u.salary'=>'Salary', 'u.color'=>'Color', 'u.api_key'=>'ApiKey',
'u.birth'=>'BirthdayDate',
'u.datec'=>"DateCreation",
'u.statut'=>'Status'
);
// Add extra fields
- $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")";
- $resql=$this->db->query($sql);
+ $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")";
+ $resql = $this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
- $fieldname='extra.'.$obj->name;
- $fieldlabel=ucfirst($obj->label);
- $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
+ $fieldname = 'extra.'.$obj->name;
+ $fieldlabel = ucfirst($obj->label);
+ $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
}
}
// End add extra fields
- $this->import_fieldshidden_array[$r]=array('u.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'user'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
- $this->import_convertvalue_array[$r]=array(
- 'u.fk_state'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/cstate.class.php','class'=>'Cstate','method'=>'fetch','dict'=>'DictionaryState'),
- 'u.fk_country'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'),
+ $this->import_fieldshidden_array[$r] = array('u.fk_user_creat'=>'user->id', 'extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'user'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
+ $this->import_convertvalue_array[$r] = array(
+ 'u.fk_state'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/cstate.class.php', 'class'=>'Cstate', 'method'=>'fetch', 'dict'=>'DictionaryState'),
+ 'u.fk_country'=>array('rule'=>'fetchidfromcodeid', 'classfile'=>'/core/class/ccountry.class.php', 'class'=>'Ccountry', 'method'=>'fetch', 'dict'=>'DictionaryCountry'),
'u.salary'=>array('rule'=>'numeric')
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
- $this->import_regex_array[$r]=array(
+ $this->import_regex_array[$r] = array(
'u.employee'=>'^[0|1]',
'u.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$',
'u.dateemployment'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
'u.birth'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'
);
- $this->import_examplevalues_array[$r]=array(
- 'u.lastname'=>"Doe", 'u.firstname'=>'John', 'u.login'=>'jdoe', 'u.employee'=>'0 or 1',
+ $this->import_examplevalues_array[$r] = array(
+ 'u.lastname'=>"Doe", 'u.firstname'=>'John', 'u.login'=>'jdoe', 'u.employee'=>'0 or 1', 'u.job'=>'CTO', 'u.gender'=>'0 or 1',
+ 'u.pass_crypted'=>'Encrypted password',
'u.fk_soc'=>'0 (internal user) or company name (external user)', 'u.datec'=>dol_print_date(dol_now(), '%Y-%m-%d'), 'u.address'=>"61 jump street",
- 'u.zip'=>"123456",'u.town'=>"Big town",'u.fk_country'=>'US, FR, DE...','u.office_phone'=>"0101010101",'u.office_fax'=>"0101010102",
- 'u.email'=>"test@mycompany.com",'u.salary'=>"10000",'u.note'=>"This is an example of note for record",'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00",
+ 'u.zip'=>"123456", 'u.town'=>"Big town", 'u.fk_country'=>'US, FR, DE...', 'u.office_phone'=>"0101010101", 'u.office_fax'=>"0101010102",
+ 'u.email'=>"test@mycompany.com", 'u.salary'=>"10000", 'u.note'=>"This is an example of note for record", 'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00",
'u.statut'=>"0 (closed) or 1 (active)",
);
- $this->import_updatekeys_array[$r]=array('u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>'Login');
+ $this->import_updatekeys_array[$r] = array('u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'u.login'=>'Login');
}
diff --git a/htdocs/core/modules/oauth/github_oauthcallback.php b/htdocs/core/modules/oauth/github_oauthcallback.php
index 919781baa93..4320481abb1 100644
--- a/htdocs/core/modules/oauth/github_oauthcallback.php
+++ b/htdocs/core/modules/oauth/github_oauthcallback.php
@@ -29,8 +29,8 @@ use OAuth\Common\Consumer\Credentials;
use OAuth\OAuth2\Service\GitHub;
// Define $urlwithroot
-$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
-$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
+$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
@@ -70,8 +70,8 @@ $credentials = new Credentials(
$currentUri->getAbsoluteUri()
);
-$requestedpermissionsarray=array();
-if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back
+$requestedpermissionsarray = array();
+if (GETPOST('state')) $requestedpermissionsarray = explode(',', GETPOST('state')); // Example: 'user'. 'state' parameter is standard to retrieve some parameters back
if ($action != 'delete' && empty($requestedpermissionsarray))
{
print 'Error, parameter state is not defined';
@@ -93,18 +93,17 @@ $langs->load("oauth");
* Actions
*/
-
if ($action == 'delete')
{
$storage->clearToken('GitHub');
setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
- header('Location: ' . $backtourl);
+ header('Location: '.$backtourl);
exit();
}
-if (! empty($_GET['code'])) // We are coming from oauth provider page
+if (!empty($_GET['code'])) // We are coming from oauth provider page
{
// We should have
//$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16))
@@ -133,12 +132,12 @@ if (! empty($_GET['code'])) // We are coming from oauth provider page
// parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri)
// has not the ending parameter to true like the Google class constructor.
- setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
+ setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
$backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
unset($_SESSION["backtourlsavedbeforeoauthjump"]);
- header('Location: ' . $backtourl);
+ header('Location: '.$backtourl);
exit();
} catch (Exception $e) {
print $e->getMessage();
@@ -146,7 +145,7 @@ if (! empty($_GET['code'])) // We are coming from oauth provider page
}
else // If entry on page with no parameter, we arrive here
{
- $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
+ $_SESSION["backtourlsavedbeforeoauthjump"] = $backtourl;
// This may create record into oauth_state before the header redirect.
// Creation of record with state in this tables depend on the Provider used (see its constructor).
@@ -156,11 +155,11 @@ else // If entry on page with no parameter, we arrive here
}
else
{
- $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
+ $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
}
// we go on oauth provider authorization page
- header('Location: ' . $url);
+ header('Location: '.$url);
exit();
}
diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php
index c9fd9869caf..68aba389f31 100644
--- a/htdocs/core/modules/oauth/google_oauthcallback.php
+++ b/htdocs/core/modules/oauth/google_oauthcallback.php
@@ -29,8 +29,8 @@ use OAuth\Common\Consumer\Credentials;
use OAuth\OAuth2\Service\Google;
// Define $urlwithroot
-$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
-$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
+$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
@@ -70,8 +70,8 @@ $credentials = new Credentials(
$currentUri->getAbsoluteUri()
);
-$requestedpermissionsarray=array();
-if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back
+$requestedpermissionsarray = array();
+if (GETPOST('state')) $requestedpermissionsarray = explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to store a hash value and can be used to retrieve some parameters back
if ($action != 'delete' && empty($requestedpermissionsarray))
{
print 'Error, parameter state is not defined';
@@ -105,11 +105,11 @@ if ($action == 'delete')
setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
- header('Location: ' . $backtourl);
+ header('Location: '.$backtourl);
exit();
}
-if (! empty($_GET['code'])) // We are coming from oauth provider page
+if (!empty($_GET['code'])) // We are coming from oauth provider page
{
dol_syslog("We are coming from the oauth provider page");
//llxHeader('',$langs->trans("OAuthSetup"));
@@ -130,12 +130,12 @@ if (! empty($_GET['code'])) // We are coming from oauth provider page
$token = $apiService->requestAccessToken($_GET['code'], $state);
- setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
+ setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
$backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
unset($_SESSION["backtourlsavedbeforeoauthjump"]);
- header('Location: ' . $backtourl);
+ header('Location: '.$backtourl);
exit();
} catch (Exception $e) {
print $e->getMessage();
@@ -143,7 +143,7 @@ if (! empty($_GET['code'])) // We are coming from oauth provider page
}
else // If entry on page with no parameter, we arrive here
{
- $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
+ $_SESSION["backtourlsavedbeforeoauthjump"] = $backtourl;
// This may create record into oauth_state before the header redirect.
// Creation of record with state in this tables depend on the Provider used (see its constructor).
@@ -153,11 +153,11 @@ else // If entry on page with no parameter, we arrive here
}
else
{
- $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
+ $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
}
// we go on oauth provider authorization page
- header('Location: ' . $url);
+ header('Location: '.$url);
exit();
}
diff --git a/htdocs/core/modules/payment/mod_payment_ant.php b/htdocs/core/modules/payment/mod_payment_ant.php
index 612a411daed..a42b68b37e4 100644
--- a/htdocs/core/modules/payment/mod_payment_ant.php
+++ b/htdocs/core/modules/payment/mod_payment_ant.php
@@ -44,7 +44,7 @@ class mod_payment_ant extends ModeleNumRefPayments
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Ant';
diff --git a/htdocs/core/modules/payment/mod_payment_cicada.php b/htdocs/core/modules/payment/mod_payment_cicada.php
index cd796fbcd19..9c40a575f47 100644
--- a/htdocs/core/modules/payment/mod_payment_cicada.php
+++ b/htdocs/core/modules/payment/mod_payment_cicada.php
@@ -45,7 +45,7 @@ class mod_payment_cicada extends ModeleNumRefPayments
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Cicada';
diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php
index 910ef3ec1cf..79941dba8d6 100644
--- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php
@@ -362,7 +362,13 @@ class pdf_baleine extends ModelePDFProjects
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
+
$forcedesconsamepage=1;
if ($forcedesconsamepage)
{
diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
index b26b46604ff..4072f22bf58 100644
--- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
@@ -512,7 +512,13 @@ class pdf_beluga extends ModelePDFProjects
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
+
$forcedesconsamepage=1;
if ($forcedesconsamepage)
{
diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php
index 27822545fa2..0c1eba3c9ac 100644
--- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php
@@ -293,7 +293,13 @@ class pdf_timespent extends ModelePDFProjects
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
+
$forcedesconsamepage=1;
if ($forcedesconsamepage)
{
diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php
index d73ee22fbae..92f86a433c8 100644
--- a/htdocs/core/modules/project/mod_project_simple.php
+++ b/htdocs/core/modules/project/mod_project_simple.php
@@ -47,7 +47,7 @@ class mod_project_simple extends ModeleNumRefProjects
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Simple';
diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php
index 9bf0d313ae8..f833ec280d2 100644
--- a/htdocs/core/modules/project/mod_project_universal.php
+++ b/htdocs/core/modules/project/mod_project_universal.php
@@ -44,7 +44,7 @@ class mod_project_universal extends ModeleNumRefProjects
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom = 'Universal';
diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php
index 386de7bfdd7..8a38450697f 100644
--- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php
+++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php
@@ -57,7 +57,7 @@ class doc_generic_task_odt extends ModelePDFTask
{
/**
* Issuer
- * @var Company object that emits
+ * @var Societe Object that emits
*/
public $emetteur;
diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php
index 65c7deb8edf..3f9debf9941 100644
--- a/htdocs/core/modules/project/task/mod_task_simple.php
+++ b/htdocs/core/modules/project/task/mod_task_simple.php
@@ -47,7 +47,7 @@ class mod_task_simple extends ModeleNumRefTask
/**
* @var string
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Simple';
diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php
index 1eecf94734b..b1c4f576a74 100644
--- a/htdocs/core/modules/project/task/mod_task_universal.php
+++ b/htdocs/core/modules/project/task/mod_task_universal.php
@@ -44,7 +44,7 @@ class mod_task_universal extends ModeleNumRefTask
/**
* @var string
* @deprecated
- * @see name
+ * @see $name
*/
public $nom = 'Universal';
diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
index b955da102ab..fde5f08d318 100644
--- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
+++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2010-2012 Laurent Destailleur
* Copyright (C) 2012 Juanjo Menent
* Copyright (C) 2016 Charlie Benke
- * Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018-2019 Frédéric France
*
* 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
@@ -115,7 +115,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$form = new Form($this->db);
$texte = $this->description.". \n";
- $texte .= '
';
}
}
-
+ // Add input to upload a new template file.
+ $texte .= ''.$langs->trans("UploadNewTemplate").' ';
+ $texte .= ' ';
+ $texte .= ' ';
+ $texte .= '
';
$texte .= ' ';
$texte .= '';
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index 9219de5863c..0167d900b3f 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -58,7 +58,7 @@ class pdf_azur extends ModelePDFPropales
public $description;
/**
- * @var string Save the name of generated file as the main doc when generating a doc with this template
+ * @var string Save the name of generated file as the main doc when generating a doc with this template
*/
public $update_main_doc_field;
@@ -116,7 +116,7 @@ class pdf_azur extends ModelePDFPropales
/**
* Issuer
- * @var Societe object that emits
+ * @var Societe Object that emits
*/
public $emetteur;
@@ -160,8 +160,6 @@ class pdf_azur extends ModelePDFPropales
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 1; // Support add of a watermark on drafts
- $this->franchise = !$mysoc->tva_assuj;
-
// Get source company
$this->emetteur = $mysoc;
if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
@@ -502,7 +500,12 @@ class pdf_azur extends ModelePDFPropales
$pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
- $showpricebeforepagebreak = 0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
if (isset($imglinesize['width']) && isset($imglinesize['height']))
@@ -543,7 +546,12 @@ class pdf_azur extends ModelePDFPropales
else
{
// We found a page break
- $showpricebeforepagebreak = 0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
@@ -866,13 +874,13 @@ class pdf_azur extends ModelePDFPropales
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{
// phpcs:enable
- global $conf;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
{
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1093,28 +1101,28 @@ class pdf_azur extends ModelePDFPropales
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1125,13 +1133,13 @@ class pdf_azur extends ModelePDFPropales
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
@@ -1140,15 +1148,15 @@ class pdf_azur extends ModelePDFPropales
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1184,11 +1192,11 @@ class pdf_azur extends ModelePDFPropales
//Local tax 1 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -1197,16 +1205,16 @@ class pdf_azur extends ModelePDFPropales
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
}
@@ -1216,11 +1224,11 @@ class pdf_azur extends ModelePDFPropales
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
// retrieve global local tax
if ($tvakey != 0) // On affiche pas taux 0
@@ -1230,16 +1238,16 @@ class pdf_azur extends ModelePDFPropales
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1468,7 +1476,7 @@ class pdf_azur extends ModelePDFPropales
if ($this->emetteur->logo)
{
$logodir = $conf->mycompany->dir_output;
- if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
@@ -1520,6 +1528,30 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
+ }
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
+ }
+ }
+
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
index 1e67ac6485c..cbbf462b446 100644
--- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
@@ -57,7 +57,7 @@ class pdf_cyan extends ModelePDFPropales
public $description;
/**
- * @var int Save the name of generated file as the main doc when generating a doc with this template
+ * @var string Save the name of generated file as the main doc when generating a doc with this template
*/
public $update_main_doc_field;
@@ -76,7 +76,7 @@ class pdf_cyan extends ModelePDFPropales
* Dolibarr version of the loaded document
* @var string
*/
- public $version = 'development';
+ public $version = 'dolibarr';
/**
* @var int page_largeur
@@ -115,7 +115,7 @@ class pdf_cyan extends ModelePDFPropales
/**
* Issuer
- * @var Societe
+ * @var Societe Object that emits
*/
public $emetteur;
@@ -135,47 +135,45 @@ class pdf_cyan extends ModelePDFPropales
$this->db = $db;
$this->name = "cyan";
$this->description = $langs->trans('DocModelCyanDescription');
- $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
+ $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
// Dimension page
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
+ $formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+ $this->format = array($this->page_largeur, $this->page_hauteur);
+ $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
+ $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
+ $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
+ $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
- $this->option_logo = 1; // Display logo
- $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
- $this->option_modereg = 1; // Display payment mode
- $this->option_condreg = 1; // Display payment terms
- $this->option_codeproduitservice = 1; // Display product-service code
- $this->option_multilang = 1; // Available in several languages
- $this->option_escompte = 0; // Displays if there has been a discount
- $this->option_credit_note = 0; // Support credit notes
- $this->option_freetext = 1; // Support add of a personalised text
- $this->option_draft_watermark = 1; // Support add of a watermark on drafts
-
- $this->franchise=!$mysoc->tva_assuj;
+ $this->option_logo = 1; // Display logo
+ $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Display payment mode
+ $this->option_condreg = 1; // Display payment terms
+ $this->option_codeproduitservice = 1; // Display product-service code
+ $this->option_multilang = 1; // Available in several languages
+ $this->option_escompte = 0; // Displays if there has been a discount
+ $this->option_credit_note = 0; // Support credit notes
+ $this->option_freetext = 1; // Support add of a personalised text
+ $this->option_draft_watermark = 1; // Support add of a watermark on drafts
// Get source company
- $this->emetteur=$mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined
+ $this->emetteur = $mysoc;
+ if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
// Define position of columns
- $this->posxdesc=$this->marge_gauche+1;
+ $this->posxdesc = $this->marge_gauche + 1;
$this->tabTitleHeight = 5; // default height
- $this->tva=array();
- $this->localtax1=array();
- $this->localtax2=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
+ $this->tva = array();
+ $this->localtax1 = array();
+ $this->localtax2 = array();
+ $this->atleastoneratenotnull = 0;
+ $this->atleastonediscount = 0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -193,52 +191,63 @@ class pdf_cyan extends ModelePDFPropales
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines;
+ global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ if (!is_object($outputlangs)) $outputlangs = $langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
- // Translations
+ // Load traductions files required by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ global $outputlangsbis;
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
+ }
+
$nblines = count($object->lines);
- $hidetop=0;
- if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){
- $hidetop=$conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
+ $hidetop = 0;
+ if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
+ $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
}
// Loop on each lines to detect if there is at least one image to show
- $realpatharray=array();
+ $realpatharray = array();
$this->atleastonephoto = false;
- if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
+ if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
{
$objphoto = new Product($this->db);
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto->fetch($object->lines[$i]->fk_product);
//var_dump($objphoto->ref);exit;
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
- $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/";
- $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/';
+ $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
+ $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
}
else
{
- $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default
- $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product') . $objphoto->id ."/photos/"; // alternative
+ $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
+ $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
}
$arephoto = false;
foreach ($pdir as $midir)
{
- if (! $arephoto)
+ if (!$arephoto)
{
- $dir = $conf->product->dir_output.'/'.$midir;
+ if ($conf->product->entity != $objphoto->entity) {
+ $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities
+ } else {
+ $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
+ }
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
{
@@ -324,14 +333,14 @@ class pdf_cyan extends ModelePDFPropales
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
- if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
$pdf->Open();
- $pagenb=0;
+ $pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
@@ -384,40 +393,42 @@ class pdf_cyan extends ModelePDFPropales
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
- $height_incoterms=$nexY-$tab_top;
+ $height_incoterms = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
}
}
// Affiche notes
- $notetoshow=empty($object->note_public)?'':$object->note_public;
- if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
{
// Get first sale rep
if (is_object($object->thirdparty))
{
- $salereparray=$object->thirdparty->getSalesRepresentatives($user);
- $salerepobj=new User($this->db);
+ $salereparray = $object->thirdparty->getSalesRepresentatives($user);
+ $salerepobj = new User($this->db);
$salerepobj->fetch($salereparray[0]['id']);
- if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
+ if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
}
}
- if (! empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
+ if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
{
- $tmpuser=new User($this->db);
+ $tmpuser = new User($this->db);
$tmpuser->fetch($object->user_author_id);
- $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
- if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email;
- if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
+ $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
+ if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email;
+ if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
}
+ $tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter;
+
$pagenb = $pdf->getPage();
if ($notetoshow)
{
@@ -529,7 +540,6 @@ class pdf_cyan extends ModelePDFPropales
$posyafter = $tab_top_newpage;
}
}
-
$tab_height = $tab_height - $height_note;
$tab_top = $posyafter + 6;
}
@@ -551,102 +561,111 @@ class pdf_cyan extends ModelePDFPropales
$nexY = $tab_top + $this->tabTitleHeight + 2;
// Loop on each lines
- $pageposbeforeprintlines=$pdf->getPage();
+ $pageposbeforeprintlines = $pdf->getPage();
$pagenb = $pageposbeforeprintlines;
for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
- $imglinesize=array();
- if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
+ $imglinesize = array();
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
$pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore=$pdf->getPage();
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
- $showpricebeforepagebreak=1;
- $posYAfterImage=0;
- $posYAfterDescription=0;
+ $showpricebeforepagebreak = 1;
+ $posYAfterImage = 0;
+ $posYAfterDescription = 0;
- if($this->getColumnStatus('photo'))
+ if ($this->getColumnStatus('photo'))
{
// We start with Photo of product line
- if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // If photo too high, we moved completely on new page
+ if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposbefore+1);
+ $pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
{
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
- $posYAfterImage=$curY+$imglinesize['height'];
+ $posYAfterImage = $curY + $imglinesize['height'];
}
}
// Description of product line
- if($this->getColumnStatus('desc'))
+ if ($this->getColumnStatus('desc'))
{
$pdf->startTransaction();
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
- $posyafter=$pdf->GetY();
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforsignature+$heightforinfotot))) // There is no space left for total+free text
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposafter+1);
+ $pdf->setPage($pageposafter + 1);
}
}
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
{
$pdf->commitTransaction();
}
- $posYAfterDescription=$pdf->GetY();
+ $posYAfterDescription = $pdf->GetY();
}
$nexY = $pdf->GetY();
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description or photo were moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
// VAT Rate
if ($this->getColumnStatus('vat'))
@@ -708,59 +727,59 @@ class pdf_cyan extends ModelePDFPropales
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails
);
- $reshook=$hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
+ $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
- if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
- else $tvaligne=$object->lines[$i]->total_tva;
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $object->lines[$i]->total_tva;
- $localtax1ligne=$object->lines[$i]->total_localtax1;
- $localtax2ligne=$object->lines[$i]->total_localtax2;
- $localtax1_rate=$object->lines[$i]->localtax1_tx;
- $localtax2_rate=$object->lines[$i]->localtax2_tx;
- $localtax1_type=$object->lines[$i]->localtax1_type;
- $localtax2_type=$object->lines[$i]->localtax2_type;
+ $localtax1ligne = $object->lines[$i]->total_localtax1;
+ $localtax2ligne = $object->lines[$i]->total_localtax2;
+ $localtax1_rate = $object->lines[$i]->localtax1_tx;
+ $localtax2_rate = $object->lines[$i]->localtax2_tx;
+ $localtax1_type = $object->lines[$i]->localtax1_type;
+ $localtax2_type = $object->lines[$i]->localtax2_type;
- if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
+ if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
- $vatrate=(string) $object->lines[$i]->tva_tx;
+ $vatrate = (string) $object->lines[$i]->tva_tx;
// Retrieve type from database for backward compatibility with old records
- if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
- && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
+ if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
{
- $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
+ $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
$localtax1_type = $localtaxtmp_array[0];
$localtax2_type = $localtaxtmp_array[2];
}
// retrieve global local tax
if ($localtax1_type && $localtax1ligne != 0)
- $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
+ $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
if ($localtax2_type && $localtax2ligne != 0)
- $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
+ $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
- if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
- if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0;
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
+ if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
$this->tva[$vatrate] += $tvaligne;
- if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
+ if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
+ $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Add space between lines
+ $nexY += 2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -857,41 +876,41 @@ class pdf_cyan extends ModelePDFPropales
$product = new Product($this->db);
$product->fetch($line->fk_product);
- if ($product->entity!=$conf->entity) {
- $entity_product_file=$product->entity;
+ if ($product->entity != $conf->entity) {
+ $entity_product_file = $product->entity;
} else {
- $entity_product_file=$conf->entity;
+ $entity_product_file = $conf->entity;
}
// If PDF is selected and file is not empty
if (count($filetomerge->lines) > 0) {
foreach ($filetomerge->lines as $linefile) {
- if (! empty($linefile->id) && ! empty($linefile->file_name)) {
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ if (!empty($linefile->id) && !empty($linefile->file_name)) {
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
- if (! empty($conf->product->enabled)) {
- $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir($product->id, 2, 0, 0, $product, 'product') . $product->id ."/photos";
- } elseif (! empty($conf->service->enabled)) {
- $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir($product->id, 2, 0, 0, $product, 'product') . $product->id ."/photos";
+ if (!empty($conf->product->enabled)) {
+ $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
+ } elseif (!empty($conf->service->enabled)) {
+ $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
}
}
else
{
- if (! empty($conf->product->enabled)) {
- $filetomerge_dir = $conf->product->multidir_output[$entity_product_file] . '/' . get_exdir(0, 0, 0, 0, $product, 'product') . dol_sanitizeFileName($product->ref);
- } elseif (! empty($conf->service->enabled)) {
- $filetomerge_dir = $conf->service->multidir_output[$entity_product_file] . '/' . get_exdir(0, 0, 0, 0, $product, 'product') . dol_sanitizeFileName($product->ref);
+ if (!empty($conf->product->enabled)) {
+ $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
+ } elseif (!empty($conf->service->enabled)) {
+ $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
}
}
- dol_syslog(get_class($this) . ':: upload_dir=' . $filetomerge_dir, LOG_DEBUG);
+ dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
- $infile = $filetomerge_dir . '/' . $linefile->file_name;
+ $infile = $filetomerge_dir.'/'.$linefile->file_name;
if (file_exists($infile) && is_readable($infile)) {
$pagecount = $pdf->setSourceFile($infile);
- for($i = 1; $i <= $pagecount; $i ++) {
+ for ($i = 1; $i <= $pagecount; $i++) {
$tplIdx = $pdf->importPage($i);
- if ($tplIdx!==false) {
+ if ($tplIdx !== false) {
$s = $pdf->getTemplatesize($tplIdx);
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
$pdf->useTemplate($tplIdx);
@@ -913,31 +932,31 @@ class pdf_cyan extends ModelePDFPropales
//Add pdfgeneration hook
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
- if (! empty($conf->global->MAIN_UMASK))
+ if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
- return 1; // No error
+ return 1; // No error
}
else
{
- $this->error=$langs->trans("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return 0;
}
}
else
{
- $this->error=$langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR");
+ $this->error = $langs->trans("ErrorConstantNotDefined", "PROP_OUTPUTDIR");
return 0;
}
}
@@ -962,17 +981,17 @@ class pdf_cyan extends ModelePDFPropales
* @param Object $object Object to show
* @param int $posy Y
* @param Translate $outputlangs Langs object
- * @return void
+ * @return int Pos y
*/
public function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
{
- global $conf;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
{
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1147,6 +1166,7 @@ class pdf_cyan extends ModelePDFPropales
protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
global $conf, $mysoc;
+
$default_font_size = pdf_getPDFFontSize($outputlangs);
$tab2_top = $posy;
@@ -1164,12 +1184,19 @@ class pdf_cyan extends ModelePDFPropales
$useborder = 0;
$index = 0;
+ $outputlangsbis = null;
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
+ }
+
// Total HT
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
- $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
+ $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
@@ -1191,28 +1218,29 @@ class pdf_cyan extends ModelePDFPropales
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
+ $totalvat .= ' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1223,13 +1251,13 @@ class pdf_cyan extends ModelePDFPropales
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
@@ -1238,15 +1266,16 @@ class pdf_cyan extends ModelePDFPropales
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
+ $totalvat .= ' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1270,7 +1299,8 @@ class pdf_cyan extends ModelePDFPropales
$tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
+ $totalvat .= ' ';
$totalvat .= vatrate($tvakey, 1).$tvacompl;
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
@@ -1282,11 +1312,11 @@ class pdf_cyan extends ModelePDFPropales
//Local tax 1 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -1295,16 +1325,17 @@ class pdf_cyan extends ModelePDFPropales
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
+ $totalvat .= ' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
}
@@ -1314,11 +1345,11 @@ class pdf_cyan extends ModelePDFPropales
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
// retrieve global local tax
if ($tvakey != 0) // On affiche pas taux 0
@@ -1328,16 +1359,17 @@ class pdf_cyan extends ModelePDFPropales
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
+ $totalvat .= ' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1351,7 +1383,7 @@ class pdf_cyan extends ModelePDFPropales
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalTTC") : ''), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
@@ -1360,6 +1392,7 @@ class pdf_cyan extends ModelePDFPropales
$pdf->SetTextColor(0, 0, 0);
+ $resteapayer = 0;
/*
$resteapayer = $object->total_ttc - $deja_regle;
if (! empty($object->paye)) $resteapayer=0;
@@ -1370,7 +1403,7 @@ class pdf_cyan extends ModelePDFPropales
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("AlreadyPaid") : ''), 0, 'L', 0);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
@@ -1395,7 +1428,7 @@ class pdf_cyan extends ModelePDFPropales
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("RemainderToPay") : ''), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
@@ -1440,24 +1473,25 @@ class pdf_cyan extends ModelePDFPropales
if (empty($hidetop))
{
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
- if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
+ $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ }
}
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', '', $default_font_size - 1);
// Output Rect
- $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
-
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
- if (empty($hidetop)){
- $pdf->line($this->marge_gauche, $tab_top+$this->tabTitleHeight, $this->page_largeur-$this->marge_droite, $tab_top+$this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
+ if (empty($hidetop)) {
+ $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
}
}
@@ -1475,10 +1509,8 @@ class pdf_cyan extends ModelePDFPropales
{
global $conf, $langs;
- $outputlangs->load("main");
- $outputlangs->load("bills");
- $outputlangs->load("propal");
- $outputlangs->load("companies");
+ // Load traductions files required by page
+ $outputlangs->loadLangs(array("main", "propal", "companies", "bills"));
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1493,8 +1525,8 @@ class pdf_cyan extends ModelePDFPropales
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-100;
+ $posy = $this->marge_haute;
+ $posx = $this->page_largeur - $this->marge_droite - 100;
$pdf->SetXY($this->marge_gauche, $posy);
@@ -1504,7 +1536,7 @@ class pdf_cyan extends ModelePDFPropales
if ($this->emetteur->logo)
{
$logodir = $conf->mycompany->dir_output;
- if (! empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
{
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
@@ -1514,8 +1546,8 @@ class pdf_cyan extends ModelePDFPropales
}
if (is_readable($logo))
{
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
}
else
{
@@ -1556,6 +1588,30 @@ class pdf_cyan extends ModelePDFPropales
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
+ }
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT))
+ {
+ $object->fetch_projet();
+ if (!empty($object->project->ref))
+ {
+ $posy += 3;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
+ }
+ }
+
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php
index 51438ed6bf8..89a532c2556 100644
--- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php
+++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php
@@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
class doc_generic_reception_odt extends ModelePdfReception
{
/**
- * @var Company Issuer object that emits
+ * @var Societe Issuer object that emits
*/
public $emetteur; // Objet societe qui emet
diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php
index 125c56960ca..f1c2eba89e4 100644
--- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php
+++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php
@@ -374,7 +374,12 @@ class pdf_squille extends ModelePdfReception
$pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
- $showpricebeforepagebreak = 0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
if (isset($imglinesize['width']) && isset($imglinesize['height']))
@@ -417,7 +422,12 @@ class pdf_squille extends ModelePdfReception
else
{
// We found a page break
- $showpricebeforepagebreak = 0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
index 23609ad4384..d5ccf5dbd89 100644
--- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
+++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
@@ -209,7 +209,7 @@ class doc_generic_stock_odt extends ModelePDFStock
/**
* Function to build a document on disk using the generic odt module.
*
- * @param Stock $object Object source to build document
+ * @param Entrepot $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
@@ -250,7 +250,7 @@ class doc_generic_stock_odt extends ModelePDFStock
if (!is_object($object))
{
$id = $object;
- $object = new Stock($this->db);
+ $object = new Entrepot($this->db);
$result = $object->fetch($id);
if ($result < 0)
{
@@ -258,7 +258,8 @@ class doc_generic_stock_odt extends ModelePDFStock
return -1;
}
}
- $stockFournisseur = new StockFournisseur($this->db);
+
+ $stockFournisseur = new ProductFournisseur($this->db);
$supplierprices = $stockFournisseur->list_stock_fournisseur_price($object->id);
$object->supplierprices = $supplierprices;
diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php
index 97c0744c121..17071641817 100644
--- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php
@@ -181,7 +181,7 @@ class pdf_standard extends ModelePDFStock
/**
* Function to build a document on disk using the generic odt module.
*
- * @param Stock $object Object source to build document
+ * @param Entrepot $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
@@ -383,7 +383,12 @@ class pdf_standard extends ModelePDFStock
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php
index 4f59c2510b4..362f17c7e9c 100644
--- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php
+++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php
@@ -543,7 +543,12 @@ class pdf_stdmovement extends ModelePDFMovement
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
diff --git a/htdocs/core/modules/supplier_invoice/pdf/index.html b/htdocs/core/modules/supplier_invoice/doc/index.html
similarity index 100%
rename from htdocs/core/modules/supplier_invoice/pdf/index.html
rename to htdocs/core/modules/supplier_invoice/doc/index.html
diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php
similarity index 99%
rename from htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
rename to htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php
index 32926e098e3..a484343b1c0 100644
--- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php
@@ -20,7 +20,7 @@
*/
/**
- * \file htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+ * \file htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php
* \ingroup fournisseur
* \brief Class file to generate the supplier invoices with the canelle model
*/
@@ -152,8 +152,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$this->option_codeproduitservice = 1; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
- $this->franchise = !$mysoc->tva_assuj;
-
// Define column position
$this->posxdesc = $this->marge_gauche + 1;
$this->posxtva = 112;
@@ -430,7 +428,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php
index 8708a2c01a2..7d2aafb4882 100644
--- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php
+++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php
@@ -47,7 +47,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Cactus';
diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php
index 85eb6673124..39360550d8c 100644
--- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php
+++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php
@@ -50,7 +50,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Tulip';
diff --git a/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php
similarity index 99%
rename from htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php
rename to htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php
index e3c46904c1f..c71fe8f59ec 100644
--- a/htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php
+++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php
@@ -23,7 +23,7 @@
*/
/**
- * \file htdocs/core/modules/supplier_order/pdf/doc_generic_supplier_order_odt.modules.php
+ * \file htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php
* \ingroup commande
* \brief File of class to build ODT documents for supplier orders
*/
diff --git a/htdocs/core/modules/supplier_order/pdf/index.html b/htdocs/core/modules/supplier_order/doc/index.html
similarity index 100%
rename from htdocs/core/modules/supplier_order/pdf/index.html
rename to htdocs/core/modules/supplier_order/doc/index.html
diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
similarity index 83%
rename from htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php
rename to htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
index 8ff4c3ad429..1c266ae89b6 100644
--- a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php
+++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
@@ -23,7 +23,7 @@
*/
/**
- * \file htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php
+ * \file htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
* \ingroup fournisseur
* \brief File of class to generate suppliers orders from cornas model
*/
@@ -71,7 +71,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
* Dolibarr version of the loaded document
* @var string
*/
- public $version = 'development';
+ public $version = 'dolibarr';
/**
* @var int page_largeur
@@ -153,8 +153,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 1; // Support add of a watermark on drafts
- $this->franchise = !$mysoc->tva_assuj;
-
// Get source company
$this->emetteur = $mysoc;
if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
@@ -185,57 +183,64 @@ class pdf_cornas extends ModelePDFSuppliersOrders
public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$hookmanager,$mysoc,$nblines;
+ global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ if (!is_object($outputlangs)) $outputlangs = $langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ global $outputlangsbis;
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
+ }
+
$nblines = count($object->lines);
- $hidetop=0;
- if(!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)){
- $hidetop=$conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
+ $hidetop = 0;
+ if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
+ $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
}
// Loop on each lines to detect if there is at least one image to show
- $realpatharray=array();
- if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE))
+ $realpatharray = array();
+ if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE))
{
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
- $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/";
+ $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
}
else
{
- $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/';
+ $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
$dir = $conf->product->dir_output.'/'.$pdir;
}
- $realpath='';
+ $realpath = '';
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
{
- $filename=$obj['photo'];
+ $filename = $obj['photo'];
//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
$realpath = $dir.$filename;
break;
}
- if ($realpath) $realpatharray[$i]=$realpath;
+ if ($realpath) $realpatharray[$i] = $realpath;
}
}
- if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
+ if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
if ($conf->fournisseur->commande->dir_output)
{
@@ -274,24 +279,24 @@ class pdf_cornas extends ModelePDFSuppliersOrders
if (file_exists($dir))
{
// Add pdfgeneration hook
- if (! is_object($hookmanager))
+ if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager=new HookManager($this->db);
+ $hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$nblines = count($object->lines);
- $pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $heightforinfotot = 50; // Height reserved to output the info and total part
- $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $heightforinfotot = 50; // Height reserved to output the info and total part
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF'))
@@ -328,8 +333,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders
}
}
-
-
// New page
$pdf->AddPage();
if (!empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -351,28 +354,28 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
- $height_incoterms=$nexY-$tab_top;
+ $height_incoterms = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
}
}
// Affiche notes
- $notetoshow=empty($object->note_public)?'':$object->note_public;
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
$pagenb = $pdf->getPage();
if ($notetoshow)
{
- $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
+ $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
$pageposbeforenote = $pagenb;
- $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
+ $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
@@ -494,98 +497,107 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
// Loop on each lines
- $pageposbeforeprintlines=$pdf->getPage();
+ $pageposbeforeprintlines = $pdf->getPage();
$pagenb = $pageposbeforeprintlines;
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
- $imglinesize=array();
- if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
+ $imglinesize = array();
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
$pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore=$pdf->getPage();
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
- $showpricebeforepagebreak=1;
- $posYAfterImage=0;
- $posYAfterDescription=0;
+ $showpricebeforepagebreak = 1;
+ $posYAfterImage = 0;
+ $posYAfterDescription = 0;
// We start with Photo of product line
- if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page
+ if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposbefore+1);
+ $pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
{
- $curX = $this->posxpicture-1;
- $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $curX = $this->posxpicture - 1;
+ $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
- $posYAfterImage=$curY+$imglinesize['height'];
+ $posYAfterImage = $curY + $imglinesize['height'];
}
// Description of product line
- $curX = $this->posxdesc-1;
- $showpricebeforepagebreak=1;
+ $curX = $this->posxdesc - 1;
+ $showpricebeforepagebreak = 1;
- if($this->getColumnStatus('desc'))
+ if ($this->getColumnStatus('desc'))
{
$pdf->startTransaction();
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
- $posyafter=$pdf->GetY();
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposafter+1);
+ $pdf->setPage($pageposafter + 1);
}
}
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
{
$pdf->commitTransaction();
}
- $posYAfterDescription=$pdf->GetY();
+ $posYAfterDescription = $pdf->GetY();
}
$nexY = $pdf->GetY();
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
// VAT Rate
if ($this->getColumnStatus('vat'))
@@ -638,7 +650,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
}
- $parameters=array(
+ $parameters = array(
'object' => $object,
'i' => $i,
'pdf' =>& $pdf,
@@ -647,58 +659,58 @@ class pdf_cornas extends ModelePDFSuppliersOrders
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails
);
- $reshook=$hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
+ $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
- if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
- else $tvaligne=$object->lines[$i]->total_tva;
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $object->lines[$i]->total_tva;
- $localtax1ligne=$object->lines[$i]->total_localtax1;
- $localtax2ligne=$object->lines[$i]->total_localtax2;
- $localtax1_rate=$object->lines[$i]->localtax1_tx;
- $localtax2_rate=$object->lines[$i]->localtax2_tx;
- $localtax1_type=$object->lines[$i]->localtax1_type;
- $localtax2_type=$object->lines[$i]->localtax2_type;
+ $localtax1ligne = $object->lines[$i]->total_localtax1;
+ $localtax2ligne = $object->lines[$i]->total_localtax2;
+ $localtax1_rate = $object->lines[$i]->localtax1_tx;
+ $localtax2_rate = $object->lines[$i]->localtax2_tx;
+ $localtax1_type = $object->lines[$i]->localtax1_type;
+ $localtax2_type = $object->lines[$i]->localtax2_type;
- if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100;
- if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
- if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
+ if (!empty($object->remise_percent)) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
+ if (!empty($object->remise_percent)) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
+ if (!empty($object->remise_percent)) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
- $vatrate=(string) $object->lines[$i]->tva_tx;
+ $vatrate = (string) $object->lines[$i]->tva_tx;
// Retrieve type from database for backward compatibility with old records
- if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
- && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
+ if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
{
- $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty);
+ $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty);
$localtax1_type = $localtaxtmp_array[0];
$localtax2_type = $localtaxtmp_array[2];
}
// retrieve global local tax
if ($localtax1_type && $localtax1ligne != 0)
- $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
+ $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
if ($localtax2_type && $localtax2ligne != 0)
- $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
+ $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
- if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
- if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0;
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
+ if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
$this->tva[$vatrate] += $tvaligne;
- if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
+ if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80,80,80)));
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
+ $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Add space between lines
+ $nexY += 2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -771,31 +783,31 @@ class pdf_cornas extends ModelePDFSuppliersOrders
// Add pdfgeneration hook
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
- if (! empty($conf->global->MAIN_UMASK))
+ if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
- return 1; // No error
+ return 1; // No error
}
else
{
- $this->error=$langs->trans("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return 0;
}
}
else
{
- $this->error=$langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
+ $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
return 0;
}
}
@@ -830,11 +842,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{
// phpcs:enable
- global $conf;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
{
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
@@ -855,11 +867,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement);
- $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement);
+ $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
- $posy=$pdf->GetY()+3;
+ $posy = $pdf->GetY() + 3;
}
// Show payment mode
@@ -990,7 +1002,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders
//Local tax 1
foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
foreach ($localtax_rate as $tvakey => $tvaval)
{
@@ -1001,15 +1013,15 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat =$outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1130,28 +1142,30 @@ class pdf_cornas extends ModelePDFSuppliersOrders
if (empty($hidetop))
{
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
- if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
+ $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ }
}
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', '', $default_font_size - 1);
// Output Rect
- $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
foreach ($this->cols as $colKey => $colDef)
{
- if(!$this->getColumnStatus($colKey)) continue;
+ if (!$this->getColumnStatus($colKey)) continue;
// get title label
- $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
+ $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']);
// Add column separator
- if(!empty($colDef['border-left'])){
+ if (!empty($colDef['border-left'])) {
$pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
}
@@ -1159,13 +1173,13 @@ class pdf_cornas extends ModelePDFSuppliersOrders
{
$pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]);
- $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
+ $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1];
$pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']);
}
}
- if (empty($hidetop)){
- $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter
+ if (empty($hidetop)) {
+ $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter
}
}
@@ -1201,19 +1215,19 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
- $posx=$this->page_largeur-$this->marge_droite-100;
- $posy=$this->marge_haute;
+ $posx = $this->page_largeur - $this->marge_droite - 100;
+ $posy = $this->marge_haute;
$pdf->SetXY($this->marge_gauche, $posy);
// Logo
- $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
+ $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (is_readable($logo))
{
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
}
else
{
@@ -1225,91 +1239,91 @@ class pdf_cornas extends ModelePDFSuppliersOrders
}
else
{
- $text=$this->emetteur->name;
+ $text = $this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
$pdf->SetFont('', 'B', $default_font_size + 3);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $title=$outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref);
+ $title = $outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref);
$pdf->MultiCell(100, 3, $title, '', 'R');
- $posy+=1;
+ $posy += 1;
if ($object->ref_supplier)
{
- $posy+=4;
+ $posy += 4;
$pdf->SetFont('', 'B', $default_font_size);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
- $posy+=1;
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
+ $posy += 1;
}
- $pdf->SetFont('', '', $default_font_size -1);
+ $pdf->SetFont('', '', $default_font_size - 1);
- if (! empty($conf->global->PDF_SHOW_PROJECT))
+ if (!empty($conf->global->PDF_SHOW_PROJECT))
{
$object->fetch_projet();
- if (! empty($object->project->ref))
+ if (!empty($object->project->ref))
{
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$langs->load("projects");
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
}
}
- if (! empty($object->date_commande))
+ if (!empty($object->date_commande))
{
- $posy+=5;
+ $posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R');
}
else
{
- $posy+=5;
+ $posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(255, 0, 0);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R');
}
$pdf->SetTextColor(0, 0, 60);
- $usehourmin='day';
- if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour';
- if (! empty($object->date_livraison))
+ $usehourmin = 'day';
+ if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 'dayhour';
+ if (!empty($object->date_livraison))
{
- $posy+=4;
- $pdf->SetXY($posx-90, $posy);
- $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R');
+ $posy += 4;
+ $pdf->SetXY($posx - 90, $posy);
+ $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R');
}
if ($object->thirdparty->code_fournisseur)
{
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
}
// Get contact
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
{
- $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL');
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
if (count($arrayidcontact) > 0)
{
- $usertmp=new User($this->db);
+ $usertmp = new User($this->db);
$usertmp->fetch($arrayidcontact[0]);
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
}
}
- $posy+=1;
+ $posy += 1;
$pdf->SetTextColor(0, 0, 60);
$top_shift = 0;
@@ -1364,9 +1378,9 @@ class pdf_cornas extends ModelePDFSuppliersOrders
- // If BILLING contact defined on order, we use it
+ // If CUSTOMER contact defined on order, we use it. Note: Even if this is a supplier object, the code for external contat that follow order is 'CUSTOMER'
$usecontact = false;
- $arrayidcontact = $object->getIdContact('external', 'BILLING');
+ $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
if (count($arrayidcontact) > 0)
{
$usecontact = true;
@@ -1661,10 +1675,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders
uasort($this->cols, array($this, 'columnSort'));
// Positionning
- $curX = $this->page_largeur-$this->marge_droite; // start from right
+ $curX = $this->page_largeur - $this->marge_droite; // start from right
// Array width
- $arrayWidth = $this->page_largeur-$this->marge_droite-$this->marge_gauche;
+ $arrayWidth = $this->page_largeur - $this->marge_droite - $this->marge_gauche;
// Count flexible column
$totalDefinedColWidth = 0;
@@ -1813,16 +1827,16 @@ class pdf_cornas extends ModelePDFSuppliersOrders
{
global $hookmanager;
- $parameters=array(
+ $parameters = array(
'curY' =>& $curY,
'columnText' => $columnText,
'colKey' => $colKey
);
- $reshook=$hookmanager->executeHooks('printStdColumnContent', $parameters, $this); // Note that $action and $object may have been modified by hook
+ $reshook = $hookmanager->executeHooks('printStdColumnContent', $parameters, $this); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (!$reshook)
{
- if(empty($columnText)) return;
+ if (empty($columnText)) return;
$pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position
$colDef = $this->cols[$colKey];
$pdf->MultiCell($this->getColumnContentWidth($colKey), 2, $columnText, '', $colDef['content']['align']);
diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php
similarity index 61%
rename from htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
rename to htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php
index a30232f0b41..e4cb8f53e66 100644
--- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
+++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php
@@ -23,7 +23,7 @@
*/
/**
- * \file htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
+ * \file htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php
* \ingroup fournisseur
* \brief File of class to generate suppliers orders from muscadet model
*/
@@ -129,72 +129,70 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$this->db = $db;
$this->name = "muscadet";
- $this->description = $langs->trans('SuppliersCommandModel');
+ $this->description = $langs->trans('SuppliersCommandModelMuscadet');
// Page size for A4 format
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
+ $formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+ $this->format = array($this->page_largeur, $this->page_hauteur);
+ $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
+ $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
+ $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
+ $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
- $this->option_logo = 1; // Affiche logo
- $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
- $this->option_modereg = 1; // Affiche mode reglement
- $this->option_condreg = 1; // Affiche conditions reglement
- $this->option_codeproduitservice = 1; // Affiche code produit-service
- $this->option_multilang = 1; // Dispo en plusieurs langues
- $this->option_escompte = 0; // Affiche si il y a eu escompte
- $this->option_credit_note = 0; // Support credit notes
- $this->option_freetext = 1; // Support add of a personalised text
- $this->option_draft_watermark = 1; // Support add of a watermark on drafts
-
- $this->franchise=!$mysoc->tva_assuj;
+ $this->option_logo = 1; // Affiche logo
+ $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Affiche mode reglement
+ $this->option_condreg = 1; // Affiche conditions reglement
+ $this->option_codeproduitservice = 1; // Affiche code produit-service
+ $this->option_multilang = 1; // Dispo en plusieurs langues
+ $this->option_escompte = 0; // Affiche si il y a eu escompte
+ $this->option_credit_note = 0; // Support credit notes
+ $this->option_freetext = 1; // Support add of a personalised text
+ $this->option_draft_watermark = 1; // Support add of a watermark on drafts
// Get source company
- $this->emetteur=$mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined
+ $this->emetteur = $mysoc;
+ if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
// Define position of columns
- $this->posxdesc=$this->marge_gauche+1;
- $this->posxdiscount=162;
- $this->postotalht=174;
+ $this->posxdesc = $this->marge_gauche + 1;
+ $this->posxdiscount = 162;
+ $this->postotalht = 174;
if ($conf->global->PRODUCT_USE_UNITS)
{
- $this->posxtva=95;
- $this->posxup=114;
- $this->posxqty=132;
- $this->posxunit=147;
+ $this->posxtva = 95;
+ $this->posxup = 114;
+ $this->posxqty = 132;
+ $this->posxunit = 147;
} else {
- $this->posxtva=110;
- $this->posxup=126;
- $this->posxqty=145;
- $this->posxunit=162;
+ $this->posxtva = 110;
+ $this->posxup = 126;
+ $this->posxqty = 145;
+ $this->posxunit = 162;
}
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference
- $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxup = $this->posxtva; // posxtva is picture position reference
+ $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{
- $this->posxpicture-=20;
- $this->posxtva-=20;
- $this->posxup-=20;
- $this->posxqty-=20;
- $this->posxunit-=20;
- $this->posxdiscount-=20;
- $this->postotalht-=20;
+ $this->posxpicture -= 20;
+ $this->posxtva -= 20;
+ $this->posxup -= 20;
+ $this->posxqty -= 20;
+ $this->posxunit -= 20;
+ $this->posxdiscount -= 20;
+ $this->postotalht -= 20;
}
- $this->tva=array();
- $this->localtax1=array();
- $this->localtax2=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
+ $this->tva = array();
+ $this->localtax1 = array();
+ $this->localtax2 = array();
+ $this->atleastoneratenotnull = 0;
+ $this->atleastonediscount = 0;
}
@@ -213,11 +211,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$hookmanager,$mysoc,$nblines;
+ global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ if (!is_object($outputlangs)) $outputlangs = $langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "orders", "companies", "bills", "dict", "products"));
@@ -225,40 +223,40 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
- $realpatharray=array();
- if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE))
+ $realpatharray = array();
+ if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE))
{
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
- $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/";
+ $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
}
else
{
- $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/';
+ $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
$dir = $conf->product->dir_output.'/'.$pdir;
}
- $realpath='';
+ $realpath = '';
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
{
- $filename=$obj['photo'];
+ $filename = $obj['photo'];
//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
$realpath = $dir.$filename;
break;
}
- if ($realpath) $realpatharray[$i]=$realpath;
+ if ($realpath) $realpatharray[$i] = $realpath;
}
}
- if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
+ if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
if ($conf->fournisseur->commande->dir_output)
{
@@ -274,22 +272,22 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if ($object->specimen)
{
$dir = $conf->fournisseur->commande->dir_output;
- $file = $dir . "/SPECIMEN.pdf";
+ $file = $dir."/SPECIMEN.pdf";
}
else
{
$objectref = dol_sanitizeFileName($object->ref);
$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
- $dir = $conf->fournisseur->commande->dir_output . '/'. $objectref;
- $file = $dir . "/" . $objectref . ".pdf";
- if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
+ $dir = $conf->fournisseur->commande->dir_output.'/'.$objectref;
+ $file = $dir."/".$objectref.".pdf";
+ if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf";
}
- if (! file_exists($dir))
+ if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
@@ -297,24 +295,24 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if (file_exists($dir))
{
// Add pdfgeneration hook
- if (! is_object($hookmanager))
+ if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager=new HookManager($this->db);
+ $hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$nblines = count($object->lines);
- $pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $heightforinfotot = 50; // Height reserved to output the info and total part
- $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $heightforinfotot = 50; // Height reserved to output the info and total part
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF'))
@@ -324,14 +322,14 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
- if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
$pdf->Open();
- $pagenb=0;
+ $pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
@@ -339,12 +337,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
- if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Positionne $this->atleastonediscount si on a au moins une remise
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
if ($object->lines[$i]->remise_percent)
{
@@ -354,26 +352,26 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if (empty($this->atleastonediscount))
{
$delta = ($this->postotalht - $this->posxdiscount);
- $this->posxpicture+=$delta;
- $this->posxtva+=$delta;
- $this->posxup+=$delta;
- $this->posxqty+=$delta;
- $this->posxunit+=$delta;
- $this->posxdiscount+=$delta;
+ $this->posxpicture += $delta;
+ $this->posxtva += $delta;
+ $this->posxup += $delta;
+ $this->posxqty += $delta;
+ $this->posxunit += $delta;
+ $this->posxdiscount += $delta;
// post of fields after are not modified, stay at same position
}
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);
- $tab_top = 90+$top_shift;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
+ $tab_top = 90 + $top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
// Incoterm
if ($conf->incoterm->enabled)
@@ -384,33 +382,33 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
- $height_incoterms=$nexY-$tab_top;
+ $height_incoterms = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
}
}
// Affiche notes
- if (! empty($object->note_public))
+ if (!empty($object->note_public))
{
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($object->note_public), 0, 1);
$nexY = $pdf->GetY();
- $height_note=$nexY-$tab_top;
+ $height_note = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
}
$iniY = $tab_top + 7;
@@ -418,81 +416,90 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
- $imglinesize=array();
- if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
+ $imglinesize = array();
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
$pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore=$pdf->getPage();
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
- $showpricebeforepagebreak=1;
- $posYAfterImage=0;
- $posYAfterDescription=0;
+ $showpricebeforepagebreak = 1;
+ $posYAfterImage = 0;
+ $posYAfterDescription = 0;
// We start with Photo of product line
- if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page
+ if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposbefore+1);
+ $pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
{
- $curX = $this->posxpicture-1;
- $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $curX = $this->posxpicture - 1;
+ $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
- $posYAfterImage=$curY+$imglinesize['height'];
+ $posYAfterImage = $curY + $imglinesize['height'];
}
// Description of product line
- $curX = $this->posxdesc-1;
- $showpricebeforepagebreak=1;
+ $curX = $this->posxdesc - 1;
+ $showpricebeforepagebreak = 1;
$pdf->startTransaction();
if ($posYAfterImage > 0)
{
- $descWidth = $this->posxpicture-$curX;
+ $descWidth = $this->posxpicture - $curX;
}
else
{
- $descWidth = $this->posxtva-$curX;
+ $descWidth = $this->posxtva - $curX;
}
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
- $posyafter=$pdf->GetY();
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
+ $posyafter = $pdf->GetY();
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposafter+1);
+ $pdf->setPage($pageposafter + 1);
}
}
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
@@ -501,42 +508,42 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
}
$nexY = $pdf->GetY();
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
// VAT Rate
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxtva, $curY);
- $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
+ $pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R');
}
// Unit price before discount
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxup, $curY);
- $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
+ $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
// Quantity
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxqty, $curY);
- $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
+ $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
// Unit
- if($conf->global->PRODUCT_USE_UNITS)
+ if ($conf->global->PRODUCT_USE_UNITS)
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
- $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
+ $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
}
// Discount on line
@@ -544,63 +551,63 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if ($object->lines[$i]->remise_percent)
{
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R');
+ $pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0, 'R');
}
// Total HT line
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs);
$pdf->SetXY($this->postotalht, $curY);
- $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
+ $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
- if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
- else $tvaligne=$object->lines[$i]->total_tva;
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $object->lines[$i]->total_tva;
- $localtax1ligne=$object->lines[$i]->total_localtax1;
- $localtax2ligne=$object->lines[$i]->total_localtax2;
- $localtax1_rate=$object->lines[$i]->localtax1_tx;
- $localtax2_rate=$object->lines[$i]->localtax2_tx;
- $localtax1_type=$object->lines[$i]->localtax1_type;
- $localtax2_type=$object->lines[$i]->localtax2_type;
+ $localtax1ligne = $object->lines[$i]->total_localtax1;
+ $localtax2ligne = $object->lines[$i]->total_localtax2;
+ $localtax1_rate = $object->lines[$i]->localtax1_tx;
+ $localtax2_rate = $object->lines[$i]->localtax2_tx;
+ $localtax1_type = $object->lines[$i]->localtax1_type;
+ $localtax2_type = $object->lines[$i]->localtax2_type;
- if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100;
- if (! empty($object->remise_percent)) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
- if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
+ if (!empty($object->remise_percent)) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
+ if (!empty($object->remise_percent)) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
+ if (!empty($object->remise_percent)) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
- $vatrate=(string) $object->lines[$i]->tva_tx;
+ $vatrate = (string) $object->lines[$i]->tva_tx;
// Retrieve type from database for backward compatibility with old records
- if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
- && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
+ if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
{
- $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty);
+ $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $mysoc, $object->thirdparty);
$localtax1_type = $localtaxtmp_array[0];
$localtax2_type = $localtaxtmp_array[2];
}
// retrieve global local tax
if ($localtax1_type && $localtax1ligne != 0)
- $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
+ $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
if ($localtax2_type && $localtax2ligne != 0)
- $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
+ $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
- if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
- if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0;
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
+ if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
$this->tva[$vatrate] += $tvaligne;
- if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
+ if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
+ $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Add space between lines
+ $nexY += 2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -617,10 +624,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pagenb++;
$pdf->setPage($pagenb);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
- if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
{
if ($pagenb == 1)
{
@@ -633,7 +640,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$this->_pagefoot($pdf, $object, $outputlangs, 1);
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
@@ -643,24 +650,24 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
// Affiche zone infos
- $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
+ $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux
- $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+ $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Affiche zone versements
if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
{
- $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
+ $posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
}
// Pied de page
@@ -673,31 +680,31 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
// Add pdfgeneration hook
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
- if (! empty($conf->global->MAIN_UMASK))
+ if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
- return 1; // No error
+ return 1; // No error
}
else
{
- $this->error=$langs->trans("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return 0;
}
}
else
{
- $this->error=$langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
+ $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
return 0;
}
}
@@ -732,20 +739,20 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{
// phpcs:enable
- global $conf;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
{
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
- $posy=$pdf->GetY()+4;
+ $posy = $pdf->GetY() + 4;
}
- $posxval=52;
+ $posxval = 52;
// Show payments conditions
if (!empty($object->cond_reglement_code) || $object->cond_reglement)
@@ -757,11 +764,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement);
- $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement);
+ $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
- $posy=$pdf->GetY()+3;
+ $posy = $pdf->GetY() + 3;
}
// Show payment mode
@@ -774,10 +781,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
+ $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
- $posy=$pdf->GetY()+2;
+ $posy = $pdf->GetY() + 2;
}
@@ -799,7 +806,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
// phpcs:enable
- global $conf,$mysoc;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -811,27 +818,27 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$col1x = 120; $col2x = 170;
if ($this->page_largeur < 210) // To work with US executive format
{
- $col2x-=20;
+ $col2x -= 20;
}
$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
- $useborder=0;
+ $useborder = 0;
$index = 0;
// Total HT
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + 0);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, 'R', 1);
// Show VAT by rates and total
$pdf->SetFillColor(248, 248, 248);
- $this->atleastoneratenotnull=0;
- foreach($this->tva as $tvakey => $tvaval)
+ $this->atleastoneratenotnull = 0;
+ foreach ($this->tva as $tvakey => $tvaval)
{
if ($tvakey > 0) // On affiche pas taux 0
{
@@ -840,47 +847,47 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
- $totalvat.=vatrate($tvakey, 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
+ $totalvat .= vatrate($tvakey, 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
}
}
- if (! $this->atleastoneratenotnull) // If no vat at all
+ if (!$this->atleastoneratenotnull) // If no vat at all
{
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
// Total LocalTax1
- if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
+ if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0)
{
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
}
// Total LocalTax2
- if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
+ if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0)
{
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
}
@@ -890,11 +897,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
//Local tax 1
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -903,15 +910,15 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat =$outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -922,11 +929,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
//Local tax 2
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -935,15 +942,15 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat =$outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
@@ -957,7 +964,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
@@ -965,13 +972,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->SetTextColor(0, 0, 0);
- $creditnoteamount=0;
- $depositsamount=0;
+ $creditnoteamount = 0;
+ $depositsamount = 0;
//$creditnoteamount=$object->getSumCreditNotesUsed();
//$depositsamount=$object->getSumDepositsUsed();
//print "x".$creditnoteamount."-".$depositsamount;exit;
$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
- if (! empty($object->paye)) $resteapayer=0;
+ if (!empty($object->paye)) $resteapayer = 0;
if ($deja_regle > 0)
{
@@ -979,7 +986,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
@@ -987,7 +994,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
@@ -1019,8 +1026,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
global $conf;
// Force to disable hidetop and hidebottom
- $hidebottom=0;
- if ($hidetop) $hidetop=-1;
+ $hidebottom = 0;
+ if ($hidetop) $hidetop = -1;
$currency = !empty($currency) ? $currency : $conf->currency;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1032,24 +1039,24 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if (empty($hidetop))
{
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
- if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
}
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', '', $default_font_size - 1);
// Output Rect
- $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
if (empty($hidetop))
{
- $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter
+ $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter
- $pdf->SetXY($this->posxdesc-1, $tab_top+1);
+ $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
}
@@ -1058,26 +1065,26 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
if (empty($hidetop))
{
- $pdf->SetXY($this->posxtva-3, $tab_top+1);
- $pdf->MultiCell($this->posxup-$this->posxtva+3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
+ $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
+ $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
}
}
$pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height);
if (empty($hidetop))
{
- $pdf->SetXY($this->posxup-1, $tab_top+1);
- $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
+ $pdf->SetXY($this->posxup - 1, $tab_top + 1);
+ $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
}
- $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
+ $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
if (empty($hidetop))
{
- $pdf->SetXY($this->posxqty-1, $tab_top+1);
- $pdf->MultiCell($this->posxunit-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
+ $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
+ $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
- if($conf->global->PRODUCT_USE_UNITS) {
+ if ($conf->global->PRODUCT_USE_UNITS) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -1085,13 +1092,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
}
}
- $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
+ $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
if (empty($hidetop))
{
if ($this->atleastonediscount)
{
- $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
+ $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
+ $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
}
}
@@ -1101,7 +1108,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
}
if (empty($hidetop))
{
- $pdf->SetXY($this->postotalht-1, $tab_top+1);
+ $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C');
}
}
@@ -1138,19 +1145,19 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
- $posx=$this->page_largeur-$this->marge_droite-100;
- $posy=$this->marge_haute;
+ $posx = $this->page_largeur - $this->marge_droite - 100;
+ $posy = $this->marge_haute;
$pdf->SetXY($this->marge_gauche, $posy);
// Logo
- $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
+ $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (is_readable($logo))
{
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
}
else
{
@@ -1162,91 +1169,91 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
}
else
{
- $text=$this->emetteur->name;
+ $text = $this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
$pdf->SetFont('', 'B', $default_font_size + 3);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $title=$outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref);
+ $title = $outputlangs->transnoentities("SupplierOrder")." ".$outputlangs->convToOutputCharset($object->ref);
$pdf->MultiCell(100, 3, $title, '', 'R');
- $posy+=1;
+ $posy += 1;
if ($object->ref_supplier)
{
- $posy+=4;
+ $posy += 4;
$pdf->SetFont('', 'B', $default_font_size);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : " . $outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
- $posy+=1;
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefSupplier")." : ".$outputlangs->convToOutputCharset($object->ref_supplier), '', 'R');
+ $posy += 1;
}
- $pdf->SetFont('', '', $default_font_size -1);
+ $pdf->SetFont('', '', $default_font_size - 1);
- if (! empty($conf->global->PDF_SHOW_PROJECT))
+ if (!empty($conf->global->PDF_SHOW_PROJECT))
{
$object->fetch_projet();
- if (! empty($object->project->ref))
+ if (!empty($object->project->ref))
{
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$langs->load("projects");
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
}
}
- if (! empty($object->date_commande))
+ if (!empty($object->date_commande))
{
- $posy+=5;
+ $posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date_commande, "day", false, $outputlangs, true), '', 'R');
}
else
{
- $posy+=5;
+ $posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(255, 0, 0);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderToProcess"), '', 'R');
}
$pdf->SetTextColor(0, 0, 60);
- $usehourmin='day';
- if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin='dayhour';
- if (! empty($object->date_livraison))
+ $usehourmin = 'day';
+ if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 'dayhour';
+ if (!empty($object->date_livraison))
{
- $posy+=4;
- $pdf->SetXY($posx-90, $posy);
- $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R');
+ $posy += 4;
+ $pdf->SetXY($posx - 90, $posy);
+ $pdf->MultiCell(190, 3, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_livraison, $usehourmin, false, $outputlangs, true), '', 'R');
}
if ($object->thirdparty->code_fournisseur)
{
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
}
// Get contact
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
{
- $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL');
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
if (count($arrayidcontact) > 0)
{
- $usertmp=new User($this->db);
+ $usertmp = new User($this->db);
$usertmp->fetch($arrayidcontact[0]);
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
}
}
- $posy+=1;
+ $posy += 1;
$pdf->SetTextColor(0, 0, 60);
$top_shift = 0;
@@ -1261,27 +1268,27 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if ($showaddress)
{
// Sender properties
- $carac_emetteur='';
+ $carac_emetteur = '';
// Add internal contact of proposal if defined
- $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL');
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
if (count($arrayidcontact) > 0)
{
$object->fetch_user($arrayidcontact[0]);
- $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+ $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
}
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
- $posy=42+$top_shift;
- $posx=$this->marge_gauche;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
- $hautcadre=40;
+ $posy = 42 + $top_shift;
+ $posx = $this->marge_gauche;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
+ $hautcadre = 40;
// Show sender frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx, $posy-5);
+ $pdf->SetXY($posx, $posy - 5);
$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
$pdf->SetXY($posx, $posy);
$pdf->SetFillColor(230, 230, 230);
@@ -1289,24 +1296,24 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetTextColor(0, 0, 60);
// Show sender name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
- $posy=$pdf->getY();
+ $posy = $pdf->getY();
// Show sender information
- $pdf->SetXY($posx+2, $posy);
+ $pdf->SetXY($posx + 2, $posy);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
// If CUSTOMER contact defined on order, we use it. Note: Even if this is a supplier object, the code for external contat that follow order is 'CUSTOMER'
- $usecontact=false;
- $arrayidcontact=$object->getIdContact('external', 'CUSTOMER');
+ $usecontact = false;
+ $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
if (count($arrayidcontact) > 0)
{
- $usecontact=true;
- $result=$object->fetch_contact($arrayidcontact[0]);
+ $usecontact = true;
+ $result = $object->fetch_contact($arrayidcontact[0]);
}
//Recipient name
@@ -1317,26 +1324,26 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$thirdparty = $object->thirdparty;
}
- $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
+ $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
- $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object);
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
// Show recipient
- $widthrecbox=100;
- if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
- $posy=42+$top_shift;
- $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ $widthrecbox = 100;
+ if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
+ $posy = 42 + $top_shift;
+ $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
// Show recipient frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx+2, $posy-5);
+ $pdf->SetXY($posx + 2, $posy - 5);
$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show recipient name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
@@ -1344,7 +1351,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
// Show recipient information
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->SetXY($posx+2, $posy);
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
}
@@ -1364,7 +1371,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
global $conf;
- $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
}
diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php
index ece2d8e5a7e..25fdd77991b 100644
--- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php
+++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php
@@ -45,7 +45,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Muguet';
diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php
index 565e8cbd41d..72ba5f28186 100644
--- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php
+++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php
@@ -46,7 +46,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Orchidee';
diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
index e8b97224aad..0ad8b391faf 100644
--- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
@@ -130,49 +130,47 @@ class pdf_standard extends ModelePDFSuppliersPayments
// Page size for A4 format
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
+ $formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+ $this->format = array($this->page_largeur, $this->page_hauteur);
+ $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
+ $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
+ $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
+ $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
- $this->option_logo = 1; // Affiche logo
- $this->option_multilang = 1; // Dispo en plusieurs langues
-
- $this->franchise=!$mysoc->tva_assuj;
+ $this->option_logo = 1; // Affiche logo
+ $this->option_multilang = 1; // Dispo en plusieurs langues
// Define column position
- $this->posxdate=$this->marge_gauche+1;
- $this->posxreffacturefourn=30;
- $this->posxreffacture=65;
- $this->posxtype=100;
- $this->posxtotalht=80;
- $this->posxtva=90;
- $this->posxtotalttc=180;
+ $this->posxdate = $this->marge_gauche + 1;
+ $this->posxreffacturefourn = 30;
+ $this->posxreffacture = 65;
+ $this->posxtype = 100;
+ $this->posxtotalht = 80;
+ $this->posxtva = 90;
+ $this->posxtotalttc = 180;
//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
if ($this->page_largeur < 210) // To work with US executive format
{
- $this->posxreffacturefourn-=20;
- $this->posxreffacture-=20;
- $this->posxtype-=20;
- $this->posxtotalht-=20;
- $this->posxtva-=20;
- $this->posxtotalttc-=20;
+ $this->posxreffacturefourn -= 20;
+ $this->posxreffacture -= 20;
+ $this->posxtype -= 20;
+ $this->posxtotalht -= 20;
+ $this->posxtva -= 20;
+ $this->posxtotalttc -= 20;
}
- $this->tva=array();
- $this->localtax1=array();
- $this->localtax2=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
+ $this->tva = array();
+ $this->localtax1 = array();
+ $this->localtax2 = array();
+ $this->atleastoneratenotnull = 0;
+ $this->atleastonediscount = 0;
// Recupere emetteur
- $this->emetteur=$mysoc;
- if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined
+ $this->emetteur = $mysoc;
+ if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
}
@@ -193,9 +191,9 @@ class pdf_standard extends ModelePDFSuppliersPayments
// phpcs:enable
global $user, $langs, $conf, $mysoc, $hookmanager;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ if (!is_object($outputlangs)) $outputlangs = $langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
// Load translation files required by the page
$outputlangs->loadLangs(array("main", "suppliers", "companies", "bills", "dict", "products"));
@@ -213,12 +211,12 @@ class pdf_standard extends ModelePDFSuppliersPayments
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
$sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
$sql .= ' AND pf.fk_paiementfourn = '.$object->id;
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql) > 0)
{
- while($objp = $this->db->fetch_object($resql)) {
+ while ($objp = $this->db->fetch_object($resql)) {
$objp->type = $outputlangs->trans('SupplierInvoice');
$object->lines[] = $objp;
}
@@ -231,22 +229,22 @@ class pdf_standard extends ModelePDFSuppliersPayments
if ($object->specimen)
{
$dir = $conf->fournisseur->payment->dir_output;
- $file = $dir . "/SPECIMEN.pdf";
+ $file = $dir."/SPECIMEN.pdf";
}
else
{
$objectref = dol_sanitizeFileName($object->ref);
$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
$dir = $conf->fournisseur->payment->dir_output.'/'.$objectref;
- $file = $dir . "/" . $objectref . ".pdf";
- if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
+ $file = $dir."/".$objectref.".pdf";
+ if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf";
}
- if (! file_exists($dir))
+ if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
@@ -254,24 +252,24 @@ class pdf_standard extends ModelePDFSuppliersPayments
if (file_exists($dir))
{
// Add pdfgeneration hook
- if (! is_object($hookmanager))
+ if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager=new HookManager($this->db);
+ $hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
$nblines = count($object->lines);
- $pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $heightforinfotot = 50; // Height reserved to output the info and total part
- $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $heightforinfotot = 50; // Height reserved to output the info and total part
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF'))
@@ -281,14 +279,14 @@ class pdf_standard extends ModelePDFSuppliersPayments
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
- if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
$pdf->Open();
- $pagenb=0;
+ $pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
@@ -296,76 +294,80 @@ class pdf_standard extends ModelePDFSuppliersPayments
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
- if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);
$tab_top = 90;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
$tab_height = 130;
$tab_height_newpage = 150;
// Incoterm
$height_incoterms = 0;
- $height_note=0;
+ $height_note = 0;
$iniY = $tab_top + 7;
$curY = $tab_top + 7;
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
$pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore=$pdf->getPage();
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
// Description of product line
- $curX = $this->posxdate-1;
- $showpricebeforepagebreak=1;
+ $curX = $this->posxdate - 1;
+ $showpricebeforepagebreak = 1;
$pdf->startTransaction();
//pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1);
- $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J', true);
- $pageposafter=$pdf->getPage();
+ $pdf->writeHTMLCell($this->posxtva - $curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J', true);
+ $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
//pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1);
- $pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J', true);
- $posyafter=$pdf->GetY();
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
+ $pdf->writeHTMLCell($this->posxtva - $curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J', true);
+ $posyafter = $pdf->GetY();
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposafter+1);
+ $pdf->setPage($pageposafter + 1);
}
}
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
@@ -374,54 +376,54 @@ class pdf_standard extends ModelePDFSuppliersPayments
}
$nexY = $pdf->GetY();
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
// ref fourn
$pdf->SetXY($this->posxreffacturefourn, $curY);
- $pdf->MultiCell($this->posxreffacturefourn-$this->posxup-0.8, 3, $object->lines[$i]->ref_supplier, 0, 'L', 0);
+ $pdf->MultiCell($this->posxreffacturefourn - $this->posxup - 0.8, 3, $object->lines[$i]->ref_supplier, 0, 'L', 0);
// ref facture fourn
$pdf->SetXY($this->posxreffacture, $curY);
- $pdf->MultiCell($this->posxreffacture-$this->posxup-0.8, 3, $object->lines[$i]->ref, 0, 'L', 0);
+ $pdf->MultiCell($this->posxreffacture - $this->posxup - 0.8, 3, $object->lines[$i]->ref, 0, 'L', 0);
// type
$pdf->SetXY($this->posxtype, $curY);
- $pdf->MultiCell($this->posxtype-$this->posxup-0.8, 3, $object->lines[$i]->type, 0, 'L', 0);
+ $pdf->MultiCell($this->posxtype - $this->posxup - 0.8, 3, $object->lines[$i]->type, 0, 'L', 0);
// Total ht
$pdf->SetXY($this->posxtotalht, $curY);
- $pdf->MultiCell($this->posxtotalht-$this->posxup-0.8, 3, price($object->lines[$i]->total_ht), 0, 'R', 0);
+ $pdf->MultiCell($this->posxtotalht - $this->posxup - 0.8, 3, price($object->lines[$i]->total_ht), 0, 'R', 0);
// Total tva
$pdf->SetXY($this->posxtva, $curY);
- $pdf->MultiCell($this->posxtva-$this->posxup-0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0);
+ $pdf->MultiCell($this->posxtva - $this->posxup - 0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0);
// Total TTC line
$pdf->SetXY($this->posxtotalttc, $curY);
- $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0);
+ $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0);
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
+ $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Add space between lines
+ $nexY += 2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -438,10 +440,10 @@ class pdf_standard extends ModelePDFSuppliersPayments
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pagenb++;
$pdf->setPage($pagenb);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
- if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
{
if ($pagenb == 1)
{
@@ -454,7 +456,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
$this->_pagefoot($pdf, $object, $outputlangs, 1);
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
@@ -464,16 +466,16 @@ class pdf_standard extends ModelePDFSuppliersPayments
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
// Affiche zone cheèque
- $posy=$this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs);
+ $posy = $this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux
//$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
@@ -488,31 +490,31 @@ class pdf_standard extends ModelePDFSuppliersPayments
// Add pdfgeneration hook
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
- if (! empty($conf->global->MAIN_UMASK))
+ if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
- return 1; // No error
+ return 1; // No error
}
else
{
- $this->error=$langs->trans("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return 0;
}
}
else
{
- $this->error=$langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
+ $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
return 0;
}
}
@@ -531,7 +533,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
protected function _tableau_cheque(&$pdf, $object, $posy, $outputlangs)
{
// phpcs:enable
- global $conf,$mysoc;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -563,7 +565,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
$pdf->MultiCell(150, 4, $object->thirdparty->nom, 0, 'L', 1);
$pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy);
- $pdf->MultiCell(35, 4, str_pad(price($object->montant). ' '.$currency, 18, '*', STR_PAD_LEFT), 0, 'R', 1);
+ $pdf->MultiCell(35, 4, str_pad(price($object->montant).' '.$currency, 18, '*', STR_PAD_LEFT), 0, 'R', 1);
$posy += 10;
@@ -593,11 +595,11 @@ class pdf_standard extends ModelePDFSuppliersPayments
*/
protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
{
- global $conf,$mysoc;
+ global $conf, $mysoc;
// Force to disable hidetop and hidebottom
- $hidebottom=0;
- if ($hidetop) $hidetop=-1;
+ $hidebottom = 0;
+ if ($hidetop) $hidetop = -1;
$currency = !empty($currency) ? $currency : $conf->currency;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -607,7 +609,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
$pdf->SetFont('', '', $default_font_size - 2);
$titre = strtoupper($mysoc->town).', le '.date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y");
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top-6);
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top - 6);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
@@ -647,19 +649,19 @@ class pdf_standard extends ModelePDFSuppliersPayments
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-100;
+ $posy = $this->marge_haute;
+ $posx = $this->page_largeur - $this->marge_droite - 100;
$pdf->SetXY($this->marge_gauche, $posy);
// Logo
- $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
+ $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
if ($mysoc->logo)
{
if (is_readable($logo))
{
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
}
else
{
@@ -671,7 +673,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
}
else
{
- $text=$this->emetteur->name;
+ $text = $this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
/*
@@ -741,15 +743,15 @@ class pdf_standard extends ModelePDFSuppliersPayments
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
// Show payer
- $posy=42;
- $posx=$this->marge_gauche;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
- $hautcadre=40;
+ $posy = 42;
+ $posx = $this->marge_gauche;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
+ $hautcadre = 40;
// Show sender frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx, $posy-5);
+ $pdf->SetXY($posx, $posy - 5);
$pdf->MultiCell(66, 5, $outputlangs->transnoentities("PayedBy").":", 0, 'L');
$pdf->SetXY($posx, $posy);
$pdf->SetFillColor(230, 230, 230);
@@ -757,39 +759,39 @@ class pdf_standard extends ModelePDFSuppliersPayments
$pdf->SetTextColor(0, 0, 60);
// Show sender name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
- $posy=$pdf->getY();
+ $posy = $pdf->getY();
// Show sender information
- $pdf->SetXY($posx+2, $posy);
+ $pdf->SetXY($posx + 2, $posy);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
// Payed
$thirdparty = $object->thirdparty;
- $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
+ $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
- $carac_client=pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact))?$object->contact:null), $usecontact, 'target', $object);
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'target', $object);
// Show recipient
- $widthrecbox=90;
- if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
- $posy=42;
- $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ $widthrecbox = 90;
+ if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
+ $posy = 42;
+ $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
// Show recipient frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx+2, $posy-5);
+ $pdf->SetXY($posx + 2, $posy - 5);
$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("PayedTo").":", 0, 'L');
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show recipient name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
@@ -797,7 +799,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
// Show recipient information
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->SetXY($posx+2, $posy);
+ $pdf->SetXY($posx + 2, $posy);
$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
}
}
@@ -815,7 +817,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
global $conf;
- $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
}
diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php
index 92a2862143f..60d25792988 100644
--- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php
+++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php
@@ -44,7 +44,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Brodator';
diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php
index 1bc34d41bce..8a16475b383 100644
--- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php
+++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php
@@ -45,7 +45,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Bronan';
diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php
index 9c7305d1c07..77503c4b61b 100644
--- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php
+++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php
@@ -225,7 +225,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
/**
* Function to build a document on disk using the generic odt module.
*
- * @param Propale $object Object source to build document
+ * @param Propal $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
index ff8ab76c674..afaf4987e04 100644
--- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
+++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
@@ -130,68 +130,66 @@ class pdf_aurore extends ModelePDFSupplierProposal
// Page size for A4 format
$this->type = 'pdf';
- $formatarray=pdf_getFormat();
+ $formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height'];
- $this->format = array($this->page_largeur,$this->page_hauteur);
- $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
- $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
- $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
- $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
+ $this->format = array($this->page_largeur, $this->page_hauteur);
+ $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
+ $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
+ $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
+ $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
- $this->option_logo = 1; // Affiche logo
- $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
- $this->option_modereg = 1; // Affiche mode reglement
- $this->option_condreg = 1; // Affiche conditions reglement
- $this->option_codeproduitservice = 1; // Affiche code produit-service
- $this->option_multilang = 1; // Dispo en plusieurs langues
- $this->option_escompte = 1; // Affiche si il y a eu escompte
- $this->option_credit_note = 1; // Support credit notes
- $this->option_freetext = 1; // Support add of a personalised text
- $this->option_draft_watermark = 1; //Support add of a watermark on drafts
-
- $this->franchise=!$mysoc->tva_assuj;
+ $this->option_logo = 1; // Affiche logo
+ $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
+ $this->option_modereg = 1; // Affiche mode reglement
+ $this->option_condreg = 1; // Affiche conditions reglement
+ $this->option_codeproduitservice = 1; // Affiche code produit-service
+ $this->option_multilang = 1; // Dispo en plusieurs langues
+ $this->option_escompte = 1; // Affiche si il y a eu escompte
+ $this->option_credit_note = 1; // Support credit notes
+ $this->option_freetext = 1; // Support add of a personalised text
+ $this->option_draft_watermark = 1; //Support add of a watermark on drafts
// Get source company
- $this->emetteur=$mysoc;
- if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if was not defined
+ $this->emetteur = $mysoc;
+ if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
// Define position of columns
- $this->posxdesc=$this->marge_gauche+1;
- $this->posxdiscount=162;
- $this->postotalht=174;
+ $this->posxdesc = $this->marge_gauche + 1;
+ $this->posxdiscount = 162;
+ $this->postotalht = 174;
if ($conf->global->PRODUCT_USE_UNITS)
{
- $this->posxtva=101;
- $this->posxup=118;
- $this->posxqty=135;
- $this->posxunit=151;
+ $this->posxtva = 101;
+ $this->posxup = 118;
+ $this->posxqty = 135;
+ $this->posxunit = 151;
} else {
- $this->posxtva=102;
- $this->posxup=126;
- $this->posxqty=145;
- $this->posxunit=162;
+ $this->posxtva = 102;
+ $this->posxup = 126;
+ $this->posxqty = 145;
+ $this->posxunit = 162;
}
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
- $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup = $this->posxtva;
+ $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{
- $this->posxpicture-=20;
- $this->posxtva-=20;
- $this->posxup-=20;
- $this->posxqty-=20;
- $this->posxunit-=20;
- $this->posxdiscount-=20;
- $this->postotalht-=20;
+ $this->posxpicture -= 20;
+ $this->posxtva -= 20;
+ $this->posxup -= 20;
+ $this->posxqty -= 20;
+ $this->posxunit -= 20;
+ $this->posxdiscount -= 20;
+ $this->postotalht -= 20;
}
- $this->tva=array();
- $this->localtax1=array();
- $this->localtax2=array();
- $this->atleastoneratenotnull=0;
- $this->atleastonediscount=0;
+ $this->tva = array();
+ $this->localtax1 = array();
+ $this->localtax2 = array();
+ $this->atleastoneratenotnull = 0;
+ $this->atleastonediscount = 0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -209,11 +207,11 @@ class pdf_aurore extends ModelePDFSupplierProposal
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
- global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblines;
+ global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
- if (! is_object($outputlangs)) $outputlangs=$langs;
+ if (!is_object($outputlangs)) $outputlangs = $langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
// Load traductions files required by page
$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal"));
@@ -221,40 +219,40 @@ class pdf_aurore extends ModelePDFSupplierProposal
$nblines = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
- $realpatharray=array();
- if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
+ $realpatharray = array();
+ if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
{
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
- $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/";
+ $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
}
else
{
- $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/';
+ $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
$dir = $conf->product->dir_output.'/'.$pdir;
}
- $realpath='';
+ $realpath = '';
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
{
- $filename=$obj['photo'];
+ $filename = $obj['photo'];
//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
$realpath = $dir.$filename;
break;
}
- if ($realpath) $realpatharray[$i]=$realpath;
+ if ($realpath) $realpatharray[$i] = $realpath;
}
}
- if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
+ if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
if ($conf->supplier_proposal->dir_output)
{
@@ -266,20 +264,20 @@ class pdf_aurore extends ModelePDFSupplierProposal
if ($object->specimen)
{
$dir = $conf->supplier_proposal->dir_output;
- $file = $dir . "/SPECIMEN.pdf";
+ $file = $dir."/SPECIMEN.pdf";
}
else
{
$objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->supplier_proposal->dir_output . "/" . $objectref;
- $file = $dir . "/" . $objectref . ".pdf";
+ $dir = $conf->supplier_proposal->dir_output."/".$objectref;
+ $file = $dir."/".$objectref.".pdf";
}
- if (! file_exists($dir))
+ if (!file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
- $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
@@ -287,23 +285,23 @@ class pdf_aurore extends ModelePDFSupplierProposal
if (file_exists($dir))
{
// Add pdfgeneration hook
- if (! is_object($hookmanager))
+ if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager=new HookManager($this->db);
+ $hookmanager = new HookManager($this->db);
}
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Create pdf instance
- $pdf=pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $heightforinfotot = 50; // Height reserved to output the info and total part
- $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $heightforinfotot = 50; // Height reserved to output the info and total part
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF'))
@@ -313,14 +311,14 @@ class pdf_aurore extends ModelePDFSupplierProposal
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
- if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
$pdf->Open();
- $pagenb=0;
+ $pagenb = 0;
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
@@ -328,12 +326,12 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
- if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Positionne $this->atleastonediscount si on a au moins une remise
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
if ($object->lines[$i]->remise_percent)
{
@@ -343,59 +341,59 @@ class pdf_aurore extends ModelePDFSupplierProposal
if (empty($this->atleastonediscount))
{
$delta = ($this->postotalht - $this->posxdiscount);
- $this->posxpicture+=$delta;
- $this->posxtva+=$delta;
- $this->posxup+=$delta;
- $this->posxqty+=$delta;
- $this->posxunit+=$delta;
- $this->posxdiscount+=$delta;
+ $this->posxpicture += $delta;
+ $this->posxtva += $delta;
+ $this->posxup += $delta;
+ $this->posxqty += $delta;
+ $this->posxunit += $delta;
+ $this->posxdiscount += $delta;
// post of fields after are not modified, stay at same position
}
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0, 0, 0);
- $tab_top = 90+$top_shift;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
+ $tab_top = 90 + $top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
// Affiche notes
- $notetoshow=empty($object->note_public)?'':$object->note_public;
- if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
{
// Get first sale rep
if (is_object($object->thirdparty))
{
- $salereparray=$object->thirdparty->getSalesRepresentatives($user);
- $salerepobj=new User($this->db);
+ $salereparray = $object->thirdparty->getSalesRepresentatives($user);
+ $salerepobj = new User($this->db);
$salerepobj->fetch($salereparray[0]['id']);
- if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
+ if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
}
}
if ($notetoshow)
{
$tab_top -= 2;
- $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
+ $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
$nexY = $pdf->GetY();
- $height_note=$nexY-$tab_top;
+ $height_note = $nexY - $tab_top;
// Rect takes a length in 3rd parameter
$pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
- $tab_top = $nexY+6;
+ $tab_top = $nexY + 6;
}
$iniY = $tab_top + 7;
@@ -403,105 +401,114 @@ class pdf_aurore extends ModelePDFSupplierProposal
$nexY = $tab_top + 7;
// Loop on each lines
- for ($i = 0 ; $i < $nblines ; $i++)
+ for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
- $imglinesize=array();
- if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
+ $imglinesize = array();
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
$pdf->setTopMargin($tab_top_newpage);
- $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
- $pageposbefore=$pdf->getPage();
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
- $showpricebeforepagebreak=1;
- $posYAfterImage=0;
- $posYAfterDescription=0;
+ $showpricebeforepagebreak = 1;
+ $posYAfterImage = 0;
+ $posYAfterDescription = 0;
// We start with Photo of product line
- if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page
+ if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposbefore+1);
+ $pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
- $showpricebeforepagebreak=0;
+
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
{
- $curX = $this->posxpicture-1;
- $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ $curX = $this->posxpicture - 1;
+ $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
- $posYAfterImage=$curY+$imglinesize['height'];
+ $posYAfterImage = $curY + $imglinesize['height'];
}
// Description of product line
- $curX = $this->posxdesc-1;
+ $curX = $this->posxdesc - 1;
$pdf->startTransaction();
if ($posYAfterImage > 0)
{
- $descWidth = $this->posxpicture-$curX;
+ $descWidth = $this->posxpicture - $curX;
}
else
{
- $descWidth = $this->posxtva-$curX;
+ $descWidth = $this->posxtva - $curX;
}
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
- $pageposafter=$pageposbefore;
+ $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc);
- $pageposafter=$pdf->getPage();
- $posyafter=$pdf->GetY();
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
- if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
{
- if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true);
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
- $pdf->setPage($pageposafter+1);
+ $pdf->setPage($pageposafter + 1);
}
}
else
{
// We found a page break
- $showpricebeforepagebreak=0;
+ // Allows data in the first page if description is long enough to break in multiples pages
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
+ $showpricebeforepagebreak = 1;
+ else
+ $showpricebeforepagebreak = 0;
}
}
else // No pagebreak
{
$pdf->commitTransaction();
}
- $posYAfterDescription=$pdf->GetY();
+ $posYAfterDescription = $pdf->GetY();
$nexY = $pdf->GetY();
- $pageposafter=$pdf->getPage();
+ $pageposafter = $pdf->getPage();
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
// We suppose that a too long description or photo were moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
- $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
// VAT Rate
/*
@@ -522,14 +529,14 @@ class pdf_aurore extends ModelePDFSupplierProposal
// Quantity
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxqty, $curY);
- $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
+ $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R'); // Enough for 6 chars
// Unit
- if($conf->global->PRODUCT_USE_UNITS)
+ if ($conf->global->PRODUCT_USE_UNITS)
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxunit, $curY);
- $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
+ $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
}
// Discount on line
@@ -549,54 +556,54 @@ class pdf_aurore extends ModelePDFSupplierProposal
*/
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
- if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
- else $tvaligne=$object->lines[$i]->total_tva;
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $object->lines[$i]->total_tva;
- $localtax1ligne=$object->lines[$i]->total_localtax1;
- $localtax2ligne=$object->lines[$i]->total_localtax2;
- $localtax1_rate=$object->lines[$i]->localtax1_tx;
- $localtax2_rate=$object->lines[$i]->localtax2_tx;
- $localtax1_type=$object->lines[$i]->localtax1_type;
- $localtax2_type=$object->lines[$i]->localtax2_type;
+ $localtax1ligne = $object->lines[$i]->total_localtax1;
+ $localtax2ligne = $object->lines[$i]->total_localtax2;
+ $localtax1_rate = $object->lines[$i]->localtax1_tx;
+ $localtax2_rate = $object->lines[$i]->localtax2_tx;
+ $localtax1_type = $object->lines[$i]->localtax1_type;
+ $localtax2_type = $object->lines[$i]->localtax2_type;
- if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
- if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
+ if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
- $vatrate=(string) $object->lines[$i]->tva_tx;
+ $vatrate = (string) $object->lines[$i]->tva_tx;
// Retrieve type from database for backward compatibility with old records
- if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
- && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
+ if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
{
- $localtaxtmp_array=getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
+ $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
$localtax1_type = $localtaxtmp_array[0];
$localtax2_type = $localtaxtmp_array[2];
}
// retrieve global local tax
if ($localtax1_type && $localtax1ligne != 0)
- $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
+ $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
if ($localtax2_type && $localtax2ligne != 0)
- $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
+ $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
- if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
- if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0;
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
+ if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
$this->tva[$vatrate] += $tvaligne;
- if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
+ if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
// Add line
- if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
{
$pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
+ $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
$pdf->SetLineStyle(array('dash'=>0));
}
- $nexY+=2; // Add space between lines
+ $nexY += 2; // Add space between lines
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
@@ -613,10 +620,10 @@ class pdf_aurore extends ModelePDFSupplierProposal
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pagenb++;
$pdf->setPage($pagenb);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
- if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
{
if ($pagenb == 1)
{
@@ -629,7 +636,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$this->_pagefoot($pdf, $object, $outputlangs, 1);
// New page
$pdf->AddPage();
- if (! empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
@@ -639,16 +646,16 @@ class pdf_aurore extends ModelePDFSupplierProposal
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
- $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
// Affiche zone infos
- $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
+ $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux
//$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
@@ -671,31 +678,31 @@ class pdf_aurore extends ModelePDFSupplierProposal
//Add pdfgeneration hook
$hookmanager->initHooks(array('pdfgeneration'));
- $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
- $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
- if (! empty($conf->global->MAIN_UMASK))
+ if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
- return 1; // No error
+ return 1; // No error
}
else
{
- $this->error=$langs->trans("ErrorCanNotCreateDir", $dir);
+ $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
return 0;
}
}
else
{
- $this->error=$langs->trans("ErrorConstantNotDefined", "SUPPLIER_PROPOSAL_OUTPUTDIR");
+ $this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_PROPOSAL_OUTPUTDIR");
return 0;
}
}
@@ -735,10 +742,10 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetFont('', '', $default_font_size - 1);
- $posxval=52;
+ $posxval = 52;
// Show shipping date
- if (! empty($object->date_livraison))
+ if (!empty($object->date_livraison))
{
$outputlangs->load("sendings");
$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -747,10 +754,10 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->MultiCell(80, 4, $titre, 0, 'L');
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $dlp=dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
+ $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
$pdf->MultiCell(80, 4, $dlp, 0, 'L');
- $posy=$pdf->GetY()+1;
+ $posy = $pdf->GetY() + 1;
}
else {
$outputlangs->load("sendings");
@@ -763,7 +770,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
//$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
$pdf->MultiCell(80, 4, $dlp, 0, 'L');
- $posy=$pdf->GetY()+1;
+ $posy = $pdf->GetY() + 1;
}
/* PHFAVRE
elseif ($object->availability_code || $object->availability) // Show availability conditions
@@ -792,14 +799,14 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
- $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
- $lib_condition_paiement=str_replace('\n', "\n", $lib_condition_paiement);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
+ $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
- $posy=$pdf->GetY()+3;
+ $posy = $pdf->GetY() + 3;
}
- if (! empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE))
+ if (!empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE))
{
// Show payment mode
if ($object->mode_reglement_code
@@ -807,24 +814,24 @@ class pdf_aurore extends ModelePDFSupplierProposal
&& $object->mode_reglement_code != 'VIR')
{
$pdf->SetFont('', 'B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy-2);
+ $pdf->SetXY($this->marge_gauche, $posy - 2);
$titre = $outputlangs->transnoentities("PaymentMode").':';
$pdf->MultiCell(80, 5, $titre, 0, 'L');
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy-2);
- $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
+ $pdf->SetXY($posxval, $posy - 2);
+ $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
- $posy=$pdf->GetY()+2;
+ $posy = $pdf->GetY() + 2;
}
// Show payment mode CHQ
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
{
// Si mode reglement non force ou si force a CHQ
- if (! empty($conf->global->FACTURE_CHQ_NUMBER))
+ if (!empty($conf->global->FACTURE_CHQ_NUMBER))
{
- $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
+ $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
if ($conf->global->FACTURE_CHQ_NUMBER > 0)
{
@@ -834,14 +841,14 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
- $posy=$pdf->GetY()+1;
+ $posy = $pdf->GetY() + 1;
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
{
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
+ $posy = $pdf->GetY() + 2;
}
}
if ($conf->global->FACTURE_CHQ_NUMBER == -1)
@@ -849,14 +856,14 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
- $posy=$pdf->GetY()+1;
+ $posy = $pdf->GetY() + 1;
if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
{
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
- $posy=$pdf->GetY()+2;
+ $posy = $pdf->GetY() + 2;
}
}
}
@@ -865,18 +872,18 @@ class pdf_aurore extends ModelePDFSupplierProposal
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
{
- if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
+ if (!empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
{
- $bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
+ $bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank);
$account = new Account($this->db);
$account->fetch($bankid);
- $curx=$this->marge_gauche;
- $cury=$posy;
+ $curx = $this->marge_gauche;
+ $cury = $posy;
- $posy=pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
+ $posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
- $posy+=2;
+ $posy += 2;
}
}
}
@@ -899,7 +906,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
// phpcs:enable
- global $conf,$mysoc;
+ global $conf, $mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
$tab2_top = $posy;
@@ -910,29 +917,29 @@ class pdf_aurore extends ModelePDFSupplierProposal
$col1x = 120; $col2x = 170;
if ($this->page_largeur < 210) // To work with US executive format
{
- $col2x-=20;
+ $col2x -= 20;
}
$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
- $useborder=0;
+ $useborder = 0;
$index = 0;
// Total HT
$pdf->SetFillColor(255, 255, 255);
$pdf->SetXY($col1x, $tab2_top + 0);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + 0);
- $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
// Show VAT by rates and total
$pdf->SetFillColor(248, 248, 248);
- $this->atleastoneratenotnull=0;
+ $this->atleastoneratenotnull = 0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
- $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
- if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
+ $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
{
// Nothing to do
}
@@ -941,28 +948,28 @@ class pdf_aurore extends ModelePDFSupplierProposal
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -973,13 +980,13 @@ class pdf_aurore extends ModelePDFSupplierProposal
//Local tax 2 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('1','3','5'))) continue;
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
- if ($tvakey!=0) // On affiche pas taux 0
+ if ($tvakey != 0) // On affiche pas taux 0
{
//$this->atleastoneratenotnull++;
@@ -988,15 +995,15 @@ class pdf_aurore extends ModelePDFSupplierProposal
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1005,7 +1012,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
}
//}
// VAT
- foreach($this->tva as $tvakey => $tvaval)
+ foreach ($this->tva as $tvakey => $tvaval)
{
if ($tvakey > 0) // On affiche pas taux 0
{
@@ -1014,15 +1021,15 @@ class pdf_aurore extends ModelePDFSupplierProposal
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
- $totalvat =$outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
- $totalvat.=vatrate($tvakey, 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
+ $totalvat .= vatrate($tvakey, 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1032,11 +1039,11 @@ class pdf_aurore extends ModelePDFSupplierProposal
//Local tax 1 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
- foreach($this->localtax1 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
{
@@ -1045,16 +1052,16 @@ class pdf_aurore extends ModelePDFSupplierProposal
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
}
@@ -1064,11 +1071,11 @@ class pdf_aurore extends ModelePDFSupplierProposal
//Local tax 2 after VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
//{
- foreach($this->localtax2 as $localtax_type => $localtax_rate)
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
{
- if (in_array((string) $localtax_type, array('2','4','6'))) continue;
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
- foreach($localtax_rate as $tvakey => $tvaval)
+ foreach ($localtax_rate as $tvakey => $tvaval)
{
// retrieve global local tax
if ($tvakey != 0) // On affiche pas taux 0
@@ -1078,16 +1085,16 @@ class pdf_aurore extends ModelePDFSupplierProposal
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $tvacompl='';
+ $tvacompl = '';
if (preg_match('/\*/', $tvakey))
{
- $tvakey=str_replace('*', '', $tvakey);
+ $tvakey = str_replace('*', '', $tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
}
$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
- $totalvat.=vatrate(abs($tvakey), 1).$tvacompl;
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
+ $totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1101,7 +1108,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
@@ -1120,7 +1127,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
@@ -1145,7 +1152,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFillColor(224, 224, 224);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
@@ -1177,8 +1184,8 @@ class pdf_aurore extends ModelePDFSupplierProposal
global $conf;
// Force to disable hidetop and hidebottom
- $hidebottom=0;
- if ($hidetop) $hidetop=-1;
+ $hidebottom = 0;
+ if ($hidetop) $hidetop = -1;
$currency = !empty($currency) ? $currency : $conf->currency;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1190,24 +1197,24 @@ class pdf_aurore extends ModelePDFSupplierProposal
if (empty($hidetop))
{
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
- $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
+ $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
- if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
}
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', '', $default_font_size - 1);
// Output Rect
- $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
+ $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
if (empty($hidetop))
{
- $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter
+ $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter
- $pdf->SetXY($this->posxdesc-1, $tab_top+1);
+ $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
}
@@ -1217,26 +1224,26 @@ class pdf_aurore extends ModelePDFSupplierProposal
//$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height);
if (empty($hidetop))
{
- $pdf->SetXY($this->posxtva-5, $tab_top+1);
- $pdf->MultiCell($this->posxup-$this->posxtva+3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
+ $pdf->SetXY($this->posxtva - 5, $tab_top + 1);
+ $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
}
}
- $pdf->line($this->posxup-3, $tab_top, $this->posxup-3, $tab_top + $tab_height);
+ $pdf->line($this->posxup - 3, $tab_top, $this->posxup - 3, $tab_top + $tab_height);
if (empty($hidetop))
{
- $pdf->SetXY($this->posxup-1, $tab_top+1);
- $pdf->MultiCell($this->posxqty-$this->posxup-1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
+ $pdf->SetXY($this->posxup - 1, $tab_top + 1);
+ $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
}
- $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
+ $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
if (empty($hidetop))
{
- $pdf->SetXY($this->posxqty-1, $tab_top+1);
- $pdf->MultiCell($this->posxunit-$this->posxqty-1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
+ $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
+ $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
- if($conf->global->PRODUCT_USE_UNITS) {
+ if ($conf->global->PRODUCT_USE_UNITS) {
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -1244,13 +1251,13 @@ class pdf_aurore extends ModelePDFSupplierProposal
}
}
- $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
+ $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
if (empty($hidetop))
{
if ($this->atleastonediscount)
{
- $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
- $pdf->MultiCell($this->postotalht-$this->posxdiscount+1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
+ $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
+ $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
}
}
if ($this->atleastonediscount)
@@ -1259,7 +1266,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
}
if (empty($hidetop))
{
- $pdf->SetXY($this->postotalht-1, $tab_top+1);
+ $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
}
}
@@ -1286,7 +1293,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if($object->statut==0 && (! empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)) )
+ if ($object->statut == 0 && (!empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)))
{
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
}
@@ -1294,19 +1301,19 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetTextColor(0, 0, 60);
$pdf->SetFont('', 'B', $default_font_size + 3);
- $posy=$this->marge_haute;
- $posx=$this->page_largeur-$this->marge_droite-100;
+ $posy = $this->marge_haute;
+ $posx = $this->page_largeur - $this->marge_droite - 100;
$pdf->SetXY($this->marge_gauche, $posy);
// Logo
- $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
+ $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo)
{
if (is_readable($logo))
{
- $height=pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
}
else
{
@@ -1318,32 +1325,32 @@ class pdf_aurore extends ModelePDFSupplierProposal
}
else
{
- $text=$this->emetteur->name;
+ $text = $this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
$pdf->SetFont('', 'B', $default_font_size + 3);
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $title=$outputlangs->transnoentities("CommercialAsk");
+ $title = $outputlangs->transnoentities("CommercialAsk");
$pdf->MultiCell(100, 4, $title, '', 'R');
$pdf->SetFont('', 'B', $default_font_size);
- $posy+=5;
+ $posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
+ $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
- $posy+=1;
+ $posy += 1;
$pdf->SetFont('', '', $default_font_size - 2);
if ($object->ref_client)
{
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
/* PHFAVRE
$posy+=4;
@@ -1354,28 +1361,28 @@ class pdf_aurore extends ModelePDFSupplierProposal
if ($object->thirdparty->code_fournisseur)
{
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
}
// Get contact
if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
{
- $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL');
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
if (count($arrayidcontact) > 0)
{
- $usertmp=new User($this->db);
+ $usertmp = new User($this->db);
$usertmp->fetch($arrayidcontact[0]);
- $posy+=4;
+ $posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
}
}
- $posy+=2;
+ $posy += 2;
$top_shift = 0;
// Show list of linked objects
@@ -1389,28 +1396,28 @@ class pdf_aurore extends ModelePDFSupplierProposal
if ($showaddress)
{
// Sender properties
- $carac_emetteur='';
+ $carac_emetteur = '';
// Add internal contact of proposal if defined
- $arrayidcontact=$object->getIdContact('internal', 'SALESREPFOLL');
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
if (count($arrayidcontact) > 0)
{
$object->fetch_user($arrayidcontact[0]);
- $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
- $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+ $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
+ $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
}
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
- $posy=42+$top_shift;
- $posx=$this->marge_gauche;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
- $hautcadre=40;
+ $posy = 42 + $top_shift;
+ $posx = $this->marge_gauche;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
+ $hautcadre = 40;
// Show sender frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx, $posy-5);
+ $pdf->SetXY($posx, $posy - 5);
$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
$pdf->SetXY($posx, $posy);
$pdf->SetFillColor(230, 230, 230);
@@ -1418,63 +1425,63 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetTextColor(0, 0, 60);
// Show sender name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
- $posy=$pdf->getY();
+ $posy = $pdf->getY();
// Show sender information
- $pdf->SetXY($posx+2, $posy);
+ $pdf->SetXY($posx + 2, $posy);
$pdf->SetFont('', '', $default_font_size - 1);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
// If CUSTOMER contact defined, we use it
- $usecontact=false;
- $arrayidcontact=$object->getIdContact('external', 'CUSTOMER');
+ $usecontact = false;
+ $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
if (count($arrayidcontact) > 0)
{
- $usecontact=true;
- $result=$object->fetch_contact($arrayidcontact[0]);
+ $usecontact = true;
+ $result = $object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
- if (! empty($usecontact))
+ if (!empty($usecontact))
{
// On peut utiliser le nom de la societe du contact
- if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
+ if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
else $socname = $object->thirdparty->name;
- $carac_client_name=$outputlangs->convToOutputCharset($socname);
+ $carac_client_name = $outputlangs->convToOutputCharset($socname);
}
else
{
- $carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
+ $carac_client_name = $outputlangs->convToOutputCharset($object->thirdparty->name);
}
- $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact?$object->contact:''), $usecontact, 'target', $object);
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
// Show recipient
- $widthrecbox=100;
- if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
- $posy=42+$top_shift;
- $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
- if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
+ $widthrecbox = 100;
+ if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
+ $posy = 42 + $top_shift;
+ $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
// Show recipient frame
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx+2, $posy-5);
+ $pdf->SetXY($posx + 2, $posy - 5);
$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show recipient name
- $pdf->SetXY($posx+2, $posy+3);
+ $pdf->SetXY($posx + 2, $posy + 3);
$pdf->SetFont('', 'B', $default_font_size);
$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
// Show recipient information
$pdf->SetFont('', '', $default_font_size - 1);
- $pdf->SetXY($posx+2, $posy+4+(dol_nboflines_bis($carac_client_name, 50)*4));
+ $pdf->SetXY($posx + 2, $posy + 4 + (dol_nboflines_bis($carac_client_name, 50) * 4));
$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
}
@@ -1495,7 +1502,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
global $conf;
- $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
}
}
diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php
index 8fa71cc1a3b..7bd15599e24 100644
--- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php
+++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php
@@ -47,7 +47,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Marbre';
diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php
index bfaaa6b15fb..7cf4d295239 100644
--- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php
+++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php
@@ -47,7 +47,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Saphir';
diff --git a/htdocs/core/modules/ticket/mod_ticket_simple.php b/htdocs/core/modules/ticket/mod_ticket_simple.php
index dbec61b67bf..3245f7b8e84 100644
--- a/htdocs/core/modules/ticket/mod_ticket_simple.php
+++ b/htdocs/core/modules/ticket/mod_ticket_simple.php
@@ -46,7 +46,7 @@ class mod_ticket_simple extends ModeleNumRefTicket
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Simple';
diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php
index 5b5f5a55953..e6749bbb1f6 100644
--- a/htdocs/core/modules/ticket/mod_ticket_universal.php
+++ b/htdocs/core/modules/ticket/mod_ticket_universal.php
@@ -43,7 +43,7 @@ class mod_ticket_universal extends ModeleNumRefTicket
/**
* @var string Nom du modele
* @deprecated
- * @see name
+ * @see $name
*/
public $nom='Universal';
diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php
index 37ca5e1ec10..e695c7aa95f 100644
--- a/htdocs/core/tpl/admin_extrafields_add.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php
@@ -148,7 +148,7 @@ $langs->load("modulebuilder");
trans("LabelOrTranslationKey"); ?>
-trans("AttributeCode"); ?> (trans("AlphaNumOnlyLowerCharsAndNoSpace"); ?>)
+trans("AttributeCode"); ?> (trans("AlphaNumOnlyLowerCharsAndNoSpace"); ?>)
trans("Type"); ?>
selectarray('type', $type2label, GETPOST('type', 'alpha')); ?>
diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php
index 478c2dfa4b8..b3b6b5d1bf1 100644
--- a/htdocs/core/tpl/advtarget.tpl.php
+++ b/htdocs/core/tpl/advtarget.tpl.php
@@ -58,24 +58,27 @@ print ''."\n";
print ''."\n";
print ''."\n";
-print ' '."\n";
+print ' '."\n";
print ' '."\n";
print ' '."\n";
-print ''.$langs->trans('AdvTgtNameTemplate').' ';
+print ' '.$langs->trans('AdvTgtNameTemplate').' ';
if (!empty($template_id)) {
$default_template = $template_id;
} else {
$default_template = $advTarget->id;
}
-print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template, 0, $advTarget->type_element);
-print ' ';
-print ' ';
-print ' ';
-print $langs->trans('AdvTgtOrCreateNewFilter');
+print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template, 0, $advTarget->type_element, 'valignmiddle');
+print ' ';
+print ' ';
+print ' ';
+print ' ' . "\n";
+print ' ' . "\n";
+
+print '' . $langs->trans('AdvTgtOrCreateNewFilter') . ' ';
print ' ';
-print ' ';
+print ' ';
print ' '."\n";
print ' '."\n";
diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php
index 1a9a046bf81..169b7753b92 100644
--- a/htdocs/core/tpl/card_presend.tpl.php
+++ b/htdocs/core/tpl/card_presend.tpl.php
@@ -188,7 +188,8 @@ if ($action == 'presend')
}
}
- $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste;
+ $formmail->withto = $liste;
+ $formmail->withtofree = (GETPOSTISSET('sendto') ? (GETPOST('sendto') ? GETPOST('sendto') : '1') : '');
$formmail->withtocc = $liste;
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
$formmail->withtopic = $topicmail;
diff --git a/htdocs/core/tpl/extrafields_list_search_param.tpl.php b/htdocs/core/tpl/extrafields_list_search_param.tpl.php
index ca72293365a..6e6d6305106 100644
--- a/htdocs/core/tpl/extrafields_list_search_param.tpl.php
+++ b/htdocs/core/tpl/extrafields_list_search_param.tpl.php
@@ -8,7 +8,7 @@ if (empty($conf) || !is_object($conf))
}
// Loop to complete $param for extrafields
-if (!empty($search_array_options)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
+if (!empty($search_array_options) && is_array($search_array_options)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
{
if (empty($search_options_pattern)) $search_options_pattern = 'search_options_';
diff --git a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php
index 29c67094975..3a0bcf6375c 100644
--- a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php
+++ b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php
@@ -40,7 +40,10 @@ if (! empty($extrafieldsobjectkey) && ! empty($search_array_options) && is_array
if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int
if (in_array($typ, array('chkbxlst','checkbox'))) $mode_search=4; // Search on a multiselect field with sql type = text
if (is_array($crit)) $crit = implode(' ', $crit); // natural_search() expects a string
-
+ elseif ($typ === 'select' and is_string($crit) and strpos($crit, ' ') === false) {
+ $sql .= ' AND (' . $extrafieldsobjectprefix.$tmpkey . ' = "' . $db->escape($crit) . '")';
+ continue;
+ }
$sql .= natural_search($extrafieldsobjectprefix.$tmpkey, $crit, $mode_search);
}
}
diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php
index f8767a82163..1ef3ef07255 100644
--- a/htdocs/core/tpl/extrafields_view.tpl.php
+++ b/htdocs/core/tpl/extrafields_view.tpl.php
@@ -73,7 +73,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
//print $key.'-'.$enabled.'-'.$perms.'-'.$label.$_POST["options_" . $key].' '."\n";
if (empty($enabled)) continue; // 0 = Never visible field
- if (abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
+ if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
if (empty($perms)) continue; // 0 = Not visible
// Load language if required
@@ -135,7 +135,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
if ($object->element == 'productlot') $permok = $user->rights->stock->creer;
if ($object->element == 'facturerec') $permok = $user->rights->facture->creer;
if (($object->statut == 0 || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$key]))
- && $permok && ($action != 'edit_extras' || GETPOST('attribute') != $key)
+ && $permok && $enabled != 5 && ($action != 'edit_extras' || GETPOST('attribute') != $key)
&& empty($extrafields->attributes[$object->table_element]['computed'][$key]))
{
$fieldid = 'id';
diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php
index a0c627ac049..492590c65e4 100644
--- a/htdocs/core/tpl/massactions_pre.tpl.php
+++ b/htdocs/core/tpl/massactions_pre.tpl.php
@@ -45,7 +45,7 @@ if ($massaction == 'presend')
$listofselectedthirdparties = array();
$listofselectedref = array();
- if (! GETPOST('cancel', 'alpha'))
+ if (!GETPOST('cancel', 'alpha'))
{
foreach ($arrayofselected as $toselectid)
{
@@ -66,25 +66,25 @@ if ($massaction == 'presend')
print ' ';
- include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
dol_fiche_head(null, '', '');
// Cree l'objet formulaire mail
- include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->withform = -1;
- $formmail->fromtype = (GETPOST('fromtype') ? GETPOST('fromtype') : (! empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user'));
+ $formmail->fromtype = (GETPOST('fromtype') ? GETPOST('fromtype') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user'));
if ($formmail->fromtype === 'user')
{
$formmail->fromid = $user->id;
}
$formmail->trackid = $trackid;
- if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
+ if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{
- include DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
+ include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail = dolAddEmailTrackId($formmail->frommail, $trackid);
}
$formmail->withfrom = 1;
@@ -112,10 +112,10 @@ if ($massaction == 'presend')
$formmail->withtoreadonly = 1;
}
- $formmail->withoptiononeemailperrecipient = ((count($listofselectedref) == 1 && count(reset($listofselectedref)) == 1) || empty($liste)) ? 0 : ((GETPOST('oneemailperrecipient')=='on')?1:-1);
+ $formmail->withoptiononeemailperrecipient = ((count($listofselectedref) == 1 && count(reset($listofselectedref)) == 1) || empty($liste)) ? 0 : ((GETPOST('oneemailperrecipient') == 'on') ? 1 : -1);
- $formmail->withto = empty($liste)?(GETPOST('sendto', 'alpha')?GETPOST('sendto', 'alpha'):array()):$liste;
- $formmail->withtofree = empty($liste)?1:0;
+ $formmail->withto = empty($liste) ? (GETPOST('sendto', 'alpha') ?GETPOST('sendto', 'alpha') : array()) : $liste;
+ $formmail->withtofree = empty($liste) ? 1 : 0;
$formmail->withtocc = 1;
$formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC;
$formmail->withtopic = $langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__');
@@ -134,8 +134,8 @@ if ($massaction == 'presend')
$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto;
- $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? ' ' : '';
- $substitutionarray['__PERSONALIZED__'] = ''; // deprecated
+ $substitutionarray['__CHECK_READ__'] = (is_object($object) && is_object($object->thirdparty)) ? ' ' : '';
+ $substitutionarray['__PERSONALIZED__'] = ''; // deprecated
$substitutionarray['__CONTACTCIVNAME__'] = '';
$parameters = array(
@@ -152,11 +152,11 @@ if ($massaction == 'presend')
$formmail->param['models_id'] = GETPOST('modelmailselected', 'int');
$formmail->param['id'] = join(',', $arrayofselected);
// $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
- if (! empty($conf->global->MAILING_LIMIT_SENDBYWEB) && count($listofselectedthirdparties) > $conf->global->MAILING_LIMIT_SENDBYWEB)
+ if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && count($listofselectedthirdparties) > $conf->global->MAILING_LIMIT_SENDBYWEB)
{
$langs->load("errors");
- print img_warning() . ' ' . $langs->trans('WarningNumberOfRecipientIsRestrictedInMassAction', $conf->global->MAILING_LIMIT_SENDBYWEB);
- print ' - ' . $langs->trans("GoBack") . ' ';
+ print img_warning().' '.$langs->trans('WarningNumberOfRecipientIsRestrictedInMassAction', $conf->global->MAILING_LIMIT_SENDBYWEB);
+ print ' - '.$langs->trans("GoBack").' ';
$arrayofmassactions = array();
}
else
@@ -166,3 +166,15 @@ if ($massaction == 'presend')
dol_fiche_end();
}
+// Allow Pre-Mass-Action hook (eg for confirmation dialog)
+$parameters = array(
+ 'toselect' => $toselect,
+ 'uploaddir' => $uploaddir
+);
+
+$reshook = $hookmanager->executeHooks('doPreMassActions', $parameters, $object, $action);
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+} else {
+ print $hookmanager->resPrint;
+}
diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php
index 7663af1c48e..28eb78fa61b 100644
--- a/htdocs/core/tpl/notes.tpl.php
+++ b/htdocs/core/tpl/notes.tpl.php
@@ -1,7 +1,7 @@
* Copyright (C) 2013 Florian Henry
- * Copyright (C) 2014-2017 Laurent Destailleur
+ * Copyright (C) 2014-2020 Laurent Destailleur
*
* 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
@@ -29,69 +29,70 @@ $module = $object->element;
$note_public = 'note_public';
$note_private = 'note_private';
-$colwidth=(isset($colwidth)?$colwidth:(empty($cssclass)?'25':''));
+$colwidth = (isset($colwidth) ? $colwidth : (empty($cssclass) ? '25' : ''));
// 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;
-if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES))
+$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;
+if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PUBLIC_NOTES))
{
- $stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
+ $stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
if (GETPOST('action', 'aZ09') == 'edit'.$note_public)
{
- $value_public=dol_concatdesc($value_public, ($value_public?"\n":"")."-- ".$stringtoadd);
- if (dol_textishtml($value_public)) $value_public.=" \n";
- else $value_public.="\n";
+ $value_public = dol_concatdesc($value_public, ($value_public ? "\n" : "")."-- ".$stringtoadd);
+ if (dol_textishtml($value_public)) $value_public .= " \n";
+ else $value_public .= "\n";
}
}
-if (! empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES))
+if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES))
{
- $stringtoadd=dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
+ $stringtoadd = dol_print_date(dol_now(), 'dayhour').' '.$user->getFullName($langs).' --';
if (GETPOST('action', 'aZ09') == 'edit'.$note_private)
{
- $value_private=dol_concatdesc($value_private, ($value_private?"\n":"")."-- ".$stringtoadd);
- if (dol_textishtml($value_private)) $value_private.=" \n";
- else $value_private.="\n";
+ $value_private = dol_concatdesc($value_private, ($value_private ? "\n" : "")."-- ".$stringtoadd);
+ if (dol_textishtml($value_private)) $value_private .= " \n";
+ else $value_private .= "\n";
}
}
// Special cases
-if ($module == 'propal') { $permission=$user->rights->propale->creer;}
-elseif ($module == 'supplier_proposal') { $permission=$user->rights->supplier_proposal->creer;}
-elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer;}
-elseif ($module == 'project') { $permission=$user->rights->projet->creer;}
-elseif ($module == 'project_task') { $permission=$user->rights->projet->creer;}
-elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer;}
-elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer;}
-elseif ($module == 'societe') { $permission=$user->rights->societe->creer;}
-elseif ($module == 'contact') { $permission=$user->rights->societe->creer;}
-elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer;}
-elseif ($module == 'product') { $permission=$user->rights->produit->creer;}
+if ($module == 'propal') { $permission = $user->rights->propale->creer; }
+elseif ($module == 'supplier_proposal') { $permission = $user->rights->supplier_proposal->creer; }
+elseif ($module == 'fichinter') { $permission = $user->rights->ficheinter->creer; }
+elseif ($module == 'project') { $permission = $user->rights->projet->creer; }
+elseif ($module == 'project_task') { $permission = $user->rights->projet->creer; }
+elseif ($module == 'invoice_supplier') { $permission = $user->rights->fournisseur->facture->creer; }
+elseif ($module == 'order_supplier') { $permission = $user->rights->fournisseur->commande->creer; }
+elseif ($module == 'societe') { $permission = $user->rights->societe->creer; }
+elseif ($module == 'contact') { $permission = $user->rights->societe->creer; }
+elseif ($module == 'shipping') { $permission = $user->rights->expedition->creer; }
+elseif ($module == 'product') { $permission = $user->rights->produit->creer; }
//else dol_print_error('','Bad value '.$module.' for param module');
-if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note.
-else $typeofdata='textarea:12:95%';
+if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note.
+else $typeofdata = 'textarea:12:95%';
print ''."\n";
print ''."\n";
if ($module != 'product') {
// No public note yet on products
print '
'."\n";
- print '
'."\n";
+ print '
'."\n";
print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0);
print '
'."\n";
- print '
'."\n";
+ print '
'."\n";
print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1)."\n";
print '
'."\n";
print '
'."\n";
}
if (empty($user->socid)) {
+ // Private notes (always hidden to external users)
print '
'."\n";
- print '
'."\n";
+ print '
'."\n";
print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0);
print '
'."\n";
- print '
'."\n";
+ print '
'."\n";
print $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, '', null, null, $moreparam, 1);
print '
'."\n";
print '
'."\n";
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index b60c48da09c..954a6a8b089 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -432,7 +432,7 @@ if ($nolinesbefore) {
showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1);
+ print $objectline->showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', 1);
}
if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required
@@ -541,6 +541,7 @@ if (!empty($usemargins) && $user->rights->margins->creer)
else if (npRate == "np_markRate")
price = ((bpjs / (1 - ratejs / 100)) / (1 - remisejs / 100));
}
+
$("input[name='price_ht']:first").val(price); // TODO Must use a function like php price to have here a formated value
return true;
@@ -552,26 +553,26 @@ if (!empty($usemargins) && $user->rights->margins->creer)
/* JQuery for product free or predefined select */
jQuery(document).ready(function() {
- jQuery("#price_ht").keyup(function(event) {
- // console.log(event.which); // discard event tag and arrows
- if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') {
- jQuery("#price_ttc").val('');
- jQuery("#multicurrency_subprice").val('');
- }
+ jQuery("#price_ht").keyup(function(event) {
+ // console.log(event.which); // discard event tag and arrows
+ if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') {
+ jQuery("#price_ttc").val('');
+ jQuery("#multicurrency_subprice").val('');
+ }
});
jQuery("#price_ttc").keyup(function(event) {
- // console.log(event.which); // discard event tag and arrows
- if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') {
- jQuery("#price_ht").val('');
- jQuery("#multicurrency_subprice").val('');
- }
+ // console.log(event.which); // discard event tag and arrows
+ if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') {
+ jQuery("#price_ht").val('');
+ jQuery("#multicurrency_subprice").val('');
+ }
});
jQuery("#multicurrency_subprice").keyup(function(event) {
- // console.log(event.which); // discard event tag and arrows
- if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') {
- jQuery("#price_ht").val('');
- jQuery("#price_ttc").val('');
- }
+ // console.log(event.which); // discard event tag and arrows
+ if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') {
+ jQuery("#price_ht").val('');
+ jQuery("#price_ttc").val('');
+ }
});
$("#prod_entry_mode_free").on( "click", function() {
@@ -630,15 +631,24 @@ if (!empty($usemargins) && $user->rights->margins->creer)
if (empty($conf->global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT) && empty($senderissupplier))
{
?>
- // Get the HT price for the product and display it
- console.log("Load price without tax and set it into #price_ht");
- $.post('/product/ajax/products.php?action=fetch',
- { 'id': $(this).val(), 'socid' : socid; ?> },
- function(data) { jQuery("#price_ht").val(data.price_ht); },
- 'json'
- );
+ var pbq = parseInt($('option:selected', this).attr('data-pbq'));
+ if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0)
+ {
+ console.log("We are in a price per qty context, we do not call ajax/product");
+ } else {
+ // Get the HT price for the product and display it
+ console.log("Load price without tax and set it into #price_ht for id="+$(this).val()+" socid=socid; ?>");
+ $.post('/product/ajax/products.php?action=fetch',
+ { 'id': $(this).val(), 'socid': socid; ?> },
+ function(data) {
+ jQuery("#price_ht").val(data.price_ht);
+ },
+ 'json'
+ );
+ }
rights->margins->creer)
{
$langs->load('stocks');
@@ -744,15 +754,20 @@ if (!empty($usemargins) && $user->rights->margins->creer)
}
?>
- /* To process customer price per quantity */
+ /* To process customer price per quantity (CUSTOMER_PRICE_PER_QTY works only if combo product is not an ajax after x key pressed) */
var pbq = parseInt($('option:selected', this).attr('data-pbq'));
+ var pbqup = parseInt($('option:selected', this).attr('data-pbqup'));
+ var pbqbase = $('option:selected', this).attr('data-pbqbase');
var pbqqty = parseFloat($('option:selected', this).attr('data-pbqqty'));
var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent'));
- if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && typeof pbq !== "undefined")
+ if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && ! isNaN(pbq) && pbq > 0)
{
- console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent);
+ var pbqupht = pbqup; /* TODO support of price per qty TTC not yet available */
+
+ console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty upht = "+pbqupht+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent);
jQuery("#pbq").val(pbq);
+ jQuery("#price_ht").val(pbqupht);
if (jQuery("#qty").val() < pbqqty)
{
jQuery("#qty").val(pbqqty);
@@ -809,7 +824,6 @@ if (!empty($usemargins) && $user->rights->margins->creer)
jQuery("#price_ht").val('').hide();
jQuery("#multicurrency_price_ht").val('').hide();
- jQuery("#price_ht").val('');
jQuery("#price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide();
jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide();
jQuery("#buying_price").show();
diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php
index 7c76a5c0e07..278b8eabdd8 100644
--- a/htdocs/core/tpl/objectline_edit.tpl.php
+++ b/htdocs/core/tpl/objectline_edit.tpl.php
@@ -260,7 +260,7 @@ $coldisplay++;
//Line extrafield
if (!empty($extrafields))
{
- print $line->showOptionals($extrafields, 'edit', array('class'=>'tredited', 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
+ print $line->showOptionals($extrafields, 'edit', array('class'=>'tredited', 'colspan'=>$coldisplay), '', '', 1);
}
?>
diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php
index 19a10e0f560..59f2e1ef57c 100644
--- a/htdocs/core/tpl/objectline_view.tpl.php
+++ b/htdocs/core/tpl/objectline_view.tpl.php
@@ -356,7 +356,7 @@ print "\n";
//Line extrafield
if (!empty($extrafields))
{
- print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1);
+ print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', 1);
}
print "\n";
diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
index b50008dba2e..b51fd0a20b7 100644
--- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
+++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
@@ -1,10 +1,11 @@
- * Copyright (C) 2009-2017 Regis Houssin
- * Copyright (C) 2011-2014 Juanjo Menent
- * Copyright (C) 2013 Cedric GROSS
- * Copyright (C) 2014 Marcos García
- * Copyright (C) 2015 Bahfir Abbes
+/*
+ * Copyright (C) 2005-2017 Laurent Destailleur
+ * Copyright (C) 2009-2017 Regis Houssin
+ * Copyright (C) 2011-2014 Juanjo Menent
+ * Copyright (C) 2013 Cedric GROSS
+ * Copyright (C) 2014 Marcos García
+ * Copyright (C) 2015 Bahfir Abbes
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -13,7 +14,7 @@
*
* 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
+ * 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
@@ -21,29 +22,31 @@
*/
/**
- * \file htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
- * \ingroup agenda
- * \brief Trigger file for company - contactroles
+ * \file htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
+ * \ingroup agenda
+ * \brief Trigger file for company - contactroles
*/
-
require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
-
/**
- * Class of triggered functions for agenda module
+ * Class of triggered functions for agenda module
*/
class InterfaceContactRoles extends DolibarrTriggers
{
+
public $family = 'agenda';
+
public $description = "Triggers of this module auto link contact to company.";
/**
* Version of the trigger
+ *
* @var string
*/
public $version = self::VERSION_DOLIBARR;
/**
+ *
* @var string Image of the trigger
*/
public $picto = 'action';
@@ -53,56 +56,56 @@ class InterfaceContactRoles extends DolibarrTriggers
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
*
* Following properties may be set before calling trigger. The may be completed by this trigger to be used for writing the event into database:
- * $object->socid or $object->fk_soc(id of thirdparty)
- * $object->element (element type of object)
+ * $object->socid or $object->fk_soc(id of thirdparty)
+ * $object->element (element type of object)
*
- * @param string $action Event action code
- * @param Object $object Object
- * @param User $user Object user
- * @param Translate $langs Object langs
- * @param conf $conf Object conf
- * @return int <0 if KO, 0 if no triggered ran, >0 if OK
+ * @param string $action Event action code
+ * @param Object $object Object
+ * @param User $user Object user
+ * @param Translate $langs Object langs
+ * @param conf $conf Object conf
+ * @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
{
-
- if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE' || $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE'
- || $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE' || $action === 'ACTION_CREATE') {
+ if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE'
+ || $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' || $action === 'PROPOSAL_SUPPLIER_CREATE'
+ || $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- $socid=(property_exists($object, 'socid')?$object->socid:$object->fk_soc);
+ $socid = (property_exists($object, 'socid') ? $object->socid : $object->fk_soc);
- if (! empty($socid) && $socid > 0) {
+ if (!empty($socid) && $socid > 0) {
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$contactdefault = new Contact($this->db);
- $contactdefault->socid=$socid;
+ $contactdefault->socid = $socid;
$TContact = $contactdefault->getContactRoles($object->element);
- $TContactAlreadyLinked = array();
- if ($object->id > 0)
- {
- $class = get_class($object);
- $cloneFrom = new $class($this->db);
- $r = $cloneFrom->fetch($object->id);
+ if (is_array($TContact) && !empty($TContact)) {
+ $TContactAlreadyLinked = array();
+ if ($object->id > 0) {
+ $cloneFrom = dol_clone($object, 1);
- if (!empty($cloneFrom->id)) $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal'));
- }
+ if (!empty($cloneFrom->id)) {
+ $TContactAlreadyLinked = array_merge($cloneFrom->liste_contact(-1, 'external'), $cloneFrom->liste_contact(-1, 'internal'));
+ }
+ }
- if (is_array($TContact))
- {
- foreach($TContact as $i => $infos) {
+ foreach ($TContact as $i => $infos) {
foreach ($TContactAlreadyLinked as $contactData) {
- if ($contactData['id'] == $infos['fk_socpeople'] && $contactData['fk_c_type_contact'] == $infos['type_contact']) unset($TContact[$i]);
+ if ($contactData['id'] == $infos['fk_socpeople'] && $contactData['fk_c_type_contact'] == $infos['type_contact'])
+ unset($TContact[$i]);
}
}
$nb = 0;
- foreach($TContact as $infos) {
+ foreach ($TContact as $infos) {
$res = $object->add_contact($infos['fk_socpeople'], $infos['type_contact']);
- if ($res > 0) $nb++;
+ if ($res > 0)
+ $nb++;
}
- if($nb > 0) {
+ if ($nb > 0) {
setEventMessages($langs->trans('ContactAddedAutomatically', $nb), null, 'mesgs');
}
}
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index 5cde792bbb5..82a898a8ddf 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -1308,7 +1308,7 @@ class Cronjob extends CommonObject
public function LibStatut($status, $mode = 0, $processing = 0, $lastresult = 0)
{
// phpcs:enable
- $this->labelStatus = array(); // Force reset o array because label depends on other fields
+ $this->labelStatus = array(); // Force reset o array because label depends on other fields
$this->labelStatusShort = array();
if (empty($this->labelStatus) || empty($this->labelStatusShort))
diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php
index 7bb598135f3..145da542976 100644
--- a/htdocs/dav/dav.class.php
+++ b/htdocs/dav/dav.class.php
@@ -175,7 +175,7 @@ class CdavLib
$caldata.="LAST-MODIFIED:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n";
$caldata.="DTSTAMP:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n";
if($obj->sourceuid=='')
- $caldata.="UID:".$obj->id.'-ev-'.$calid.'-cal-'.CDAV_URI_KEY."\n";
+ $caldata.="UID:".$obj->id.'-ev-'.$calid.'-cal-'.constant('CDAV_URI_KEY')."\n";
else
$caldata.="UID:".$obj->sourceuid."\n";
$caldata.="SUMMARY:".$obj->label."\n";
@@ -277,7 +277,7 @@ class CdavLib
{
$calevents[] = array(
'calendardata' => $calendardata,
- 'uri' => $obj->id.'-ev-'.CDAV_URI_KEY,
+ 'uri' => $obj->id.'-ev-'.constant('CDAV_URI_KEY'),
'lastmodified' => strtotime($obj->lastupd),
'etag' => '"'.md5($calendardata).'"',
'calendarid' => $calendarId,
@@ -289,7 +289,7 @@ class CdavLib
{
$calevents[] = array(
// 'calendardata' => $calendardata, not necessary because etag+size are present
- 'uri' => $obj->id.'-ev-'.CDAV_URI_KEY,
+ 'uri' => $obj->id.'-ev-'.constant('CDAV_URI_KEY'),
'lastmodified' => strtotime($obj->lastupd),
'etag' => '"'.md5($calendardata).'"',
'calendarid' => $calendarId,
diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php
index 9387c1a099d..e8e7fa4f5b9 100644
--- a/htdocs/don/admin/donation.php
+++ b/htdocs/don/admin/donation.php
@@ -2,9 +2,9 @@
/* Copyright (C) 2005-2010 Laurent Destailleur
* Copyright (C) 2012-2015 Juanjo Menent
* Copyright (C) 2013-2017 Philippe Grand
- * Copyright (C) 2015-2017 Alexandre Spangaro
+ * Copyright (C) 2015-2020 Alexandre Spangaro
* Copyright (C) 2015 Benoit Bruchard
- * Copyright (C) 2019 Thibault FOUCART
+ * Copyright (C) 2019 Thibault FOUCART
*
* 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
@@ -431,13 +431,13 @@ if (preg_match('/fr/i', $conf->global->MAIN_INFO_SOCIETE_COUNTRY))
print '';
print '';
- print ''.$langs->trans("DONATION_ART885").' ';
+ print ''.$langs->trans("DONATION_ART978").' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('DONATION_ART885');
+ print ajax_constantonoff('DONATION_ART978');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("DONATION_ART885", $arrval, $conf->global->DONATION_ART885);
+ print $form->selectarray("DONATION_ART978", $arrval, $conf->global->DONATION_ART978);
}
print ' ';
print "
\n";
diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php
index 4adef57e816..95ea92f1ff3 100644
--- a/htdocs/don/class/api_donations.class.php
+++ b/htdocs/don/class/api_donations.class.php
@@ -284,10 +284,10 @@ class Donations extends DolibarrApi
*
* @url POST {id}/validate
*
- * @throws 304
- * @throws 401
- * @throws 404
- * @throws 500
+ * @throws RestException 304
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 500
*
* @return array
*/
diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php
index abdc35c850e..b3ab7e2d360 100644
--- a/htdocs/don/payment/payment.php
+++ b/htdocs/don/payment/payment.php
@@ -29,12 +29,12 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$langs->load("bills");
-$chid=GETPOST("rowid");
-$action=GETPOST('action', 'aZ09');
+$chid = GETPOST("rowid");
+$action = GETPOST('action', 'aZ09');
$amounts = array();
// Security check
-$socid=0;
+$socid = 0;
if ($user->socid > 0) {
$socid = $user->socid;
}
@@ -48,7 +48,7 @@ $object = new Don($db);
if ($action == 'add_payment')
{
- $error=0;
+ $error = 0;
if ($_POST["cancel"])
{
@@ -59,7 +59,7 @@ if ($action == 'add_payment')
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
- if (! $_POST["paymenttype"] > 0)
+ if (!$_POST["paymenttype"] > 0)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
$error++;
@@ -69,13 +69,13 @@ if ($action == 'add_payment')
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
$error++;
}
- if (! empty($conf->banque->enabled) && ! $_POST["accountid"] > 0)
+ if (!empty($conf->banque->enabled) && !$_POST["accountid"] > 0)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
$error++;
}
- if (! $error)
+ if (!$error)
{
$paymentid = 0;
@@ -92,11 +92,11 @@ if ($action == 'add_payment')
if (count($amounts) <= 0)
{
$error++;
- $errmsg='ErrorNoPaymentDefined';
+ $errmsg = 'ErrorNoPaymentDefined';
setEventMessages($errmsg, null, 'errors');
}
- if (! $error)
+ if (!$error)
{
$db->begin();
@@ -104,34 +104,34 @@ if ($action == 'add_payment')
$payment = new PaymentDonation($db);
$payment->chid = $chid;
$payment->datepaid = $datepaid;
- $payment->amounts = $amounts; // Tableau de montant
+ $payment->amounts = $amounts; // Tableau de montant
$payment->paymenttype = GETPOST("paymenttype", 'int');
$payment->num_payment = GETPOST("num_payment", 'alphanohtml');
$payment->note_public = GETPOST("note_public", 'none');
- if (! $error)
+ if (!$error)
{
$paymentid = $payment->create($user);
if ($paymentid < 0)
{
- $errmsg=$payment->error;
+ $errmsg = $payment->error;
setEventMessages($errmsg, null, 'errors');
$error++;
}
}
- if (! $error)
+ if (!$error)
{
- $result=$payment->addPaymentToBank($user, 'payment_donation', '(DonationPayment)', $_POST['accountid'], '', '');
- if (! $result > 0)
+ $result = $payment->addPaymentToBank($user, 'payment_donation', '(DonationPayment)', $_POST['accountid'], '', '');
+ if (!$result > 0)
{
- $errmsg=$payment->error;
+ $errmsg = $payment->error;
setEventMessages($errmsg, null, 'errors');
$error++;
}
}
- if (! $error)
+ if (!$error)
{
$db->commit();
$loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
@@ -153,18 +153,18 @@ if ($action == 'add_payment')
* View
*/
-$form=new Form($db);
+$form = new Form($db);
llxHeader();
$sql = "SELECT sum(p.amount) as total";
-$sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
-$sql.= " WHERE p.fk_donation = ".$chid;
+$sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
+$sql .= " WHERE p.fk_donation = ".$chid;
$resql = $db->query($sql);
if ($resql)
{
- $obj=$db->fetch_object($resql);
+ $obj = $db->fetch_object($resql);
$sumpaid = $obj->total;
$db->free();
}
@@ -191,20 +191,20 @@ if ($action == 'create')
print ' '.$langs->trans("Date").' ';
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
- $datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaid):0;
+ $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaid) : 0;
print $form->selectDate($datepayment, '', 0, 0, 0, "add_payment", 1, 1, 0, '', '', $object->date, '', 1, $langs->trans("DonationDate"));
print " ";
print ' ';
print ''.$langs->trans("PaymentMode").' ';
- $form->select_types_paiements(isset($_POST["paymenttype"])?$_POST["paymenttype"]:$object->paymenttype, "paymenttype");
+ $form->select_types_paiements(GETPOSTISSET("paymenttype") ? GETPOST("paymenttype") : $object->paymenttype, "paymenttype");
print " \n";
print ' ';
print '';
print ''.$langs->trans('AccountToCredit').' ';
print '';
- $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$object->accountid, "accountid", 0, '', 1); // Show open bank account list
+ $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid") : $object->accountid, "accountid", 0, '', 1); // Show open bank account list
print ' ';
// Number
@@ -238,8 +238,8 @@ if ($action == 'create')
print ''.$langs->trans("Amount").' ';
print "\n";
- $total=0;
- $totalrecu=0;
+ $total = 0;
+ $totalrecu = 0;
while ($i < $num)
{
diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php
index 0844cff2057..0c27f710135 100644
--- a/htdocs/emailcollector/class/emailcollector.class.php
+++ b/htdocs/emailcollector/class/emailcollector.class.php
@@ -812,9 +812,9 @@ class EmailCollector extends CommonObject
//var_dump($tmpproperty.' - '.$regexstring.' - '.$regexoptions.' - '.$sourcestring);
if (preg_match('/'.$regexstring.'/'.$regexoptions, $sourcestring, $regforval))
{
- //var_dump($regforval[1]);exit;
+ //var_dump($regforval[count($regforval)-1]);exit;
// Overwrite param $tmpproperty
- $object->$tmpproperty = isset($regforval[1]) ?trim($regforval[1]) : null;
+ $object->$tmpproperty = isset($regforval[count($regforval)-1]) ?trim($regforval[count($regforval)-1]) : null;
}
else
{
@@ -1423,9 +1423,9 @@ class EmailCollector extends CommonObject
//var_dump($regexstring);var_dump($sourcestring);
if (preg_match('/'.$regexstring.'/ms', $sourcestring, $regforval))
{
- //var_dump($regforval[1]);exit;
+ //var_dump($regforval[count($regforval)-1]);exit;
// Overwrite param $tmpproperty
- $nametouseforthirdparty = isset($regforval[1]) ?trim($regforval[1]) : null;
+ $nametouseforthirdparty = isset($regforval[count($regforval)-1]) ?trim($regforval[count($regforval)-1]) : null;
}
else
{
@@ -2013,6 +2013,9 @@ class EmailCollector extends CommonObject
// TEXT
if ($p->type == 0 && $data) {
+ if(!empty($params['charset'])) {
+ $data = $this->convertStringEncoding($data, $params['charset']);
+ }
// Messages may be split in different parts because of inline attachments,
// so append parts together with blank row.
if (strtolower($p->subtype) == 'plain')
@@ -2028,6 +2031,9 @@ class EmailCollector extends CommonObject
// There are no PHP functions to parse embedded messages,
// so this just appends the raw source to the main message.
elseif ($p->type == 2 && $data) {
+ if(!empty($params['charset'])) {
+ $data = $this->convertStringEncoding($data, $params['charset']);
+ }
$plainmsg .= $data."\n\n";
}
@@ -2039,4 +2045,28 @@ class EmailCollector extends CommonObject
}
}
}
+
+ /**
+ * Converts a string from one encoding to another.
+ *
+ * @param string $string String to convert
+ * @param string $fromEncoding String encoding
+ * @param string $toEncoding String return encoding
+ * @return string Converted string if conversion was successful, or the original string if not
+ * @throws Exception
+ */
+ protected function convertStringEncoding($string, $fromEncoding, $toEncoding = 'UTF-8')
+ {
+ if(!$string || $fromEncoding == $toEncoding) {
+ return $string;
+ }
+ $convertedString = function_exists('iconv') ? @iconv($fromEncoding, $toEncoding . '//IGNORE', $string) : null;
+ if(!$convertedString && extension_loaded('mbstring')) {
+ $convertedString = @mb_convert_encoding($string, $toEncoding, $fromEncoding);
+ }
+ if(!$convertedString) {
+ throw new Exception('Mime string encoding conversion failed');
+ }
+ return $convertedString;
+ }
}
diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index 0b9682f5f06..741b0c09611 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -241,11 +241,11 @@ if (empty($reshook))
if ($objectsrc->lines[$i]->product_tobatch) // If product need a batch number
{
- if (isset($_POST[$batch]))
+ if (GETPOSTISSET($batch))
{
//shipment line with batch-enable product
$qty .= '_'.$j;
- while (isset($_POST[$batch]))
+ while (GETPOSTISSET($batch))
{
// save line of detail into sub_qty
$sub_qty[$j]['q'] = GETPOST($qty, 'int'); // the qty we want to move for this stock record
@@ -277,11 +277,11 @@ if (empty($reshook))
}
}
}
- elseif (isset($_POST[$stockLocation]))
+ elseif (GETPOSTISSET($stockLocation))
{
//shipment line from multiple stock locations
$qty .= '_'.$j;
- while (isset($_POST[$stockLocation]))
+ while (GETPOSTISSET($stockLocation))
{
// save sub line of warehouse
$stockLine[$i][$j]['qty'] = GETPOST($qty, 'int');
@@ -1578,7 +1578,7 @@ if ($action == 'create')
//$line->fetch_optionals($line->id);
$line->array_options = array_merge($line->array_options, $srcLine->array_options);
- print $expLine->showOptionals($extrafields, 'edit', array('style'=>'class="drag drop oddeven"', 'colspan'=>$colspan), $indiceAsked, '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1);
+ print $expLine->showOptionals($extrafields, 'edit', array('style'=>'class="drag drop oddeven"', 'colspan'=>$colspan), $indiceAsked, '', 1);
}
}
@@ -1693,7 +1693,7 @@ elseif ($id || $ref)
}
// Call Hook formConfirm
- $parameters = array();
+ $parameters = array('formConfirm' => $formconfirm);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php
index 5aca14fb28d..8526f0c9610 100644
--- a/htdocs/expedition/class/api_shipments.class.php
+++ b/htdocs/expedition/class/api_shipments.class.php
@@ -373,8 +373,9 @@ class Shipments extends DolibarrApi
* @url DELETE {id}/lines/{lineid}
*
* @return int
- * @throws 401
- * @throws 404
+ *
+ * @throws RestException 401
+ * @throws RestException 404
*/
public function deleteLine($id, $lineid)
{
@@ -537,10 +538,10 @@ class Shipments extends DolibarrApi
// *
// * @return int
// *
- // * @throws 400
- // * @throws 401
- // * @throws 404
- // * @throws 405
+ // * @throws RestException 400
+ // * @throws RestException 401
+ // * @throws RestException 404
+ // * @throws RestException 405
// */
/*
public function setinvoiced($id)
@@ -574,10 +575,10 @@ class Shipments extends DolibarrApi
// * @url POST /createfromorder/{orderid}
// *
// * @return int
- // * @throws 400
- // * @throws 401
- // * @throws 404
- // * @throws 405
+ // * @throws RestException 400
+ // * @throws RestException 401
+ // * @throws RestException 404
+ // * @throws RestException 405
// */
/*
public function createShipmentFromOrder($orderid)
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index a3f5f21659d..bf20ac42611 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -447,7 +447,7 @@ class Expedition extends CommonObject
* @param array $array_options extrafields array
* @return int <0 if KO, line_id if OK
*/
- public function create_line($entrepot_id, $origin_line_id, $qty, $rang, $array_options = 0)
+ public function create_line($entrepot_id, $origin_line_id, $qty, $rang = 0, $array_options = 0)
{
//phpcs:enable
global $user;
diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php
index 478d4287a82..146f4b54962 100644
--- a/htdocs/expedition/contact.php
+++ b/htdocs/expedition/contact.php
@@ -211,7 +211,7 @@ if ($id > 0 || !empty($ref))
//print '';
print '
';
- print '
';
+ print '';
// Linked documents
if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled))
diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php
index 7c400c0fbb7..f7ff3565e10 100644
--- a/htdocs/expedition/list.php
+++ b/htdocs/expedition/list.php
@@ -59,6 +59,10 @@ $search_state = trim(GETPOST("search_state"));
$search_country = GETPOST("search_country", 'int');
$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
$search_billed = GETPOST("search_billed", 'int');
+$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_startmonth', 'int'), GETPOST('search_datedelivery_startday', 'int'), GETPOST('search_datedelivery_startyear', 'int'));
+$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_endmonth', 'int'), GETPOST('search_datedelivery_endday', 'int'), GETPOST('search_datedelivery_endyear', 'int'));
+$search_datereceipt_start = dol_mktime(0, 0, 0, GETPOST('search_datereceipt_startmonth', 'int'), GETPOST('search_datereceipt_startday', 'int'), GETPOST('search_datereceipt_startyear', 'int'));
+$search_datereceipt_end = dol_mktime(23, 59, 59, GETPOST('search_datereceipt_endmonth', 'int'), GETPOST('search_datereceipt_endday', 'int'), GETPOST('search_datereceipt_endyear', 'int'));
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$optioncss = GETPOST('optioncss', 'alpha');
@@ -156,6 +160,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_country = '';
$search_type_thirdparty = '';
$search_billed = '';
+ $search_datedelivery_start = '';
+ $search_datedelivery_end = '';
+ $search_datereceipt_start = '';
+ $search_datereceipt_end = '';
$viewstatut = '';
$toselect = '';
$search_array_options = array();
@@ -234,6 +242,10 @@ if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdp
if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp);
if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv);
if ($search_company) $sql .= natural_search('s.nom', $search_company);
+if ($search_datedelivery_start) $sql .= " AND e.date_delivery >= '".$db->idate($search_datedelivery_start)."'";
+if ($search_datedelivery_end) $sql .= " AND e.date_delivery <= '".$db->idate($search_datedelivery_end)."'";
+if ($search_datereceipt_start) $sql .= " AND l.date_delivery >= '".$db->idate($search_datereceipt_start)."'";
+if ($search_datereceipt_end) $sql .= " AND l.date_delivery <= '".$db->idate($search_datereceipt_end)."'";
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
// Add where from extra fields
@@ -280,6 +292,10 @@ if ($resql)
if ($search_company) $param .= "&search_company=".urlencode($search_company);
if ($search_town) $param .= '&search_town='.urlencode($search_town);
if ($search_zip) $param .= '&search_zip='.urlencode($search_zip);
+ if ($search_datedelivery_start) $param .= '&search_datedelivery_start='.urlencode($search_datedelivery_start);
+ if ($search_datedelivery_end) $param .= '&search_datedelivery_end='.urlencode($search_datedelivery_end);
+ if ($search_datereceipt_start) $param .= '&search_datereceipt_start='.urlencode($search_datereceipt_start);
+ if ($search_datereceipt_end) $param .= '&search_datereceipt_end='.urlencode($search_datereceipt_end);
if ($viewstatut != '') $param .= '&viewstatut='.urlencode($viewstatut);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
@@ -391,7 +407,16 @@ if ($resql)
// Date delivery planned
if (!empty($arrayfields['e.date_delivery']['checked']))
{
- print ' ';
+ print '';
+ print '';
+ print $langs->trans('From').' ';
+ print $form->selectDate($search_delivery_start ? $search_delivery_start : -1, 'search_delivery_start', 0, 0, 1);
+ print '
';
+ print '';
+ print $langs->trans('to').' ';
+ print $form->selectDate($search_delivery_end ? $search_delivery_end : -1, 'search_delivery_end', 0, 0, 1);
+ print '
';
+ print ' ';
}
if (!empty($arrayfields['l.ref']['checked']))
{
@@ -403,7 +428,16 @@ if ($resql)
if (!empty($arrayfields['l.date_delivery']['checked']))
{
// Date received
- print ' ';
+ print '';
+ print '';
+ print $langs->trans('From').' ';
+ print $form->selectDate($search_receipt_start ? $search_receipt_start : -1, 'search_receipt_start', 0, 0, 1);
+ print '
';
+ print '';
+ print $langs->trans('to').' ';
+ print $form->selectDate($search_receipt_end ? $search_receipt_end : -1, 'search_receipt_end', 0, 0, 1);
+ print '
';
+ print ' ';
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php
index 4834152127f..5039af22e84 100644
--- a/htdocs/expedition/shipment.php
+++ b/htdocs/expedition/shipment.php
@@ -261,7 +261,7 @@ if ($id > 0 || !empty($ref))
}
// Call Hook formConfirm
- $parameters = array();
+ $parameters = array('formConfirm' => $formconfirm);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index cbca46576a1..79e418206a5 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -389,7 +389,7 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
- $link = '' . $link . ' ';
+ $link = ''.$link.' ';
$message = $langs->transnoentities("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut, $object->date_fin, '', $langs), $link);
// Rebuild pdf
@@ -509,7 +509,7 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
- $link = '' . $link . ' ';
+ $link = ''.$link.' ';
$dateRefusEx = explode(" ", $object->date_refuse);
$message = $langs->transnoentities("ExpenseReportWaitingForReApprovalMessage", $dateRefusEx[0], $object->detail_refuse, $expediteur->getFullName($langs), $link);
@@ -635,7 +635,7 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
- $link = '' . $link . ' ';
+ $link = ''.$link.' ';
$message = $langs->transnoentities("ExpenseReportApprovedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
// Rebuilt pdf
@@ -755,7 +755,7 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
- $link = '' . $link . ' ';
+ $link = ''.$link.' ';
$message = $langs->transnoentities("ExpenseReportRefusedMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailRefuse, $link);
// Rebuilt pdf
@@ -885,7 +885,7 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
- $link = '' . $link . ' ';
+ $link = ''.$link.' ';
$message = $langs->transnoentities("ExpenseReportCanceledMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $detailCancel, $link);
// Rebuilt pdf
@@ -1111,7 +1111,7 @@ if (empty($reshook))
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
- $link = '' . $link . ' ';
+ $link = ''.$link.' ';
$message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
// Generate pdf before attachment
diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php
index 0e673ffdf30..60e5eafcb48 100644
--- a/htdocs/expensereport/class/api_expensereports.class.php
+++ b/htdocs/expensereport/class/api_expensereports.class.php
@@ -501,6 +501,9 @@ class ExpenseReports extends DolibarrApi
// phpcs:enable
$object = parent::_cleanObjectDatas($object);
+ unset($object->cond_reglement);
+ unset($object->shipping_method_id);
+
unset($object->barcode_type);
unset($object->barcode_type_code);
unset($object->barcode_type_label);
diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php
index 05272aa2ff7..14ab2b88f22 100644
--- a/htdocs/expensereport/class/expensereport.class.php
+++ b/htdocs/expensereport/class/expensereport.class.php
@@ -1486,7 +1486,7 @@ class ExpenseReport extends CommonObject
{
// phpcs:enable
$error = 0;
- $this->date_cancel = $this->db->idate(gmmktime());
+ $this->date_cancel = $this->db->idate(dol_now());
if ($this->fk_statut != self::STATUS_CANCELED)
{
$this->db->begin();
diff --git a/htdocs/expensereport/class/expensereport_ik.class.php b/htdocs/expensereport/class/expensereport_ik.class.php
index bac8522ca74..c7bf959e27e 100644
--- a/htdocs/expensereport/class/expensereport_ik.class.php
+++ b/htdocs/expensereport/class/expensereport_ik.class.php
@@ -32,17 +32,17 @@ class ExpenseReportIk extends CoreObject
/**
* @var string ID to identify managed object
*/
- public $element='expenseik';
+ public $element = 'expenseik';
/**
* @var string Name of table without prefix where object is stored
*/
- public $table_element='expensereport_ik';
+ public $table_element = 'expensereport_ik';
/**
* @var int Field with ID of parent key if this field has a parent
*/
- public $fk_element='fk_expense_ik';
+ public $fk_element = 'fk_expense_ik';
/**
* c_exp_tax_cat Id
@@ -72,10 +72,10 @@ class ExpenseReportIk extends CoreObject
* Attribute object linked with database
* @var array
*/
- protected $fields=array(
- 'rowid'=>array('type'=>'integer','index'=>true)
- ,'fk_c_exp_tax_cat'=>array('type'=>'integer','index'=>true)
- ,'fk_range'=>array('type'=>'integer','index'=>true)
+ public $fields = array(
+ 'rowid'=>array('type'=>'integer', 'index'=>true)
+ ,'fk_c_exp_tax_cat'=>array('type'=>'integer', 'index'=>true)
+ ,'fk_range'=>array('type'=>'integer', 'index'=>true)
,'coef'=>array('type'=>'double')
,'ikoffset'=>array('type'=>'double')
);
@@ -109,10 +109,10 @@ class ExpenseReportIk extends CoreObject
$categories = array();
$sql = 'SELECT rowid, label, entity, active';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat';
- $sql.= ' WHERE entity IN ('. getEntity('c_exp_tax_cat').')';
- if ($mode == 1) $sql.= ' AND active = 1';
- elseif ($mode == 2) $sql.= 'AND active = 0';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat';
+ $sql .= ' WHERE entity IN ('.getEntity('c_exp_tax_cat').')';
+ if ($mode == 1) $sql .= ' AND active = 1';
+ elseif ($mode == 2) $sql .= 'AND active = 0';
dol_syslog(get_called_class().'::getTaxCategories sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql);
@@ -144,8 +144,8 @@ class ExpenseReportIk extends CoreObject
$ranges = self::getRangesByCategory($fk_c_exp_tax_cat);
// substract 1 because array start from 0
- if (empty($ranges) || !isset($ranges[$default_range-1])) return false;
- else return $ranges[$default_range-1];
+ if (empty($ranges) || !isset($ranges[$default_range - 1])) return false;
+ else return $ranges[$default_range - 1];
}
/**
@@ -162,10 +162,10 @@ class ExpenseReportIk extends CoreObject
$ranges = array();
$sql = 'SELECT r.rowid FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
- if ($active) $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)';
- $sql.= ' WHERE r.fk_c_exp_tax_cat = '.$fk_c_exp_tax_cat;
- if ($active) $sql.= ' AND r.active = 1 AND c.active = 1';
- $sql.= ' ORDER BY r.range_ik';
+ if ($active) $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)';
+ $sql .= ' WHERE r.fk_c_exp_tax_cat = '.$fk_c_exp_tax_cat;
+ if ($active) $sql .= ' AND r.active = 1 AND c.active = 1';
+ $sql .= ' ORDER BY r.range_ik';
dol_syslog(get_called_class().'::getRangesByCategory sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql);
@@ -203,11 +203,11 @@ class ExpenseReportIk extends CoreObject
$ranges = array();
$sql = ' SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, c.label, i.rowid as fk_expense_ik, r.active as range_active, c.active as cat_active';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
- $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport_ik i ON (r.rowid = i.fk_range)';
- $sql.= ' WHERE r.entity IN (0, '. getEntity('').')';
- $sql.= ' ORDER BY r.fk_c_exp_tax_cat, r.range_ik';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
+ $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'c_exp_tax_cat c ON (r.fk_c_exp_tax_cat = c.rowid)';
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expensereport_ik i ON (r.rowid = i.fk_range)';
+ $sql .= ' WHERE r.entity IN (0, '.getEntity('').')';
+ $sql .= ' ORDER BY r.fk_c_exp_tax_cat, r.range_ik';
dol_syslog(get_called_class().'::getAllRanges sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql);
@@ -239,14 +239,14 @@ class ExpenseReportIk extends CoreObject
*/
public static function getMaxRangeNumber($default_c_exp_tax_cat = 0)
{
- global $db,$conf;
+ global $db, $conf;
$sql = 'SELECT MAX(counted) as nbRange FROM (';
- $sql.= ' SELECT COUNT(*) as counted';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
- $sql.= ' WHERE r.entity IN (0, '.$conf->entity.')';
+ $sql .= ' SELECT COUNT(*) as counted';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'c_exp_tax_range r';
+ $sql .= ' WHERE r.entity IN (0, '.$conf->entity.')';
if ($default_c_exp_tax_cat > 0) $sql .= ' AND r.fk_c_exp_tax_cat = '.$default_c_exp_tax_cat;
- $sql.= ' GROUP BY r.fk_c_exp_tax_cat';
+ $sql .= ' GROUP BY r.fk_c_exp_tax_cat';
$sql .= ') as counts';
dol_syslog(get_called_class().'::getMaxRangeNumber sql='.$sql, LOG_DEBUG);
diff --git a/htdocs/expensereport/class/expensereport_rule.class.php b/htdocs/expensereport/class/expensereport_rule.class.php
index 9726184a94a..b98552f681d 100644
--- a/htdocs/expensereport/class/expensereport_rule.class.php
+++ b/htdocs/expensereport/class/expensereport_rule.class.php
@@ -32,17 +32,17 @@ class ExpenseReportRule extends CoreObject
/**
* @var string ID to identify managed object
*/
- public $element='expenserule';
+ public $element = 'expenserule';
/**
* @var string Name of table without prefix where object is stored
*/
- public $table_element='expensereport_rules';
+ public $table_element = 'expensereport_rules';
/**
* @var int Field with ID of parent key if this field has a parent
*/
- public $fk_element='fk_expense_rule';
+ public $fk_element = 'fk_expense_rule';
/**
* date start
@@ -111,8 +111,8 @@ class ExpenseReportRule extends CoreObject
* Attribute object linked with database
* @var array
*/
- protected $fields=array(
- 'rowid'=>array('type'=>'integer','index'=>true)
+ public $fields = array(
+ 'rowid'=>array('type'=>'integer', 'index'=>true)
,'dates'=>array('type'=>'date')
,'datee'=>array('type'=>'date')
,'amount'=>array('type'=>'double')
@@ -154,25 +154,25 @@ class ExpenseReportRule extends CoreObject
$rules = array();
$sql = 'SELECT er.rowid';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_rules er';
- $sql.= ' WHERE er.entity IN (0,'. getEntity('').')';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_rules er';
+ $sql .= ' WHERE er.entity IN (0,'.getEntity('').')';
if (!empty($fk_c_type_fees))
{
- $sql.= ' AND er.fk_c_type_fees IN (-1, '.$fk_c_type_fees.')';
+ $sql .= ' AND er.fk_c_type_fees IN (-1, '.$fk_c_type_fees.')';
}
if (!empty($date))
{
$date = dol_print_date($date, '%Y-%m-%d');
- $sql.= ' AND er.dates <= \''.$date.'\'';
- $sql.= ' AND er.datee >= \''.$date.'\'';
+ $sql .= ' AND er.dates <= \''.$date.'\'';
+ $sql .= ' AND er.datee >= \''.$date.'\'';
}
if ($fk_user > 0)
{
- $sql.= ' AND (er.is_for_all = 1';
- $sql.= ' OR er.fk_user = '.$fk_user;
- $sql.= ' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.'usergroup_user ugu WHERE ugu.fk_user = '.$fk_user.') )';
+ $sql .= ' AND (er.is_for_all = 1';
+ $sql .= ' OR er.fk_user = '.$fk_user;
+ $sql .= ' OR er.fk_usergroup IN (SELECT ugu.fk_usergroup FROM '.MAIN_DB_PREFIX.'usergroup_user ugu WHERE ugu.fk_user = '.$fk_user.') )';
}
- $sql.= ' ORDER BY er.is_for_all, er.fk_usergroup, er.fk_user';
+ $sql .= ' ORDER BY er.is_for_all, er.fk_usergroup, er.fk_user';
dol_syslog("ExpenseReportRule::getAllRule sql=".$sql);
diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php
index 9c614e4953c..f400d5e4277 100644
--- a/htdocs/expensereport/class/expensereportstats.class.php
+++ b/htdocs/expensereport/class/expensereportstats.class.php
@@ -22,8 +22,8 @@
* \ingroup expensereport
* \brief Fichier de la classe de gestion des stats des expensereport et notes de frais
*/
-require_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
-require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php';
+require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
/**
* Classe permettant la gestion des stats des expensereports et notes de frais
@@ -61,29 +61,29 @@ class ExpenseReportStats extends Stats
$this->socid = $socid;
$this->userid = $userid;
- $object=new ExpenseReport($this->db);
+ $object = new ExpenseReport($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as e";
- $this->field='total_ht';
+ $this->field = 'total_ht';
//$this->where = " e.fk_statut > 0";
//$this->where.= " AND e.date_valid > '2000-01-01'"; // To filter only correct "valid date". If date is invalid, the group by on it will fails. Launch a repair.php if you have.
- $this->where.= ' e.entity IN ('.getEntity('expensereport').')';
+ $this->where .= ' e.entity IN ('.getEntity('expensereport').')';
//$this->where.= " AND entity = ".$conf->entity;
if ($this->socid)
{
- $this->where.=" AND e.fk_soc = ".$this->socid;
+ $this->where .= " AND e.fk_soc = ".$this->socid;
}
// Only me and subordinates
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous))
{
$childids = $user->getAllChildIds();
- $childids[]=$user->id;
- $this->where.=" AND e.fk_user_author IN (".(join(',', $childids)).")";
+ $childids[] = $user->id;
+ $this->where .= " AND e.fk_user_author IN (".(join(',', $childids)).")";
}
- if ($this->userid > 0) $this->where.=' AND e.fk_user_author = '.$this->userid;
+ if ($this->userid > 0) $this->where .= ' AND e.fk_user_author = '.$this->userid;
}
@@ -95,9 +95,9 @@ class ExpenseReportStats extends Stats
public function getNbByYear()
{
$sql = "SELECT YEAR(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).") as dm, count(*)";
- $sql.= " FROM ".$this->from;
- $sql.= " GROUP BY dm DESC";
- $sql.= " WHERE ".$this->where;
+ $sql .= " FROM ".$this->from;
+ $sql .= " GROUP BY dm DESC";
+ $sql .= " WHERE ".$this->where;
return $this->_getNbByYear($sql);
}
@@ -113,13 +113,13 @@ class ExpenseReportStats extends Stats
public function getNbByMonth($year, $format = 0)
{
$sql = "SELECT MONTH(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).") as dm, count(*)";
- $sql.= " FROM ".$this->from;
- $sql.= " WHERE YEAR(e.".$this->datetouse.") = ".$year;
- $sql.= " AND ".$this->where;
- $sql.= " GROUP BY dm";
- $sql.= $this->db->order('dm', 'DESC');
+ $sql .= " FROM ".$this->from;
+ $sql .= " WHERE YEAR(e.".$this->datetouse.") = ".$year;
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
- $res=$this->_getNbByMonth($year, $sql, $format);
+ $res = $this->_getNbByMonth($year, $sql, $format);
//var_dump($res);print ' ';
return $res;
}
@@ -135,13 +135,13 @@ class ExpenseReportStats extends Stats
public function getAmountByMonth($year, $format = 0)
{
$sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%m') as dm, sum(".$this->field.")";
- $sql.= " FROM ".$this->from;
- $sql.= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'";
- $sql.= " AND ".$this->where;
- $sql.= " GROUP BY dm";
- $sql.= $this->db->order('dm', 'DESC');
+ $sql .= " FROM ".$this->from;
+ $sql .= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'";
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
- $res=$this->_getAmountByMonth($year, $sql, $format);
+ $res = $this->_getAmountByMonth($year, $sql, $format);
//var_dump($res);print ' ';
return $res;
}
@@ -155,11 +155,11 @@ class ExpenseReportStats extends Stats
public function getAverageByMonth($year)
{
$sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%m') as dm, avg(".$this->field.")";
- $sql.= " FROM ".$this->from;
- $sql.= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'";
- $sql.= " AND ".$this->where;
- $sql.= " GROUP BY dm";
- $sql.= $this->db->order('dm', 'DESC');
+ $sql .= " FROM ".$this->from;
+ $sql .= " WHERE date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') = '".$year."'";
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
return $this->_getAverageByMonth($year, $sql);
}
@@ -172,10 +172,10 @@ class ExpenseReportStats extends Stats
public function getAllByYear()
{
$sql = "SELECT date_format(".$this->db->ifsql('e.'.$this->datetouse.' IS NULL', 'e.date_create', 'e.'.$this->datetouse).",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
- $sql.= " FROM ".$this->from;
- $sql.= " WHERE ".$this->where;
- $sql.= " GROUP BY year";
- $sql.= $this->db->order('year', 'DESC');
+ $sql .= " FROM ".$this->from;
+ $sql .= " WHERE ".$this->where;
+ $sql .= " GROUP BY year";
+ $sql .= $this->db->order('year', 'DESC');
return $this->_getAllByYear($sql);
}
diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php
index 06813b03ae5..bf00027b58a 100644
--- a/htdocs/exports/class/export.class.php
+++ b/htdocs/exports/class/export.class.php
@@ -35,27 +35,27 @@ class Export
*/
public $db;
- public $array_export_code=array(); // Tableau de "idmodule_numlot"
- public $array_export_module=array(); // Tableau de "nom de modules"
- public $array_export_label=array(); // Tableau de "libelle de lots"
- public $array_export_sql_start=array(); // Tableau des "requetes sql"
- public $array_export_sql_end=array(); // Tableau des "requetes sql"
- public $array_export_sql_order=array(); // Tableau des "requetes sql"
+ public $array_export_code = array(); // Tableau de "idmodule_numlot"
+ public $array_export_module = array(); // Tableau de "nom de modules"
+ public $array_export_label = array(); // Tableau de "libelle de lots"
+ public $array_export_sql_start = array(); // Tableau des "requetes sql"
+ public $array_export_sql_end = array(); // Tableau des "requetes sql"
+ public $array_export_sql_order = array(); // Tableau des "requetes sql"
- public $array_export_fields=array(); // Tableau des listes de champ+libelle a exporter
- public $array_export_TypeFields=array(); // Tableau des listes de champ+Type de filtre
- public $array_export_FilterValue=array(); // Tableau des listes de champ+Valeur a filtrer
- public $array_export_entities=array(); // Tableau des listes de champ+alias a exporter
- public $array_export_dependencies=array(); // array of list of entities that must take care of the DISTINCT if a field is added into export
- public $array_export_special=array(); // array of special operations to do on field
- public $array_export_examplevalues=array(); // array with examples for fields
- public $array_export_help=array(); // array with tooltip help for fields
+ public $array_export_fields = array(); // Tableau des listes de champ+libelle a exporter
+ public $array_export_TypeFields = array(); // Tableau des listes de champ+Type de filtre
+ public $array_export_FilterValue = array(); // Tableau des listes de champ+Valeur a filtrer
+ public $array_export_entities = array(); // Tableau des listes de champ+alias a exporter
+ public $array_export_dependencies = array(); // array of list of entities that must take care of the DISTINCT if a field is added into export
+ public $array_export_special = array(); // array of special operations to do on field
+ public $array_export_examplevalues = array(); // array with examples for fields
+ public $array_export_help = array(); // array with tooltip help for fields
// To store export modules
- public $hexa; // List of fields in the export profile
- public $hexafiltervalue; // List of search criteria in the export profile
+ public $hexa; // List of fields in the export profile
+ public $hexafiltervalue; // List of search criteria in the export profile
public $datatoexport;
- public $model_name; // Name of export profile
+ public $model_name; // Name of export profile
public $sqlusedforexport;
@@ -67,7 +67,7 @@ class Export
*/
public function __construct($db)
{
- $this->db=$db;
+ $this->db = $db;
}
@@ -82,35 +82,35 @@ class Export
public function load_arrays($user, $filter = '')
{
// phpcs:enable
- global $langs,$conf,$mysoc;
+ global $langs, $conf, $mysoc;
dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter);
- $i=0;
+ $i = 0;
// Define list of modules directories into modulesdir
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$modulesdir = dolGetModulesDirs();
- foreach($modulesdir as $dir)
+ foreach ($modulesdir as $dir)
{
// Search available exports
- $handle=@opendir(dol_osencode($dir));
+ $handle = @opendir(dol_osencode($dir));
if (is_resource($handle))
{
// Search module files
- while (($file = readdir($handle))!==false)
+ while (($file = readdir($handle)) !== false)
{
if (is_readable($dir.$file) && preg_match("/^(mod.*)\.class\.php$/i", $file, $reg))
{
- $modulename=$reg[1];
+ $modulename = $reg[1];
// Defined if module is enabled
- $enabled=true;
- $part=strtolower(preg_replace('/^mod/i', '', $modulename));
- if ($part == 'propale') $part='propal';
- if (empty($conf->$part->enabled)) $enabled=false;
+ $enabled = true;
+ $part = strtolower(preg_replace('/^mod/i', '', $modulename));
+ if ($part == 'propale') $part = 'propal';
+ if (empty($conf->$part->enabled)) $enabled = false;
if ($enabled)
{
@@ -122,32 +122,32 @@ class Export
if (isset($module->export_code) && is_array($module->export_code))
{
- foreach($module->export_code as $r => $value)
+ foreach ($module->export_code as $r => $value)
{
//print $i.'-'.$filter.'-'.$modulename.'-'.join(',',$module->export_code).' ';
if ($filter && ($filter != $module->export_code[$r])) continue;
// Test if condition to show are ok
- if (! empty($module->export_enabled[$r]) && ! verifCond($module->export_enabled[$r])) continue;
+ if (!empty($module->export_enabled[$r]) && !verifCond($module->export_enabled[$r])) continue;
// Test if permissions are ok
- $bool=true;
+ $bool = true;
if (isset($module->export_permission))
{
- foreach($module->export_permission[$r] as $val)
+ foreach ($module->export_permission[$r] as $val)
{
- $perm=$val;
+ $perm = $val;
//print_r("$perm[0]-$perm[1]-$perm[2] ");
- if (! empty($perm[2]))
+ if (!empty($perm[2]))
{
- $bool=$user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]};
+ $bool = $user->rights->{$perm[0]}->{$perm[1]}->{$perm[2]};
}
else
{
- $bool=$user->rights->{$perm[0]}->{$perm[1]};
+ $bool = $user->rights->{$perm[0]}->{$perm[1]};
}
- if ($perm[0]=='user' && $user->admin) $bool=true;
- if (! $bool) break;
+ if ($perm[0] == 'user' && $user->admin) $bool = true;
+ if (!$bool) break;
}
}
//print $bool." $perm[0]"." ";
@@ -156,47 +156,47 @@ class Export
// if ($bool)
// {
// Charge fichier lang en rapport
- $langtoload=$module->getLangFilesArray();
+ $langtoload = $module->getLangFilesArray();
if (is_array($langtoload))
{
- foreach($langtoload as $key)
+ foreach ($langtoload as $key)
{
$langs->load($key);
}
}
// Module
- $this->array_export_module[$i]=$module;
+ $this->array_export_module[$i] = $module;
// Permission
- $this->array_export_perms[$i]=$bool;
+ $this->array_export_perms[$i] = $bool;
// Icon
- $this->array_export_icon[$i]=(isset($module->export_icon[$r])?$module->export_icon[$r]:$module->picto);
+ $this->array_export_icon[$i] = (isset($module->export_icon[$r]) ? $module->export_icon[$r] : $module->picto);
// Code du dataset export
- $this->array_export_code[$i]=$module->export_code[$r];
+ $this->array_export_code[$i] = $module->export_code[$r];
// Libelle du dataset export
- $this->array_export_label[$i]=$module->getExportDatasetLabel($r);
+ $this->array_export_label[$i] = $module->getExportDatasetLabel($r);
// Tableau des champ a exporter (cle=champ, valeur=libelle)
- $this->array_export_fields[$i]=$module->export_fields_array[$r];
+ $this->array_export_fields[$i] = $module->export_fields_array[$r];
// Tableau des champs a filtrer (cle=champ, valeur1=type de donnees) on verifie que le module a des filtres
- $this->array_export_TypeFields[$i]=(isset($module->export_TypeFields_array[$r])?$module->export_TypeFields_array[$r]:'');
+ $this->array_export_TypeFields[$i] = (isset($module->export_TypeFields_array[$r]) ? $module->export_TypeFields_array[$r] : '');
// Tableau des entites a exporter (cle=champ, valeur=entite)
- $this->array_export_entities[$i]=$module->export_entities_array[$r];
+ $this->array_export_entities[$i] = $module->export_entities_array[$r];
// Tableau des entites qui requiert abandon du DISTINCT (cle=entite, valeur=champ id child records)
- $this->array_export_dependencies[$i]=(! empty($module->export_dependencies_array[$r])?$module->export_dependencies_array[$r]:'');
+ $this->array_export_dependencies[$i] = (!empty($module->export_dependencies_array[$r]) ? $module->export_dependencies_array[$r] : '');
// Tableau des operations speciales sur champ
- $this->array_export_special[$i]=(! empty($module->export_special_array[$r])?$module->export_special_array[$r]:'');
+ $this->array_export_special[$i] = (!empty($module->export_special_array[$r]) ? $module->export_special_array[$r] : '');
// Array of examples
- $this->array_export_examplevalues[$i]=$module->export_examplevalues_array[$r];
+ $this->array_export_examplevalues[$i] = $module->export_examplevalues_array[$r];
// Array of help tooltips
- $this->array_export_help[$i]=(! empty($module->export_help_array[$r])?$module->export_help_array[$r]:'');
+ $this->array_export_help[$i] = (!empty($module->export_help_array[$r]) ? $module->export_help_array[$r] : '');
// Requete sql du dataset
- $this->array_export_sql_start[$i]=$module->export_sql_start[$r];
- $this->array_export_sql_end[$i]=$module->export_sql_end[$r];
- $this->array_export_sql_order[$i]=$module->export_sql_order[$r];
+ $this->array_export_sql_start[$i] = $module->export_sql_start[$r];
+ $this->array_export_sql_end[$i] = $module->export_sql_end[$r];
+ $this->array_export_sql_order[$i] = $module->export_sql_order[$r];
//$this->array_export_sql[$i]=$module->export_sql[$r];
- dol_syslog(get_class($this)."::load_arrays loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".(! empty($module->export_fields_code[$r])?count($module->export_fields_code[$r]):''));
+ dol_syslog(get_class($this)."::load_arrays loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".(!empty($module->export_fields_code[$r]) ?count($module->export_fields_code[$r]) : ''));
$i++;
// }
}
@@ -226,42 +226,42 @@ class Export
{
// phpcs:enable
// Build the sql request
- $sql=$this->array_export_sql_start[$indice];
- $i=0;
+ $sql = $this->array_export_sql_start[$indice];
+ $i = 0;
//print_r($array_selected);
foreach ($this->array_export_fields[$indice] as $key => $value)
{
- if (! array_key_exists($key, $array_selected)) continue; // Field not selected
- if (preg_match('/^none\./', $key)) continue; // A field that must not appears into SQL
- if ($i > 0) $sql.=', ';
+ if (!array_key_exists($key, $array_selected)) continue; // Field not selected
+ if (preg_match('/^none\./', $key)) continue; // A field that must not appears into SQL
+ if ($i > 0) $sql .= ', ';
else $i++;
- if (strpos($key, ' as ')===false) {
- $newfield=$key.' as '.str_replace(array('.', '-','(',')'), '_', $key);
+ if (strpos($key, ' as ') === false) {
+ $newfield = $key.' as '.str_replace(array('.', '-', '(', ')'), '_', $key);
} else {
- $newfield=$key;
+ $newfield = $key;
}
- $sql.=$newfield;
+ $sql .= $newfield;
}
- $sql.=$this->array_export_sql_end[$indice];
+ $sql .= $this->array_export_sql_end[$indice];
// Add the WHERE part. Filtering into sql if a filtering array is provided
if (is_array($array_filterValue) && !empty($array_filterValue))
{
- $sqlWhere='';
+ $sqlWhere = '';
// Loop on each condition to add
foreach ($array_filterValue as $key => $value)
{
if (preg_match('/GROUP_CONCAT/i', $key)) continue;
- if ($value != '') $sqlWhere.=" and ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
+ if ($value != '') $sqlWhere .= " and ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
}
- $sql.=$sqlWhere;
+ $sql .= $sqlWhere;
}
// Add the order
- $sql.=$this->array_export_sql_order[$indice];
+ $sql .= $this->array_export_sql_order[$indice];
// Add the HAVING part.
if (is_array($array_filterValue) && !empty($array_filterValue))
@@ -269,7 +269,7 @@ class Export
// Loop on each condition to add
foreach ($array_filterValue as $key => $value)
{
- if (preg_match('/GROUP_CONCAT/i', $key) and $value != '') $sql.=" HAVING ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
+ if (preg_match('/GROUP_CONCAT/i', $key) and $value != '') $sql .= " HAVING ".$this->build_filterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
}
}
@@ -293,25 +293,25 @@ class Export
// build the input field on depend of the type of file
switch ($InfoFieldList[0]) {
case 'Text':
- if (! (strpos($ValueField, '%') === false))
- $szFilterQuery.=" ".$NameField." LIKE '".$ValueField."'";
+ if (!(strpos($ValueField, '%') === false))
+ $szFilterQuery .= " ".$NameField." LIKE '".$ValueField."'";
else
- $szFilterQuery.=" ".$NameField." = '".$ValueField."'";
+ $szFilterQuery .= " ".$NameField." = '".$ValueField."'";
break;
case 'Date':
if (strpos($ValueField, "+") > 0)
{
// mode plage
$ValueArray = explode("+", $ValueField);
- $szFilterQuery ="(".$this->conditionDate($NameField, trim($ValueArray[0]), ">=");
- $szFilterQuery.=" AND ".$this->conditionDate($NameField, trim($ValueArray[1]), "<=").")";
+ $szFilterQuery = "(".$this->conditionDate($NameField, trim($ValueArray[0]), ">=");
+ $szFilterQuery .= " AND ".$this->conditionDate($NameField, trim($ValueArray[1]), "<=").")";
}
else
{
if (is_numeric(substr($ValueField, 0, 1)))
- $szFilterQuery=$this->conditionDate($NameField, trim($ValueField), "=");
+ $szFilterQuery = $this->conditionDate($NameField, trim($ValueField), "=");
else
- $szFilterQuery=$this->conditionDate($NameField, trim(substr($ValueField, 1)), substr($ValueField, 0, 1));
+ $szFilterQuery = $this->conditionDate($NameField, trim(substr($ValueField, 1)), substr($ValueField, 0, 1));
}
break;
case 'Duree':
@@ -322,29 +322,29 @@ class Export
{
// mode plage
$ValueArray = explode("+", $ValueField);
- $szFilterQuery ="(".$NameField.">=".$ValueArray[0];
- $szFilterQuery.=" AND ".$NameField."<=".$ValueArray[1].")";
+ $szFilterQuery = "(".$NameField.">=".$ValueArray[0];
+ $szFilterQuery .= " AND ".$NameField."<=".$ValueArray[1].")";
}
else
{
if (is_numeric(substr($ValueField, 0, 1)))
- $szFilterQuery=" ".$NameField."=".$ValueField;
+ $szFilterQuery = " ".$NameField."=".$ValueField;
else
- $szFilterQuery=" ".$NameField.substr($ValueField, 0, 1).substr($ValueField, 1);
+ $szFilterQuery = " ".$NameField.substr($ValueField, 0, 1).substr($ValueField, 1);
}
break;
case 'Boolean':
- $szFilterQuery=" ".$NameField."=".(is_numeric($ValueField) ? $ValueField : ($ValueField =='yes' ? 1: 0) );
+ $szFilterQuery = " ".$NameField."=".(is_numeric($ValueField) ? $ValueField : ($ValueField == 'yes' ? 1 : 0));
break;
case 'Status':
case 'List':
if (is_numeric($ValueField))
- $szFilterQuery=" ".$NameField."=".$ValueField;
+ $szFilterQuery = " ".$NameField."=".$ValueField;
else {
- if (! (strpos($ValueField, '%') === false))
- $szFilterQuery=" ".$NameField." LIKE '".$ValueField."'";
+ if (!(strpos($ValueField, '%') === false))
+ $szFilterQuery = " ".$NameField." LIKE '".$ValueField."'";
else
- $szFilterQuery=" ".$NameField." = '".$ValueField."'";
+ $szFilterQuery = " ".$NameField." = '".$ValueField."'";
}
break;
default:
@@ -365,9 +365,9 @@ class Export
public function conditionDate($Field, $Value, $Sens)
{
// TODO date_format is forbidden, not performant and not portable. Use instead BETWEEN
- if (strlen($Value)==4) $Condition=" date_format(".$Field.",'%Y') ".$Sens." '".$Value."'";
- elseif (strlen($Value)==6) $Condition=" date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'";
- else $Condition=" date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value;
+ if (strlen($Value) == 4) $Condition = " date_format(".$Field.",'%Y') ".$Sens." '".$Value."'";
+ elseif (strlen($Value) == 6) $Condition = " date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'";
+ else $Condition = " date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value;
return $Condition;
}
@@ -383,9 +383,9 @@ class Export
public function build_filterField($TypeField, $NameField, $ValueField)
{
// phpcs:enable
- global $conf,$langs;
+ global $conf, $langs;
- $szFilterField='';
+ $szFilterField = '';
$InfoFieldList = explode(":", $TypeField);
// build the input field on depend of the type of file
@@ -393,31 +393,31 @@ class Export
{
case 'Text':
case 'Date':
- $szFilterField=' ';
+ $szFilterField = ' ';
break;
case 'Duree':
case 'Numeric':
case 'Number':
// Must be a string text to allow to use comparison strings like "<= 999"
- $szFilterField=' ';
+ $szFilterField = ' ';
break;
case 'Status':
- $szFilterField=' ';
+ $szFilterField = ' ';
break;
case 'Boolean':
- $szFilterField='';
- $szFilterField.=' ';
+ $szFilterField = '';
+ $szFilterField .= ''.yn(1).' ';
+ $szFilterField .= '';
- $szFilterField.=' '.yn(0).' ';
- $szFilterField.=" ";
+ $szFilterField .= '';
+ $szFilterField .= " ";
break;
case 'List':
// 0 : Type du champ
@@ -426,23 +426,23 @@ class Export
// 3 : Name of field with key (if it is not "rowid"). Used this field as key for combo list.
// 4 : Name of element for getEntity().
- if (! empty($InfoFieldList[3]))
- $keyList=$InfoFieldList[3];
+ if (!empty($InfoFieldList[3]))
+ $keyList = $InfoFieldList[3];
else
- $keyList='rowid';
- $sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3])?'':', '.$InfoFieldList[3].' as code');
- if ($InfoFieldList[1] == 'c_stcomm') $sql = 'SELECT id as id, '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3])?'':', '.$InfoFieldList[3].' as code');
+ $keyList = 'rowid';
+ $sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code');
+ if ($InfoFieldList[1] == 'c_stcomm') $sql = 'SELECT id as id, '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3]) ? '' : ', '.$InfoFieldList[3].' as code');
if ($InfoFieldList[1] == 'c_country') $sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label, code as code';
- $sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[1];
- if (! empty($InfoFieldList[4])) {
- $sql.= ' WHERE entity IN ('.getEntity($InfoFieldList[4]).')';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[1];
+ if (!empty($InfoFieldList[4])) {
+ $sql .= ' WHERE entity IN ('.getEntity($InfoFieldList[4]).')';
}
$resql = $this->db->query($sql);
if ($resql)
{
- $szFilterField='';
- $szFilterField.=' ';
+ $szFilterField = '';
+ $szFilterField .= ' ';
$num = $this->db->num_rows($resql);
$i = 0;
@@ -458,30 +458,30 @@ class Export
continue;
}
//var_dump($InfoFieldList[1]);
- $labeltoshow=dol_trunc($obj->label, 18);
+ $labeltoshow = dol_trunc($obj->label, 18);
if ($InfoFieldList[1] == 'c_stcomm')
{
$langs->load("companies");
- $labeltoshow=(($langs->trans("StatusProspect".$obj->id) != "StatusProspect".$obj->id)?$langs->trans("StatusProspect".$obj->id):$obj->label);
+ $labeltoshow = (($langs->trans("StatusProspect".$obj->id) != "StatusProspect".$obj->id) ? $langs->trans("StatusProspect".$obj->id) : $obj->label);
}
if ($InfoFieldList[1] == 'c_country')
{
//var_dump($sql);
$langs->load("dict");
- $labeltoshow=(($langs->trans("Country".$obj->code) != "Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label);
+ $labeltoshow = (($langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->label);
}
if (!empty($ValueField) && $ValueField == $obj->rowid)
{
- $szFilterField.=''.$labeltoshow.' ';
+ $szFilterField .= ''.$labeltoshow.' ';
}
else
{
- $szFilterField.=''.$labeltoshow.' ';
+ $szFilterField .= ''.$labeltoshow.' ';
}
$i++;
}
}
- $szFilterField.=" ";
+ $szFilterField .= " ";
$this->db->free($resql);
}
@@ -502,12 +502,12 @@ class Export
{
global $langs;
- $szMsg='';
+ $szMsg = '';
$InfoFieldList = explode(":", $TypeField);
// build the input field on depend of the type of file
switch ($InfoFieldList[0]) {
case 'Text':
- $szMsg= $langs->trans('ExportStringFilter');
+ $szMsg = $langs->trans('ExportStringFilter');
break;
case 'Date':
$szMsg = $langs->trans('ExportDateFilter');
@@ -542,37 +542,37 @@ class Export
public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '')
{
// phpcs:enable
- global $conf,$langs,$mysoc;
+ global $conf, $langs, $mysoc;
- $indice=0;
+ $indice = 0;
asort($array_selected);
- dol_syslog(get_class($this)."::".__FUNCTION__." ".$model.", ".$datatoexport.", ".implode(",", $array_selected));
+ dol_syslog(__METHOD__." ".$model.", ".$datatoexport.", ".implode(",", $array_selected));
// Check parameters or context properties
- if (empty($this->array_export_fields) || ! is_array($this->array_export_fields))
+ if (empty($this->array_export_fields) || !is_array($this->array_export_fields))
{
- $this->error="ErrorBadParameter";
+ $this->error = "ErrorBadParameter";
return -1;
}
// Creation of class to export using model ExportXXX
- $dir = DOL_DOCUMENT_ROOT . "/core/modules/export/";
+ $dir = DOL_DOCUMENT_ROOT."/core/modules/export/";
$file = "export_".$model.".modules.php";
$classname = "Export".$model;
require_once $dir.$file;
$objmodel = new $classname($this->db);
- if (! empty($sqlquery)) $sql = $sqlquery;
+ if (!empty($sqlquery)) $sql = $sqlquery;
else
{
// Define value for indice from $datatoexport
- $foundindice=0;
- foreach($this->array_export_code as $key => $dataset)
+ $foundindice = 0;
+ foreach ($this->array_export_code as $key => $dataset)
{
if ($datatoexport == $dataset)
{
- $indice=$key;
+ $indice = $key;
$foundindice++;
//print "Found indice = ".$indice." for dataset=".$datatoexport."\n";
break;
@@ -580,31 +580,31 @@ class Export
}
if (empty($foundindice))
{
- $this->error="ErrorBadParameter can't find dataset ".$datatoexport." into preload arrays this->array_export_code";
+ $this->error = "ErrorBadParameter can't find dataset ".$datatoexport." into preload arrays this->array_export_code";
return -1;
}
- $sql=$this->build_sql($indice, $array_selected, $array_filterValue);
+ $sql = $this->build_sql($indice, $array_selected, $array_filterValue);
}
// Run the sql
- $this->sqlusedforexport=$sql;
- dol_syslog(get_class($this)."::".__FUNCTION__."", LOG_DEBUG);
+ $this->sqlusedforexport = $sql;
+ dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
//$this->array_export_label[$indice]
if ($conf->global->EXPORT_PREFIX_SPEC)
- $filename=$conf->global->EXPORT_PREFIX_SPEC."_".$datatoexport;
+ $filename = $conf->global->EXPORT_PREFIX_SPEC."_".$datatoexport;
else
- $filename="export_".$datatoexport;
- $filename.='.'.$objmodel->getDriverExtension();
- $dirname=$conf->export->dir_temp.'/'.$user->id;
+ $filename = "export_".$datatoexport;
+ $filename .= '.'.$objmodel->getDriverExtension();
+ $dirname = $conf->export->dir_temp.'/'.$user->id;
$outputlangs = clone $langs; // We clone to have an object we can modify (for example to change output charset by csv handler) without changing original value
// Open file
dol_mkdir($dirname);
- $result=$objmodel->open_file($dirname."/".$filename, $outputlangs);
+ $result = $objmodel->open_file($dirname."/".$filename, $outputlangs);
if ($result >= 0)
{
@@ -617,61 +617,62 @@ class Export
while ($obj = $this->db->fetch_object($resql))
{
// Process special operations
- if (! empty($this->array_export_special[$indice]))
+ if (!empty($this->array_export_special[$indice]))
{
foreach ($this->array_export_special[$indice] as $key => $value)
{
- if (! array_key_exists($key, $array_selected)) continue; // Field not selected
+ if (!array_key_exists($key, $array_selected)) continue; // Field not selected
// Operation NULLIFNEG
- if ($this->array_export_special[$indice][$key]=='NULLIFNEG')
+ if ($this->array_export_special[$indice][$key] == 'NULLIFNEG')
{
//$alias=$this->array_export_alias[$indice][$key];
- $alias=str_replace(array('.', '-','(',')'), '_', $key);
- if ($obj->$alias < 0) $obj->$alias='';
+ $alias = str_replace(array('.', '-', '(', ')'), '_', $key);
+ if ($obj->$alias < 0) $obj->$alias = '';
}
// Operation ZEROIFNEG
- elseif ($this->array_export_special[$indice][$key]=='ZEROIFNEG')
+ elseif ($this->array_export_special[$indice][$key] == 'ZEROIFNEG')
{
//$alias=$this->array_export_alias[$indice][$key];
- $alias=str_replace(array('.', '-','(',')'), '_', $key);
- if ($obj->$alias < 0) $obj->$alias='0';
+ $alias = str_replace(array('.', '-', '(', ')'), '_', $key);
+ if ($obj->$alias < 0) $obj->$alias = '0';
}
// Operation GETNUMOPENDAYS (for Holiday module)
- elseif ($this->array_export_special[$indice][$key]=='getNumOpenDays')
+ elseif ($this->array_export_special[$indice][$key] == 'getNumOpenDays')
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
//$alias=$this->array_export_alias[$indice][$key];
- $alias=str_replace(array('.', '-','(',')'), '_', $key);
- $obj->$alias=num_open_day(dol_stringtotime($obj->d_date_debut, 1), dol_stringtotime($obj->d_date_fin, 1), 0, 1, $obj->d_halfday, $mysoc->country_code);
+ $alias = str_replace(array('.', '-', '(', ')'), '_', $key);
+ $obj->$alias = num_open_day(dol_stringtotime($obj->d_date_debut, 1), dol_stringtotime($obj->d_date_fin, 1), 0, 1, $obj->d_halfday, $mysoc->country_code);
}
// Operation INVOICEREMAINTOPAY
- elseif ($this->array_export_special[$indice][$key]=='getRemainToPay')
+ elseif ($this->array_export_special[$indice][$key] == 'getRemainToPay')
{
//$alias=$this->array_export_alias[$indice][$key];
- $alias=str_replace(array('.', '-','(',')'), '_', $key);
- $remaintopay='';
+ $alias = str_replace(array('.', '-', '(', ')'), '_', $key);
+ $remaintopay = '';
if ($obj->f_rowid > 0)
{
global $tmpobjforcomputecall;
- if (! is_object($tmpobjforcomputecall))
+ if (!is_object($tmpobjforcomputecall))
{
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
- $tmpobjforcomputecall=new Facture($this->db);
+ $tmpobjforcomputecall = new Facture($this->db);
}
$tmpobjforcomputecall->id = $obj->f_rowid;
$tmpobjforcomputecall->total_ttc = $obj->f_total_ttc;
- $remaintopay=$tmpobjforcomputecall->getRemainToPay();
+ $tmpobjforcomputecall->close_code = $obj->f_close_code;
+ $remaintopay = $tmpobjforcomputecall->getRemainToPay();
}
- $obj->$alias=$remaintopay;
+ $obj->$alias = $remaintopay;
}
else
{
// TODO FIXME Export of compute field does not work. $obj containt $obj->alias_field and formulat will contains $obj->field
- $computestring=$this->array_export_special[$indice][$key];
- $tmp=dol_eval($computestring, 1, 0);
- $obj->$alias=$tmp;
+ $computestring = $this->array_export_special[$indice][$key];
+ $tmp = dol_eval($computestring, 1, 0);
+ $obj->$alias = $tmp;
- $this->error="ERROPNOTSUPPORTED. Operation ".$this->array_export_special[$indice][$key]." not supported. Export of 'computed' extrafields is not yet supported, please remove field.";
+ $this->error = "ERROPNOTSUPPORTED. Operation ".$this->array_export_special[$indice][$key]." not supported. Export of 'computed' extrafields is not yet supported, please remove field.";
return -1;
}
}
@@ -690,14 +691,14 @@ class Export
}
else
{
- $this->error=$objmodel->error;
+ $this->error = $objmodel->error;
dol_syslog("Export::build_file Error: ".$this->error, LOG_ERR);
return -1;
}
}
else
{
- $this->error=$this->db->error()." - sql=".$sql;
+ $this->error = $this->db->error()." - sql=".$sql;
return -1;
}
}
@@ -716,24 +717,24 @@ class Export
$this->db->begin();
- $filter='';
+ $filter = '';
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'export_model (';
- $sql.= 'label,';
- $sql.= 'type,';
- $sql.= 'field,';
- $sql.= 'fk_user,';
- $sql.= 'filter';
- $sql.= ') VALUES (';
- $sql.= "'".$this->db->escape($this->model_name)."',";
- $sql.= "'".$this->db->escape($this->datatoexport)."',";
- $sql.= "'".$this->db->escape($this->hexa)."',";
- $sql.= "'".$user->id."',";
- $sql.= "'".$this->db->escape($this->hexafiltervalue)."'";
- $sql.= ")";
+ $sql .= 'label,';
+ $sql .= 'type,';
+ $sql .= 'field,';
+ $sql .= 'fk_user,';
+ $sql .= 'filter';
+ $sql .= ') VALUES (';
+ $sql .= "'".$this->db->escape($this->model_name)."',";
+ $sql .= "'".$this->db->escape($this->datatoexport)."',";
+ $sql .= "'".$this->db->escape($this->hexa)."',";
+ $sql .= "'".$user->id."',";
+ $sql .= "'".$this->db->escape($this->hexafiltervalue)."'";
+ $sql .= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql)
{
$this->db->commit();
@@ -741,8 +742,8 @@ class Export
}
else
{
- $this->error=$this->db->lasterror();
- $this->errno=$this->db->lasterrno();
+ $this->error = $this->db->lasterror();
+ $this->errno = $this->db->lasterrno();
$this->db->rollback();
return -1;
}
@@ -757,8 +758,8 @@ class Export
public function fetch($id)
{
$sql = 'SELECT em.rowid, em.label, em.type, em.field, em.filter';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'export_model as em';
- $sql.= ' WHERE em.rowid = '.$id;
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'export_model as em';
+ $sql .= ' WHERE em.rowid = '.$id;
dol_syslog("Export::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
@@ -778,7 +779,7 @@ class Export
}
else
{
- $this->error="ModelNotFound";
+ $this->error = "ModelNotFound";
return -2;
}
}
@@ -800,20 +801,20 @@ class Export
public function delete($user, $notrigger = 0)
{
global $conf, $langs;
- $error=0;
+ $error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."export_model";
- $sql.= " WHERE rowid=".$this->id;
+ $sql .= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+ if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
- if (! $error)
+ if (!$error)
{
- if (! $notrigger)
+ if (!$notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
@@ -830,13 +831,13 @@ class Export
// Commit or rollback
if ($error)
{
- foreach($this->errors as $errmsg)
+ foreach ($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
+ $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
$this->db->rollback();
- return -1*$error;
+ return -1 * $error;
}
else
{
@@ -858,8 +859,8 @@ class Export
global $conf, $langs;
$sql = "SELECT em.rowid, em.field, em.label, em.type, em.filter";
- $sql.= " FROM ".MAIN_DB_PREFIX."export_model as em";
- $sql.= " ORDER BY rowid";
+ $sql .= " FROM ".MAIN_DB_PREFIX."export_model as em";
+ $sql .= " ORDER BY rowid";
$result = $this->db->query($sql);
if ($result)
@@ -877,12 +878,12 @@ class Export
print $this->array_export_module[$keyModel]->getName().' - ';
// recuperation du nom de l'export
- $string=$langs->trans($this->array_export_label[$keyModel]);
- print ($string!=$this->array_export_label[$keyModel]?$string:$this->array_export_label[$keyModel]);
+ $string = $langs->trans($this->array_export_label[$keyModel]);
+ print ($string != $this->array_export_label[$keyModel] ? $string : $this->array_export_label[$keyModel]);
print '';
//print ''.$obj->type.$keyModel.' ';
print ''.str_replace(',', ' , ', $obj->field).' ';
- if (! empty($obj->filter)) {
+ if (!empty($obj->filter)) {
$filter = json_decode($obj->filter, true);
print ''.str_replace(',', ' , ', $filter['field']).' ';
print ''.str_replace(',', ' , ', $filter['value']).' ';
diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php
index ffbed97a75c..6543747d1f7 100644
--- a/htdocs/exports/export.php
+++ b/htdocs/exports/export.php
@@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Load translation files required by the page
-$langs->loadlangs(array('admin', 'exports', 'other', 'users', 'companies', 'projects', 'suppliers', 'products', 'bank'));
+$langs->loadlangs(array('admin', 'exports', 'other', 'users', 'companies', 'projects', 'suppliers', 'products', 'bank', 'bills'));
// Everybody should be able to go on this page
//if (! $user->admin)
@@ -147,6 +147,7 @@ $htmlother = new FormOther($db);
$formfile = new FormFile($db);
$sqlusedforexport = '';
+$head = array();
$upload_dir = $conf->export->dir_temp.'/'.$user->id;
//$usefilters=($conf->global->MAIN_FEATURES_LEVEL > 1);
@@ -379,7 +380,7 @@ if ($step == 2 && $action == 'select_model')
{
$fieldsarray = preg_split("/,(?! [^(]*\))/", $objexport->hexa);
$i = 1;
- foreach($fieldsarray as $val)
+ foreach ($fieldsarray as $val)
{
$array_selected[$val] = $i;
$i++;
@@ -410,12 +411,12 @@ if ($step == 4 && $action == 'submitFormField')
$newcode = (string) preg_replace('/\./', '_', $code);
//print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n ";
$filterqualified = 1;
- if (!isset($_POST[$newcode]) || $_POST[$newcode] == '') $filterqualified = 0;
- elseif (preg_match('/^List/', $type) && (is_numeric($_POST[$newcode]) && $_POST[$newcode] <= 0)) $filterqualified = 0;
+ if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'restricthtml') == '') $filterqualified = 0;
+ elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'restricthtml')) && GETPOST($newcode, 'restricthtml') <= 0)) $filterqualified = 0;
if ($filterqualified)
{
//print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n";
- $objexport->array_export_FilterValue[0][$code] = $_POST[$newcode];
+ $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'restricthtml');
}
}
$array_filtervalue = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] : '');
@@ -938,7 +939,7 @@ if ($step == 4 && $datatoexport)
// List of filtered fiels
if (isset($objexport->array_export_TypeFields[0]) && is_array($objexport->array_export_TypeFields[0]))
{
- print ''.$langs->trans("FilteredFields").' ';
+ print ''.$langs->trans("FilteredFields").' ';
$list = '';
if (!empty($array_filtervalue))
{
@@ -952,7 +953,7 @@ if ($step == 4 && $datatoexport)
}
}
}
- print ''.(!empty($list) ? $list : $langs->trans("None")).' ';
+ print ''.(!empty($list) ? $list : ''.$langs->trans("None").' ').' ';
print ' ';
}
@@ -1186,7 +1187,7 @@ if ($step == 5 && $datatoexport)
print $objexport->array_export_module[0]->getName();
print '';
- // Lot de donnees a exporter
+ // Dataset to export
print ''.$langs->trans("DatasetToExport").' ';
print '';
$icon = preg_replace('/:.*$/', '', $objexport->array_export_icon[0]);
@@ -1266,22 +1267,17 @@ if ($step == 5 && $datatoexport)
print '';
- print '';
-
if ($sqlusedforexport && $user->admin)
{
- print '';
- print info_admin($langs->trans("SQLUsedForExport").': '.$sqlusedforexport);
- print ' ';
+ print info_admin($langs->trans("SQLUsedForExport").': '.$sqlusedforexport, 0, 0, 1, '', 'TechnicalInformation');
}
- print '
';
if (!is_dir($conf->export->dir_temp)) dol_mkdir($conf->export->dir_temp);
// Show existing generated documents
// NB: La fonction show_documents rescanne les modules qd genallowed=1, sinon prend $liste
- print $formfile->showdocuments('export', '', $upload_dir, $_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport, $liste, 1, (!empty($_POST['model']) ? $_POST['model'] : 'csv'), 1, 1, 0, 0, 0, '', ' ', '', '', '');
+ print $formfile->showdocuments('export', '', $upload_dir, $_SERVER["PHP_SELF"].'?step=5&datatoexport='.$datatoexport, $liste, 1, (!empty($_POST['model']) ? $_POST['model'] : 'csv'), 1, 1, 0, 0, 0, '', 'none', '', '', '');
}
llxFooter();
diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php
index d2a4171eb4f..3d1a23ee26d 100644
--- a/htdocs/fichinter/card.php
+++ b/htdocs/fichinter/card.php
@@ -96,6 +96,8 @@ if ($id > 0 || !empty($ref))
$permissionnote = $user->rights->ficheinter->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->ficheinter->creer; // Used by the include of actions_dellink.inc.php
+$error = 0;
+
/*
* Actions
@@ -351,7 +353,7 @@ if (empty($reshook))
$desc .= ' ';
$desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')';
- $timearray = dol_getdate(mktime());
+ $timearray = dol_getdate(dol_now());
$date_intervention = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']);
if ($product_type == Product::TYPE_PRODUCT) {
@@ -818,10 +820,7 @@ llxHeader('', $langs->trans("Intervention"));
if ($action == 'create')
{
- /*
- * Mode creation
- * Creation d'une nouvelle fiche d'intervention
- */
+ // Create new intervention
$soc = new Societe($db);
@@ -831,11 +830,12 @@ if ($action == 'create')
if ($socid) $res = $soc->fetch($socid);
- if (GETPOST('origin') && GETPOST('originid'))
+ if (GETPOST('origin', 'alphanohtml') && GETPOST('originid', 'int'))
{
// Parse element/subelement (ex: project_task)
- $element = $subelement = GETPOST('origin');
- if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin'), $regs))
+ $regs = array();
+ $element = $subelement = GETPOST('origin', 'alphanohtml');
+ if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs))
{
$element = $regs[1];
$subelement = $regs[2];
@@ -843,7 +843,7 @@ if ($action == 'create')
if ($element == 'project')
{
- $projectid = GETPOST('originid');
+ $projectid = GETPOST('originid', 'int');
}
else
{
@@ -941,7 +941,7 @@ if ($action == 'create')
$numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid');
if ($numprojet == 0)
{
- print ' '.$langs->trans("AddProject").' ';
+ print ' ';
}
print ' ';
}
@@ -954,7 +954,7 @@ if ($action == 'create')
$numcontrat = $formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1);
if ($numcontrat == 0)
{
- print ' '.$langs->trans("AddContract").' ';
+ print ' ';
}
print '';
}
@@ -1076,6 +1076,7 @@ if ($action == 'create')
print '';
print ''.$langs->trans("ThirdParty").' ';
print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300');
+ print ' ';
print ' ';
print '
';
@@ -1168,7 +1169,7 @@ elseif ($id > 0 || !empty($ref))
if (!$formconfirm)
{
- $parameters = array('lineid'=>$lineid);
+ $parameters = array('formConfirm' => $formconfirm, 'lineid'=>$lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php
index 18e2992930c..d8f7dad8ac0 100644
--- a/htdocs/filefunc.inc.php
+++ b/htdocs/filefunc.inc.php
@@ -165,7 +165,8 @@ if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck))
if ($csrfattack)
{
//print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_HOST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER'];
- print "Access refused by CSRF protection in main.inc.php. Referer of form (".$_SERVER['HTTP_REFERER'].") is outside the server that serve this page (with method = ".$_SERVER['REQUEST_METHOD'].").\n";
+ // Note: We can't use dol_escape_htmltag here to escape output because lib functions.lib.ph is not yet loaded.
+ print "Access refused by CSRF protection in main.inc.php. Referer of form (".htmlentities($_SERVER['HTTP_REFERER'], ENT_COMPAT, 'UTF-8').") is outside the server that serve this page (with method = ".htmlentities($_SERVER['REQUEST_METHOD'], ENT_COMPAT, 'UTF-8').").\n";
print "If you access your server behind a proxy using url rewriting, you might check that all HTTP headers are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file to remove this security check).\n";
die;
}
diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php
index 2d18c6ea86e..0c0d8f42c9e 100644
--- a/htdocs/fourn/ajax/getSupplierPrices.php
+++ b/htdocs/fourn/ajax/getSupplierPrices.php
@@ -22,20 +22,20 @@
* \brief File to return an Ajax response to get list of possible prices for margin calculation
*/
-if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
-if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
-if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
-if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
+if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
+if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
+if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
+if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
-$idprod=GETPOST('idprod', 'int');
+$idprod = GETPOST('idprod', 'int');
$prices = array();
// Load translation files required by the page
-$langs->loadLangs(array("stocks","margins"));
+$langs->loadLangs(array("stocks", "margins"));
/*
@@ -48,14 +48,14 @@ top_httphead();
if ($idprod > 0)
{
- $producttmp=new ProductFournisseur($db);
+ $producttmp = new ProductFournisseur($db);
$producttmp->fetch($idprod);
$sorttouse = 's.nom, pfp.quantity, pfp.price';
if (GETPOST('bestpricefirst')) $sorttouse = 'pfp.unitprice, s.nom, pfp.quantity, pfp.price';
- $productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse); // We list all price per supplier, and then firstly with the lower quantity. So we can choose first one with enough quantity into list.
- if ( is_array($productSupplierArray))
+ $productSupplierArray = $producttmp->list_product_fournisseur_price($idprod, $sorttouse); // We list all price per supplier, and then firstly with the lower quantity. So we can choose first one with enough quantity into list.
+ if (is_array($productSupplierArray))
{
foreach ($productSupplierArray as $productSupplier)
{
@@ -66,35 +66,35 @@ if ($idprod > 0)
if ($productSupplier->fourn_qty == 1)
{
- $title.= price($price, 0, $langs, 0, 0, -1, $conf->currency)."/";
+ $title .= price($price, 0, $langs, 0, 0, -1, $conf->currency)."/";
}
- $title.= $productSupplier->fourn_qty.' '.($productSupplier->fourn_qty == 1 ? $langs->trans("Unit") : $langs->trans("Units"));
+ $title .= $productSupplier->fourn_qty.' '.($productSupplier->fourn_qty == 1 ? $langs->trans("Unit") : $langs->trans("Units"));
if ($productSupplier->fourn_qty > 1)
{
- $title.=" - ";
- $title.= price($unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit");
+ $title .= " - ";
+ $title .= price($unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit");
$price = $unitprice;
}
$label = price($price, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit");
- if ($productSupplier->fourn_ref) $label.=' ('.$productSupplier->fourn_ref.')';
+ if ($productSupplier->fourn_ref) $label .= ' ('.$productSupplier->fourn_ref.')';
- $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, 0, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price()
+ $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, 0, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price()
}
}
// After best supplier prices and before costprice
- if(!empty($conf->stock->enabled))
+ if (!empty($conf->stock->enabled))
{
// Add price for pmp
- $price=$producttmp->pmp;
- $prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
+ $price = $producttmp->pmp;
+ $prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
}
// Add price for costprice (at end)
- $price=$producttmp->cost_price;
- $prices[] = array("id" => 'costprice', "price" => price2num($price), "label" => $langs->trans("CostPrice").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
+ $price = $producttmp->cost_price;
+ $prices[] = array("id" => 'costprice', "price" => price2num($price), "label" => $langs->trans("CostPrice").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
}
echo json_encode($prices);
diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php
index 9056d1217ca..23031d09d90 100644
--- a/htdocs/fourn/card.php
+++ b/htdocs/fourn/card.php
@@ -36,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
+if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by page
$langs->loadLangs(array(
@@ -312,7 +313,7 @@ if ($object->id > 0)
$langs->load("categories");
print ''.$langs->trans("SuppliersCategoriesShort").' ';
print '';
- print $form->showCategories($object->id, 'supplier', 1);
+ print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
print " ";
}
diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php
index 21e5e82c13b..204471bc9e7 100644
--- a/htdocs/fourn/class/api_supplier_invoices.class.php
+++ b/htdocs/fourn/class/api_supplier_invoices.class.php
@@ -194,8 +194,8 @@ class SupplierInvoices extends DolibarrApi
*
* @return int ID of supplier invoice
*
- * @throws 401
- * @throws 500
+ * @throws RestException 401
+ * @throws RestException 500
*/
public function post($request_data = null)
{
@@ -226,8 +226,8 @@ class SupplierInvoices extends DolibarrApi
*
* @return int
*
- * @throws 401
- * @throws 404
+ * @throws RestException 401
+ * @throws RestException 404
*/
public function put($id, $request_data = null)
{
@@ -262,9 +262,9 @@ class SupplierInvoices extends DolibarrApi
*
* @return array
*
- * @throws 401
- * @throws 404
- * @throws 500
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 500
*/
public function delete($id)
{
@@ -304,11 +304,11 @@ class SupplierInvoices extends DolibarrApi
*
* @return array
*
- * @throws 304
- * @throws 401
- * @throws 404
- * @throws 405
- * @throws 500
+ * @throws RestException 304
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 405
+ * @throws RestException 500
*/
public function validate($id, $idwarehouse = 0, $notrigger = 0)
{
@@ -348,10 +348,10 @@ class SupplierInvoices extends DolibarrApi
* @url GET {id}/payments
*
* @return array
- * @throws 400
- * @throws 401
- * @throws 404
- * @throws 405
+ * @throws RestException 400
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 405
*/
public function getPayments($id)
{
@@ -396,9 +396,9 @@ class SupplierInvoices extends DolibarrApi
* @url POST {id}/payments
*
* @return int Payment ID
- * @throws 400
- * @throws 401
- * @throws 404
+ * @throws RestException 400
+ * @throws RestException 401
+ * @throws RestException 404
*/
public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '')
{
diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php
index 37ac4c55e9d..cb2e27b1a97 100644
--- a/htdocs/fourn/class/api_supplier_orders.class.php
+++ b/htdocs/fourn/class/api_supplier_orders.class.php
@@ -252,8 +252,8 @@ class SupplierOrders extends DolibarrApi
/**
* Delete supplier order
*
- * @param int $id Supplier order ID
- * @return type
+ * @param int $id Supplier order ID
+ * @return array Array of result
*/
public function delete($id)
{
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 3b2833fee76..bed02b94d55 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -65,7 +65,7 @@ class CommandeFournisseur extends CommonOrder
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
- public $picto='order';
+ public $picto = 'order';
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
@@ -183,6 +183,60 @@ class CommandeFournisseur extends CommonOrder
public $multicurrency_total_tva;
public $multicurrency_total_ttc;
+
+
+ public $fields = array(
+ 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
+ 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15),
+ 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20),
+ 'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'showoncombobox'=>1, 'position'=>25),
+ 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>30, 'index'=>1),
+ 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>35),
+ 'ref_supplier' =>array('type'=>'varchar(255)', 'label'=>'RefSupplier', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
+ 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
+ 'date_creation' =>array('type'=>'datetime', 'label'=>'Date creation', 'enabled'=>1, 'visible'=>-1, 'position'=>50),
+ 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>55),
+ 'date_approve' =>array('type'=>'datetime', 'label'=>'Date approve', 'enabled'=>1, 'visible'=>-1, 'position'=>60),
+ 'date_approve2' =>array('type'=>'datetime', 'label'=>'Date approve2', 'enabled'=>1, 'visible'=>-1, 'position'=>65),
+ 'date_commande' =>array('type'=>'date', 'label'=>'Date commande', 'enabled'=>1, 'visible'=>-1, 'position'=>70),
+ 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>75),
+ 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>80),
+ 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>85),
+ 'fk_user_approve' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserApproval', 'enabled'=>1, 'visible'=>-1, 'position'=>90),
+ 'fk_user_approve2' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserSecondApproval', 'enabled'=>1, 'visible'=>-1, 'position'=>95),
+ 'source' =>array('type'=>'smallint(6)', 'label'=>'Source', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>100),
+ 'billed' =>array('type'=>'smallint(6)', 'label'=>'Billed', 'enabled'=>1, 'visible'=>-1, 'position'=>110),
+ 'amount_ht' =>array('type'=>'double(24,8)', 'label'=>'Amount ht', 'enabled'=>1, 'visible'=>-1, 'position'=>115),
+ 'remise_percent' =>array('type'=>'double', 'label'=>'Remise percent', 'enabled'=>1, 'visible'=>-1, 'position'=>120),
+ 'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>125),
+ 'tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1),
+ 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1),
+ 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1),
+ 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1),
+ 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>150, 'isameasure'=>1),
+ 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>155),
+ 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>160),
+ 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>165),
+ 'fk_input_method' =>array('type'=>'integer', 'label'=>'InputMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>170),
+ 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>175),
+ 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>180),
+ 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>190),
+ 'date_livraison' =>array('type'=>'datetime', 'label'=>'DeliveryDate', 'enabled'=>1, 'visible'=>-1, 'position'=>195),
+ 'fk_account' =>array('type'=>'integer', 'label'=>'Fk account', 'enabled'=>1, 'visible'=>-1, 'position'=>200),
+ 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermCode', 'enabled'=>1, 'visible'=>-1, 'position'=>205),
+ 'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'IncotermLocation', 'enabled'=>1, 'visible'=>-1, 'position'=>210),
+ 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'Fk multicurrency', 'enabled'=>1, 'visible'=>-1, 'position'=>215),
+ 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'MulticurrencyCode', 'enabled'=>1, 'visible'=>-1, 'position'=>220),
+ 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyRate', 'enabled'=>1, 'visible'=>-1, 'position'=>225),
+ 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyTotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>230),
+ 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyTotalVAT', 'enabled'=>1, 'visible'=>-1, 'position'=>235),
+ 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyTotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>240),
+ 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>-1, 'position'=>245),
+ 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
+ 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900),
+ );
+
+
/**
* Draft status
*/
@@ -387,6 +441,7 @@ class CommandeFournisseur extends CommonOrder
*/
public function fetch_lines($only_product = 0)
{
+ global $conf;
// phpcs:enable
//$result=$this->fetch_lines();
$this->lines = array();
@@ -399,8 +454,12 @@ class CommandeFournisseur extends CommonOrder
$sql .= " l.fk_unit,";
$sql .= " l.date_start, l.date_end,";
$sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc';
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ $sql .= ", pfp.rowid as fk_pfp, pfp.packaging";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn";
$sql .= " WHERE l.fk_commande = ".$this->id;
if ($only_product) $sql .= ' AND p.fk_product_type = 0';
$sql .= " ORDER BY l.rang, l.rowid";
@@ -442,7 +501,7 @@ class CommandeFournisseur extends CommonOrder
$line->fk_product = $objp->fk_product;
- $line->libelle = $objp->product_label; // deprecated
+ $line->libelle = $objp->product_label; // deprecated
$line->product_label = $objp->product_label;
$line->product_desc = $objp->product_desc;
@@ -451,7 +510,13 @@ class CommandeFournisseur extends CommonOrder
$line->ref_fourn = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since
$line->ref_supplier = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since
- $line->date_start = $this->db->jdate($objp->date_start);
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ {
+ $line->fk_fournprice = $objp->fk_pfp;
+ $line->packaging = $objp->packaging;
+ }
+
+ $line->date_start = $this->db->jdate($objp->date_start);
$line->date_end = $this->db->jdate($objp->date_end);
$line->fk_unit = $objp->fk_unit;
@@ -1414,38 +1479,38 @@ class CommandeFournisseur extends CommonOrder
*/
public function createFromClone(User $user, $socid = 0)
{
- global $conf, $user,$hookmanager;
+ global $conf, $user, $hookmanager;
- $error=0;
+ $error = 0;
$this->db->begin();
// get lines so they will be clone
- foreach($this->lines as $line)
+ foreach ($this->lines as $line)
$line->fetch_optionals();
// Load source object
$objFrom = clone $this;
// Change socid if needed
- if (! empty($socid) && $socid != $this->socid)
+ if (!empty($socid) && $socid != $this->socid)
{
$objsoc = new Societe($this->db);
- if ($objsoc->fetch($socid)>0)
+ if ($objsoc->fetch($socid) > 0)
{
- $this->socid = $objsoc->id;
- $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
- $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
- $this->fk_project = 0;
- $this->fk_delivery_address = 0;
+ $this->socid = $objsoc->id;
+ $this->cond_reglement_id = (!empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
+ $this->mode_reglement_id = (!empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
+ $this->fk_project = 0;
+ $this->fk_delivery_address = 0;
}
// TODO Change product price if multi-prices
}
- $this->id=0;
- $this->statut=self::STATUS_DRAFT;
+ $this->id = 0;
+ $this->statut = self::STATUS_DRAFT;
// Clear fields
$this->user_author_id = $user->id;
@@ -1631,6 +1696,26 @@ class CommandeFournisseur extends CommonOrder
return -1;
}
}
+
+ // redefine quantity according to packaging
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ {
+ $prod = new Product($this->db, $fk_product);
+ $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc ? $this->fk_soc : $this->socid));
+ if ($qty < $prod->packaging)
+ {
+ $qty = $prod->packaging;
+ }
+ else
+ {
+ if (($qty % $prod->packaging) > 0)
+ {
+ $coeff = intval($qty / $prod->packaging) + 1;
+ $qty = $prod->packaging * $coeff;
+ setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs');
+ }
+ }
+ }
}
else
{
@@ -2400,7 +2485,7 @@ class CommandeFournisseur extends CommonOrder
$sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet";
$sql .= " (fk_commande, label, description, fk_product, price, qty, tva_tx, localtax1_tx, localtax2_tx, remise_percent, subprice, remise, ref)";
- $sql .= " VALUES (".$idc.", '" . $this->db->escape($label) . "','" . $this->db->escape($comclient->lines[$i]->desc) . "'";
+ $sql .= " VALUES (".$idc.", '".$this->db->escape($label)."','".$this->db->escape($comclient->lines[$i]->desc)."'";
$sql .= ",".$comclient->lines[$i]->fk_product.",'".price2num($comclient->lines[$i]->price)."'";
$sql .= ", '".$comclient->lines[$i]->qty."', ".$comclient->lines[$i]->tva_tx.", ".$comclient->lines[$i]->localtax1_tx.", ".$comclient->lines[$i]->localtax2_tx.", ".$comclient->lines[$i]->remise_percent;
$sql .= ", '".price2num($comclient->lines[$i]->subprice)."','0','".$ref."');";
@@ -2582,6 +2667,25 @@ class CommandeFournisseur extends CommonOrder
$this->line->fk_commande = $this->id;
//$this->line->label=$label;
$this->line->desc = $desc;
+
+ // redefine quantity according to packaging
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ {
+ if ($qty < $this->line->packaging)
+ {
+ $qty = $this->line->packaging;
+ }
+ else
+ {
+ if (($qty % $this->line->packaging) > 0)
+ {
+ $coeff = intval($qty / $this->line->packaging) + 1;
+ $qty = $this->line->packaging * $coeff;
+ setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs');
+ }
+ }
+ }
+
$this->line->qty = $qty;
$this->line->ref_supplier = $ref_supplier;
@@ -2623,7 +2727,7 @@ class CommandeFournisseur extends CommonOrder
if (is_array($array_options) && count($array_options) > 0) {
// We replace values in this->line->array_options only for entries defined into $array_options
- foreach($array_options as $key => $value) {
+ foreach ($array_options as $key => $value) {
$this->line->array_options[$key] = $array_options[$key];
}
}
@@ -2795,26 +2899,26 @@ class CommandeFournisseur extends CommonOrder
// phpcs:enable
global $conf, $user;
- $this->nb=array();
+ $this->nb = array();
$clause = "WHERE";
$sql = "SELECT count(co.rowid) as nb";
- $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as co";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid";
+ $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as co";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->socid)
{
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
- $sql.= " WHERE sc.fk_user = " .$user->id;
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
+ $sql .= " WHERE sc.fk_user = ".$user->id;
$clause = "AND";
}
- $sql.= " ".$clause." co.entity = ".$conf->entity;
+ $sql .= " ".$clause." co.entity = ".$conf->entity;
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql)
{
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
- $this->nb["supplier_orders"]=$obj->nb;
+ $this->nb["supplier_orders"] = $obj->nb;
}
$this->db->free($resql);
return 1;
@@ -2843,41 +2947,41 @@ class CommandeFournisseur extends CommonOrder
$clause = " WHERE";
$sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.fk_statut, c.date_livraison as delivery_date";
- $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
+ $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
if (!$user->rights->societe->client->voir && !$user->socid)
{
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc";
- $sql.= " WHERE sc.fk_user = " .$user->id;
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc";
+ $sql .= " WHERE sc.fk_user = ".$user->id;
$clause = " AND";
}
- $sql.= $clause." c.entity = ".$conf->entity;
- if($mode==='awaiting'){
- $sql.= " AND c.fk_statut = ".self::STATUS_ORDERSENT;
+ $sql .= $clause." c.entity = ".$conf->entity;
+ if ($mode === 'awaiting') {
+ $sql .= " AND c.fk_statut = ".self::STATUS_ORDERSENT;
}
- else{
- $sql.= " AND c.fk_statut IN (".self::STATUS_VALIDATED.", ".self::STATUS_ACCEPTED.")";
+ else {
+ $sql .= " AND c.fk_statut IN (".self::STATUS_VALIDATED.", ".self::STATUS_ACCEPTED.")";
}
- if ($user->socid) $sql.=" AND c.fk_soc = ".$user->socid;
+ if ($user->socid) $sql .= " AND c.fk_soc = ".$user->socid;
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql)
{
$commandestatic = new CommandeFournisseur($this->db);
$response = new WorkboardResponse();
- $response->warning_delay=$conf->commande->fournisseur->warning_delay/60/60/24;
- $response->label=$langs->trans("SuppliersOrdersToProcess");
- $response->labelShort=$langs->trans("Opened");
- $response->url=DOL_URL_ROOT.'/fourn/commande/list.php?statut=1,2&mainmenu=commercial&leftmenu=orders_suppliers';
- $response->img=img_object('', "order");
+ $response->warning_delay = $conf->commande->fournisseur->warning_delay / 60 / 60 / 24;
+ $response->label = $langs->trans("SuppliersOrdersToProcess");
+ $response->labelShort = $langs->trans("Opened");
+ $response->url = DOL_URL_ROOT.'/fourn/commande/list.php?statut=1,2&mainmenu=commercial&leftmenu=orders_suppliers';
+ $response->img = img_object('', "order");
- if($mode==='awaiting'){
- $response->label=$langs->trans("SuppliersOrdersAwaitingReception");
- $response->labelShort=$langs->trans("AwaitingReception");
- $response->url=DOL_URL_ROOT.'/fourn/commande/list.php?statut=3&mainmenu=commercial&leftmenu=orders_suppliers';
+ if ($mode === 'awaiting') {
+ $response->label = $langs->trans("SuppliersOrdersAwaitingReception");
+ $response->labelShort = $langs->trans("AwaitingReception");
+ $response->url = DOL_URL_ROOT.'/fourn/commande/list.php?statut=3&mainmenu=commercial&leftmenu=orders_suppliers';
}
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
$response->nbtodo++;
@@ -2953,17 +3057,17 @@ class CommandeFournisseur extends CommonOrder
$langs->load("suppliers");
- if (! dol_strlen($modele)) {
+ if (!dol_strlen($modele)) {
$modele = 'muscadet';
if ($this->modelpdf) {
$modele = $this->modelpdf;
- } elseif (! empty($conf->global->COMMANDE_SUPPLIER_ADDON_PDF)) {
+ } elseif (!empty($conf->global->COMMANDE_SUPPLIER_ADDON_PDF)) {
$modele = $conf->global->COMMANDE_SUPPLIER_ADDON_PDF;
}
}
- $modelpath = "core/modules/supplier_order/pdf/";
+ $modelpath = "core/modules/supplier_order/doc/";
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
}
@@ -3336,6 +3440,8 @@ class CommandeFournisseurLigne extends CommonOrderLine
*/
public function fetch($rowid)
{
+ global $conf;
+
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx, cd.special_code,';
$sql .= ' cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.ref,';
$sql .= ' cd.remise, cd.remise_percent, cd.subprice,';
@@ -3344,8 +3450,12 @@ class CommandeFournisseurLigne extends CommonOrderLine
$sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,';
$sql .= ' cd.date_start, cd.date_end, cd.fk_unit,';
$sql .= ' cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc';
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ $sql .= ", pfp.rowid as fk_pfp, pfp.packaging";
$sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON cd.fk_product = pfp.fk_product and cd.ref = pfp.ref_fourn";
$sql .= ' WHERE cd.rowid = '.$rowid;
$result = $this->db->query($sql);
if ($result)
@@ -3383,6 +3493,11 @@ class CommandeFournisseurLigne extends CommonOrderLine
$this->product_ref = $objp->product_ref;
$this->product_libelle = $objp->product_libelle;
$this->product_desc = $objp->product_desc;
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ {
+ $this->packaging = $objp->packaging;
+ $this->fk_fournprice = $objp->fk_pfp;
+ }
$this->date_start = $this->db->jdate($objp->date_start);
$this->date_end = $this->db->jdate($objp->date_end);
@@ -3642,20 +3757,20 @@ class CommandeFournisseurLigne extends CommonOrderLine
{
global $user;
- $error=0;
+ $error = 0;
$this->db->begin();
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande_fournisseurdet WHERE rowid=".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql)
{
if (!$notrigger)
{
// Call trigger
- $result=$this->call_trigger('LINEORDER_SUPPLIER_DELETE', $user);
+ $result = $this->call_trigger('LINEORDER_SUPPLIER_DELETE', $user);
if ($result < 0) $error++;
// End call triggers
}
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index e6562dbf928..6178bc5ae3c 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -46,27 +46,27 @@ class FactureFournisseur extends CommonInvoice
/**
* @var string ID to identify managed object
*/
- public $element='invoice_supplier';
+ public $element = 'invoice_supplier';
/**
* @var string Name of table without prefix where object is stored
*/
- public $table_element='facture_fourn';
+ public $table_element = 'facture_fourn';
/**
* @var int Name of subtable line
*/
- public $table_element_line='facture_fourn_det';
+ public $table_element_line = 'facture_fourn_det';
/**
* @var int Field with ID of parent key if this field has a parent
*/
- public $fk_element='fk_facture_fourn';
+ public $fk_element = 'fk_facture_fourn';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
- public $picto='bill';
+ public $picto = 'bill';
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
@@ -96,7 +96,7 @@ class FactureFournisseur extends CommonInvoice
public $ref;
public $label;
- public $libelle; // @deprecated
+ public $libelle; // @deprecated
public $product_ref;
public $ref_supplier;
@@ -196,9 +196,9 @@ class FactureFournisseur extends CommonInvoice
public $fk_incoterms;
public $location_incoterms;
- public $label_incoterms; //Used into tooltip
+ public $label_incoterms; //Used into tooltip
- public $extraparams=array();
+ public $extraparams = array();
// Multicurrency
/**
@@ -217,6 +217,59 @@ class FactureFournisseur extends CommonInvoice
*/
public $fk_facture_source;
+
+ public $fields = array(
+ 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
+ 'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>15),
+ 'ref_supplier' =>array('type'=>'varchar(255)', 'label'=>'RefSupplier', 'enabled'=>1, 'visible'=>-1, 'position'=>20),
+ 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>25, 'index'=>1),
+ 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>30),
+ 'type' =>array('type'=>'smallint(6)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35),
+ 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>40),
+ 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
+ 'datef' =>array('type'=>'date', 'label'=>'Date', 'enabled'=>1, 'visible'=>-1, 'position'=>50),
+ 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>55),
+ 'libelle' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'position'=>60),
+ 'paye' =>array('type'=>'smallint(6)', 'label'=>'Paye', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>65),
+ 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70),
+ 'remise' =>array('type'=>'double(24,8)', 'label'=>'Discount', 'enabled'=>1, 'visible'=>-1, 'position'=>75),
+ 'close_code' =>array('type'=>'varchar(16)', 'label'=>'CloseCode', 'enabled'=>1, 'visible'=>-1, 'position'=>80),
+ 'close_note' =>array('type'=>'varchar(128)', 'label'=>'CloseNote', 'enabled'=>1, 'visible'=>-1, 'position'=>85),
+ 'tva' =>array('type'=>'double(24,8)', 'label'=>'Tva', 'enabled'=>1, 'visible'=>-1, 'position'=>90),
+ 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>95),
+ 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>100),
+ 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>105),
+ 'total_tva' =>array('type'=>'double(24,8)', 'label'=>'TotalVAT', 'enabled'=>1, 'visible'=>-1, 'position'=>110),
+ 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>115),
+ 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'position'=>125),
+ 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>130),
+ 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>135),
+ 'fk_facture_source' =>array('type'=>'integer', 'label'=>'Fk facture source', 'enabled'=>1, 'visible'=>-1, 'position'=>140),
+ 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>145),
+ 'fk_account' =>array('type'=>'integer', 'label'=>'Account', 'enabled'=>1, 'visible'=>-1, 'position'=>150),
+ 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>155),
+ 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>160),
+ 'date_lim_reglement' =>array('type'=>'date', 'label'=>'DateLimReglement', 'enabled'=>1, 'visible'=>-1, 'position'=>165),
+ 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>170),
+ 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>175),
+ 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPdf', 'enabled'=>1, 'visible'=>0, 'position'=>180),
+ 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>190),
+ 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermCode', 'enabled'=>1, 'visible'=>-1, 'position'=>195),
+ 'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'IncotermLocation', 'enabled'=>1, 'visible'=>-1, 'position'=>200),
+ 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'MulticurrencyId', 'enabled'=>1, 'visible'=>-1, 'position'=>205),
+ 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'MulticurrencyCode', 'enabled'=>1, 'visible'=>-1, 'position'=>210),
+ 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyRate', 'enabled'=>1, 'visible'=>-1, 'position'=>215),
+ 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyTotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>220),
+ 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyTotalVAT', 'enabled'=>1, 'visible'=>-1, 'position'=>225),
+ 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyTotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>230),
+ 'date_pointoftax' =>array('type'=>'date', 'label'=>'Date pointoftax', 'enabled'=>1, 'visible'=>-1, 'position'=>235),
+ 'date_valid' =>array('type'=>'date', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>240),
+ 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>245),
+ 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
+ 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900),
+ );
+
+
/**
* Standard invoice
*/
@@ -317,86 +370,86 @@ class FactureFournisseur extends CommonInvoice
$this->db->begin();
- if (! $remise) $remise = 0 ;
+ if (!$remise) $remise = 0;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_fourn (";
- $sql.= "ref";
- $sql.= ", ref_supplier";
- $sql.= ", entity";
- $sql.= ", type";
- $sql.= ", libelle";
- $sql.= ", fk_soc";
- $sql.= ", datec";
- $sql.= ", datef";
- $sql.= ", fk_projet";
- $sql.= ", fk_cond_reglement";
- $sql.= ", fk_mode_reglement";
- $sql.= ", fk_account";
- $sql.= ", note_private";
- $sql.= ", note_public";
- $sql.= ", fk_user_author";
- $sql.= ", date_lim_reglement";
- $sql.= ", fk_incoterms, location_incoterms";
- $sql.= ", fk_multicurrency";
- $sql.= ", multicurrency_code";
- $sql.= ", multicurrency_tx";
- $sql.= ", fk_facture_source";
- $sql.= ")";
- $sql.= " VALUES (";
- $sql.= "'(PROV)'";
- $sql.= ", '".$this->db->escape($this->ref_supplier)."'";
- $sql.= ", ".$conf->entity;
- $sql.= ", '".$this->db->escape($this->type)."'";
- $sql.= ", '".$this->db->escape($this->label?$this->label:$this->libelle)."'";
- $sql.= ", ".$this->socid;
- $sql.= ", '".$this->db->idate($now)."'";
- $sql.= ", '".$this->db->idate($this->date)."'";
- $sql.= ", ".($this->fk_project > 0 ? $this->fk_project:"null");
- $sql.= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id:"null");
- $sql.= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id:"null");
- $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
- $sql.= ", '".$this->db->escape($this->note_private)."'";
- $sql.= ", '".$this->db->escape($this->note_public)."'";
- $sql.= ", ".$user->id.",";
- $sql.= $this->date_echeance!=''?"'".$this->db->idate($this->date_echeance)."'":"null";
- $sql.= ", ".(int) $this->fk_incoterms;
- $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
- $sql.= ", ".(int) $this->fk_multicurrency;
- $sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
- $sql.= ", ".(double) $this->multicurrency_tx;
- $sql.= ", ".(isset($this->fk_facture_source)?$this->fk_facture_source:"NULL");
- $sql.= ")";
+ $sql .= "ref";
+ $sql .= ", ref_supplier";
+ $sql .= ", entity";
+ $sql .= ", type";
+ $sql .= ", libelle";
+ $sql .= ", fk_soc";
+ $sql .= ", datec";
+ $sql .= ", datef";
+ $sql .= ", fk_projet";
+ $sql .= ", fk_cond_reglement";
+ $sql .= ", fk_mode_reglement";
+ $sql .= ", fk_account";
+ $sql .= ", note_private";
+ $sql .= ", note_public";
+ $sql .= ", fk_user_author";
+ $sql .= ", date_lim_reglement";
+ $sql .= ", fk_incoterms, location_incoterms";
+ $sql .= ", fk_multicurrency";
+ $sql .= ", multicurrency_code";
+ $sql .= ", multicurrency_tx";
+ $sql .= ", fk_facture_source";
+ $sql .= ")";
+ $sql .= " VALUES (";
+ $sql .= "'(PROV)'";
+ $sql .= ", '".$this->db->escape($this->ref_supplier)."'";
+ $sql .= ", ".$conf->entity;
+ $sql .= ", '".$this->db->escape($this->type)."'";
+ $sql .= ", '".$this->db->escape($this->label ? $this->label : $this->libelle)."'";
+ $sql .= ", ".$this->socid;
+ $sql .= ", '".$this->db->idate($now)."'";
+ $sql .= ", '".$this->db->idate($this->date)."'";
+ $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : "null");
+ $sql .= ", ".($this->cond_reglement_id > 0 ? $this->cond_reglement_id : "null");
+ $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "null");
+ $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL');
+ $sql .= ", '".$this->db->escape($this->note_private)."'";
+ $sql .= ", '".$this->db->escape($this->note_public)."'";
+ $sql .= ", ".$user->id.",";
+ $sql .= $this->date_echeance != '' ? "'".$this->db->idate($this->date_echeance)."'" : "null";
+ $sql .= ", ".(int) $this->fk_incoterms;
+ $sql .= ", '".$this->db->escape($this->location_incoterms)."'";
+ $sql .= ", ".(int) $this->fk_multicurrency;
+ $sql .= ", '".$this->db->escape($this->multicurrency_code)."'";
+ $sql .= ", ".(double) $this->multicurrency_tx;
+ $sql .= ", ".(isset($this->fk_facture_source) ? $this->fk_facture_source : "NULL");
+ $sql .= ")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn');
// Update ref with new one
- $this->ref='(PROV'.$this->id.')';
+ $this->ref = '(PROV'.$this->id.')';
$sql = 'UPDATE '.MAIN_DB_PREFIX."facture_fourn SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::create", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (! $resql) $error++;
+ $resql = $this->db->query($sql);
+ if (!$resql) $error++;
- if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
+ if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
{
- $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
+ $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
}
// Add object linked
- if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
+ if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects))
{
- foreach($this->linked_objects as $origin => $tmp_origin_id)
+ foreach ($this->linked_objects as $origin => $tmp_origin_id)
{
if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
{
- foreach($tmp_origin_id as $origin_id)
+ foreach ($tmp_origin_id as $origin_id)
{
$ret = $this->add_object_linked($origin, $origin_id);
- if (! $ret)
+ if (!$ret)
{
dol_print_error($this->db);
$error++;
@@ -501,28 +554,28 @@ class FactureFournisseur extends CommonInvoice
}
// Update total price
- $result=$this->update_price();
+ $result = $this->update_price();
if ($result > 0)
{
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
- $result=$this->insertExtraFields(); // This also set $this->error or $this->errors if errors are found
+ $result = $this->insertExtraFields(); // This also set $this->error or $this->errors if errors are found
if ($result < 0)
{
$error++;
}
}
- if (! $error)
+ if (!$error)
{
// Call trigger
- $result=$this->call_trigger('BILL_SUPPLIER_CREATE', $user);
+ $result = $this->call_trigger('BILL_SUPPLIER_CREATE', $user);
if ($result < 0) $error++;
// End call triggers
}
- if (! $error)
+ if (!$error)
{
$this->db->commit();
return $this->id;
@@ -569,75 +622,75 @@ class FactureFournisseur extends CommonInvoice
global $langs;
$sql = "SELECT";
- $sql.= " t.rowid,";
- $sql.= " t.ref,";
- $sql.= " t.ref_supplier,";
- $sql.= " t.entity,";
- $sql.= " t.type,";
- $sql.= " t.fk_soc,";
- $sql.= " t.datec,";
- $sql.= " t.datef,";
- $sql.= " t.tms,";
- $sql.= " t.libelle as label,";
- $sql.= " t.paye,";
- $sql.= " t.amount,";
- $sql.= " t.remise,";
- $sql.= " t.close_code,";
- $sql.= " t.close_note,";
- $sql.= " t.tva,";
- $sql.= " t.localtax1,";
- $sql.= " t.localtax2,";
- $sql.= " t.total_ht,";
- $sql.= " t.total_tva,";
- $sql.= " t.total_ttc,";
- $sql.= " t.fk_statut,";
- $sql.= " t.fk_user_author,";
- $sql.= " t.fk_user_valid,";
- $sql.= " t.fk_facture_source,";
- $sql.= " t.fk_projet as fk_project,";
- $sql.= " t.fk_cond_reglement,";
- $sql.= " t.fk_account,";
- $sql.= " t.fk_mode_reglement,";
- $sql.= " t.date_lim_reglement,";
- $sql.= " t.note_private,";
- $sql.= " t.note_public,";
- $sql.= " t.model_pdf,";
- $sql.= " t.import_key,";
- $sql.= " t.extraparams,";
- $sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,";
- $sql.= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle,";
- $sql.= ' s.nom as socnom, s.rowid as socid,';
- $sql.= ' t.fk_incoterms, t.location_incoterms,';
- $sql.= " i.libelle as label_incoterms,";
- $sql.= ' t.fk_multicurrency, t.multicurrency_code, t.multicurrency_tx, t.multicurrency_total_ht, t.multicurrency_total_tva, t.multicurrency_total_ttc';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t';
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON t.fk_cond_reglement = cr.rowid";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON t.fk_mode_reglement = p.id";
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid';
- if ($id) $sql.= " WHERE t.rowid=".$id;
- if ($ref) $sql.= " WHERE t.ref='".$this->db->escape($ref)."' AND t.entity IN (".getEntity('supplier_invoice').")";
+ $sql .= " t.rowid,";
+ $sql .= " t.ref,";
+ $sql .= " t.ref_supplier,";
+ $sql .= " t.entity,";
+ $sql .= " t.type,";
+ $sql .= " t.fk_soc,";
+ $sql .= " t.datec,";
+ $sql .= " t.datef,";
+ $sql .= " t.tms,";
+ $sql .= " t.libelle as label,";
+ $sql .= " t.paye,";
+ $sql .= " t.amount,";
+ $sql .= " t.remise,";
+ $sql .= " t.close_code,";
+ $sql .= " t.close_note,";
+ $sql .= " t.tva,";
+ $sql .= " t.localtax1,";
+ $sql .= " t.localtax2,";
+ $sql .= " t.total_ht,";
+ $sql .= " t.total_tva,";
+ $sql .= " t.total_ttc,";
+ $sql .= " t.fk_statut,";
+ $sql .= " t.fk_user_author,";
+ $sql .= " t.fk_user_valid,";
+ $sql .= " t.fk_facture_source,";
+ $sql .= " t.fk_projet as fk_project,";
+ $sql .= " t.fk_cond_reglement,";
+ $sql .= " t.fk_account,";
+ $sql .= " t.fk_mode_reglement,";
+ $sql .= " t.date_lim_reglement,";
+ $sql .= " t.note_private,";
+ $sql .= " t.note_public,";
+ $sql .= " t.model_pdf,";
+ $sql .= " t.import_key,";
+ $sql .= " t.extraparams,";
+ $sql .= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,";
+ $sql .= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle,";
+ $sql .= ' s.nom as socnom, s.rowid as socid,';
+ $sql .= ' t.fk_incoterms, t.location_incoterms,';
+ $sql .= " i.libelle as label_incoterms,";
+ $sql .= ' t.fk_multicurrency, t.multicurrency_code, t.multicurrency_tx, t.multicurrency_total_ht, t.multicurrency_total_tva, t.multicurrency_total_ttc';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as t';
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON t.fk_cond_reglement = cr.rowid";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON t.fk_mode_reglement = p.id";
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid';
+ if ($id) $sql .= " WHERE t.rowid=".$id;
+ if ($ref) $sql .= " WHERE t.ref='".$this->db->escape($ref)."' AND t.entity IN (".getEntity('supplier_invoice').")";
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
- $this->id = $obj->rowid;
- $this->ref = $obj->ref?$obj->ref:$obj->rowid; // We take rowid if ref is empty for backward compatibility
+ $this->id = $obj->rowid;
+ $this->ref = $obj->ref ? $obj->ref : $obj->rowid; // We take rowid if ref is empty for backward compatibility
- $this->ref_supplier = $obj->ref_supplier;
+ $this->ref_supplier = $obj->ref_supplier;
$this->entity = $obj->entity;
- $this->type = empty($obj->type)? self::TYPE_STANDARD:$obj->type;
+ $this->type = empty($obj->type) ? self::TYPE_STANDARD : $obj->type;
$this->fk_soc = $obj->fk_soc;
$this->datec = $this->db->jdate($obj->datec);
$this->date = $this->db->jdate($obj->datef);
$this->datep = $this->db->jdate($obj->datef);
- $this->tms = $this->db->jdate($obj->tms);
- $this->libelle = $obj->label; // deprecated
+ $this->tms = $this->db->jdate($obj->tms);
+ $this->libelle = $obj->label; // deprecated
$this->label = $obj->label;
$this->paye = $obj->paye;
$this->paid = $obj->paye;
@@ -645,7 +698,7 @@ class FactureFournisseur extends CommonInvoice
$this->remise = $obj->remise;
$this->close_code = $obj->close_code;
$this->close_note = $obj->close_note;
- $this->tva = $obj->tva;
+ $this->tva = $obj->tva;
$this->total_localtax1 = $obj->localtax1;
$this->total_localtax2 = $obj->localtax2;
$this->total_ht = $obj->total_ht;
@@ -758,44 +811,44 @@ class FactureFournisseur extends CommonInvoice
$line = new SupplierInvoiceLine($this->db);
- $line->id = $obj->rowid;
- $line->rowid = $obj->rowid;
- $line->description = $obj->description;
- $line->date_start = $obj->date_start;
- $line->date_end = $obj->date_end;
+ $line->id = $obj->rowid;
+ $line->rowid = $obj->rowid;
+ $line->description = $obj->description;
+ $line->date_start = $obj->date_start;
+ $line->date_end = $obj->date_end;
- $line->product_ref = $obj->product_ref;
- $line->ref = $obj->product_ref;
+ $line->product_ref = $obj->product_ref;
+ $line->ref = $obj->product_ref;
$line->ref_supplier = $obj->ref_supplier;
$line->libelle = $obj->label;
$line->label = $obj->label;
$line->product_desc = $obj->product_desc;
- $line->subprice = $obj->pu_ht;
- $line->pu_ht = $obj->pu_ht;
+ $line->subprice = $obj->pu_ht;
+ $line->pu_ht = $obj->pu_ht;
$line->pu_ttc = $obj->pu_ttc;
- $line->vat_src_code = $obj->vat_src_code;
+ $line->vat_src_code = $obj->vat_src_code;
$line->tva_tx = $obj->tva_tx;
$line->localtax1_tx = $obj->localtax1_tx;
$line->localtax2_tx = $obj->localtax2_tx;
$line->localtax1_type = $obj->localtax1_type;
$line->localtax2_type = $obj->localtax2_type;
$line->qty = $obj->qty;
- $line->remise_percent = $obj->remise_percent;
- $line->tva = $obj->total_tva; // deprecated
+ $line->remise_percent = $obj->remise_percent;
+ $line->tva = $obj->total_tva; // deprecated
$line->total_ht = $obj->total_ht;
$line->total_ttc = $obj->total_ttc;
$line->total_tva = $obj->total_tva;
$line->total_localtax1 = $obj->total_localtax1;
$line->total_localtax2 = $obj->total_localtax2;
- $line->fk_facture_fourn = $obj->fk_facture_fourn;
- $line->fk_product = $obj->fk_product;
+ $line->fk_facture_fourn = $obj->fk_facture_fourn;
+ $line->fk_product = $obj->fk_product;
$line->product_type = $obj->product_type;
$line->product_label = $obj->label;
- $line->info_bits = $obj->info_bits;
+ $line->info_bits = $obj->info_bits;
$line->fk_parent_line = $obj->fk_parent_line;
$line->special_code = $obj->special_code;
- $line->rang = $obj->rang;
+ $line->rang = $obj->rang;
$line->fk_unit = $obj->fk_unit;
// Multicurrency
@@ -832,40 +885,40 @@ class FactureFournisseur extends CommonInvoice
public function update($user = null, $notrigger = 0)
{
global $conf, $langs;
- $error=0;
+ $error = 0;
// Clean parameters
- if (empty($this->type)) $this->type= self::TYPE_STANDARD;
- if (isset($this->ref)) $this->ref=trim($this->ref);
- if (isset($this->ref_supplier)) $this->ref_supplier=trim($this->ref_supplier);
- if (isset($this->entity)) $this->entity=trim($this->entity);
- if (isset($this->type)) $this->type=trim($this->type);
- if (isset($this->fk_soc)) $this->fk_soc=trim($this->fk_soc);
- if (isset($this->label)) $this->label=trim($this->label);
- if (isset($this->libelle)) $this->libelle=trim($this->libelle); // deprecated
- if (isset($this->paye)) $this->paye=trim($this->paye);
- if (isset($this->amount)) $this->amount=trim($this->amount);
- if (isset($this->remise)) $this->remise=trim($this->remise);
- if (isset($this->close_code)) $this->close_code=trim($this->close_code);
- if (isset($this->close_note)) $this->close_note=trim($this->close_note);
- if (isset($this->tva)) $this->tva=trim($this->tva);
- if (isset($this->localtax1)) $this->localtax1=trim($this->localtax1);
- if (isset($this->localtax2)) $this->localtax2=trim($this->localtax2);
- if (empty($this->total_ht)) $this->total_ht=0;
- if (empty($this->total_tva)) $this->total_tva=0;
+ if (empty($this->type)) $this->type = self::TYPE_STANDARD;
+ if (isset($this->ref)) $this->ref = trim($this->ref);
+ if (isset($this->ref_supplier)) $this->ref_supplier = trim($this->ref_supplier);
+ if (isset($this->entity)) $this->entity = trim($this->entity);
+ if (isset($this->type)) $this->type = trim($this->type);
+ if (isset($this->fk_soc)) $this->fk_soc = trim($this->fk_soc);
+ if (isset($this->label)) $this->label = trim($this->label);
+ if (isset($this->libelle)) $this->libelle = trim($this->libelle); // deprecated
+ if (isset($this->paye)) $this->paye = trim($this->paye);
+ if (isset($this->amount)) $this->amount = trim($this->amount);
+ if (isset($this->remise)) $this->remise = trim($this->remise);
+ if (isset($this->close_code)) $this->close_code = trim($this->close_code);
+ if (isset($this->close_note)) $this->close_note = trim($this->close_note);
+ if (isset($this->tva)) $this->tva = trim($this->tva);
+ if (isset($this->localtax1)) $this->localtax1 = trim($this->localtax1);
+ if (isset($this->localtax2)) $this->localtax2 = trim($this->localtax2);
+ if (empty($this->total_ht)) $this->total_ht = 0;
+ if (empty($this->total_tva)) $this->total_tva = 0;
// if (isset($this->total_localtax1)) $this->total_localtax1=trim($this->total_localtax1);
// if (isset($this->total_localtax2)) $this->total_localtax2=trim($this->total_localtax2);
- if (isset($this->total_ttc)) $this->total_ttc=trim($this->total_ttc);
- if (isset($this->statut)) $this->statut=(int) $this->statut;
- if (isset($this->author)) $this->author=trim($this->author);
- if (isset($this->fk_user_valid)) $this->fk_user_valid=trim($this->fk_user_valid);
- if (isset($this->fk_facture_source)) $this->fk_facture_source=trim($this->fk_facture_source);
- if (isset($this->fk_project)) $this->fk_project=trim($this->fk_project);
- if (isset($this->cond_reglement_id)) $this->cond_reglement_id=trim($this->cond_reglement_id);
- if (isset($this->note_private)) $this->note=trim($this->note_private);
- if (isset($this->note_public)) $this->note_public=trim($this->note_public);
- if (isset($this->model_pdf)) $this->model_pdf=trim($this->model_pdf);
- if (isset($this->import_key)) $this->import_key=trim($this->import_key);
+ if (isset($this->total_ttc)) $this->total_ttc = trim($this->total_ttc);
+ if (isset($this->statut)) $this->statut = (int) $this->statut;
+ if (isset($this->author)) $this->author = trim($this->author);
+ if (isset($this->fk_user_valid)) $this->fk_user_valid = trim($this->fk_user_valid);
+ if (isset($this->fk_facture_source)) $this->fk_facture_source = trim($this->fk_facture_source);
+ if (isset($this->fk_project)) $this->fk_project = trim($this->fk_project);
+ if (isset($this->cond_reglement_id)) $this->cond_reglement_id = trim($this->cond_reglement_id);
+ if (isset($this->note_private)) $this->note = trim($this->note_private);
+ if (isset($this->note_public)) $this->note_public = trim($this->note_public);
+ if (isset($this->model_pdf)) $this->model_pdf = trim($this->model_pdf);
+ if (isset($this->import_key)) $this->import_key = trim($this->import_key);
// Check parameters
@@ -873,38 +926,38 @@ class FactureFournisseur extends CommonInvoice
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn SET";
- $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").",";
- $sql.= " ref_supplier=".(isset($this->ref_supplier)?"'".$this->db->escape($this->ref_supplier)."'":"null").",";
- $sql.= " entity=".(isset($this->entity)?$this->entity:"null").",";
- $sql.= " type=".(isset($this->type)?$this->type:"null").",";
- $sql.= " fk_soc=".(isset($this->fk_soc)?$this->fk_soc:"null").",";
- $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
- $sql.= " datef=".(dol_strlen($this->date)!=0 ? "'".$this->db->idate($this->date)."'" : 'null').",";
- if (dol_strlen($this->tms) != 0) $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
- $sql.= " libelle=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
- $sql.= " paye=".(isset($this->paye)?$this->paye:"null").",";
- $sql.= " amount=".(isset($this->amount)?$this->amount:"null").",";
- $sql.= " remise=".(isset($this->remise)?$this->remise:"null").",";
- $sql.= " close_code=".(isset($this->close_code)?"'".$this->db->escape($this->close_code)."'":"null").",";
- $sql.= " close_note=".(isset($this->close_note)?"'".$this->db->escape($this->close_note)."'":"null").",";
- $sql.= " tva=".(isset($this->tva)?$this->tva:"null").",";
- $sql.= " localtax1=".(isset($this->localtax1)?$this->localtax1:"null").",";
- $sql.= " localtax2=".(isset($this->localtax2)?$this->localtax2:"null").",";
- $sql.= " total_ht=".(isset($this->total_ht)?$this->total_ht:"null").",";
- $sql.= " total_tva=".(isset($this->total_tva)?$this->total_tva:"null").",";
- $sql.= " total_ttc=".(isset($this->total_ttc)?$this->total_ttc:"null").",";
- $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").",";
- $sql.= " fk_user_author=".(isset($this->author)?$this->author:"null").",";
- $sql.= " fk_user_valid=".(isset($this->fk_user_valid)?$this->fk_user_valid:"null").",";
- $sql.= " fk_facture_source=".(isset($this->fk_facture_source)?$this->fk_facture_source:"null").",";
- $sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").",";
- $sql.= " fk_cond_reglement=".(isset($this->cond_reglement_id)?$this->cond_reglement_id:"null").",";
- $sql.= " date_lim_reglement=".(dol_strlen($this->date_echeance)!=0 ? "'".$this->db->idate($this->date_echeance)."'" : 'null').",";
- $sql.= " note_private=".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null").",";
- $sql.= " note_public=".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null").",";
- $sql.= " model_pdf=".(isset($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null").",";
- $sql.= " import_key=".(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null")."";
- $sql.= " WHERE rowid=".$this->id;
+ $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").",";
+ $sql .= " ref_supplier=".(isset($this->ref_supplier) ? "'".$this->db->escape($this->ref_supplier)."'" : "null").",";
+ $sql .= " entity=".(isset($this->entity) ? $this->entity : "null").",";
+ $sql .= " type=".(isset($this->type) ? $this->type : "null").",";
+ $sql .= " fk_soc=".(isset($this->fk_soc) ? $this->fk_soc : "null").",";
+ $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
+ $sql .= " datef=".(dol_strlen($this->date) != 0 ? "'".$this->db->idate($this->date)."'" : 'null').",";
+ if (dol_strlen($this->tms) != 0) $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
+ $sql .= " libelle=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").",";
+ $sql .= " paye=".(isset($this->paye) ? $this->paye : "null").",";
+ $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
+ $sql .= " remise=".(isset($this->remise) ? $this->remise : "null").",";
+ $sql .= " close_code=".(isset($this->close_code) ? "'".$this->db->escape($this->close_code)."'" : "null").",";
+ $sql .= " close_note=".(isset($this->close_note) ? "'".$this->db->escape($this->close_note)."'" : "null").",";
+ $sql .= " tva=".(isset($this->tva) ? $this->tva : "null").",";
+ $sql .= " localtax1=".(isset($this->localtax1) ? $this->localtax1 : "null").",";
+ $sql .= " localtax2=".(isset($this->localtax2) ? $this->localtax2 : "null").",";
+ $sql .= " total_ht=".(isset($this->total_ht) ? $this->total_ht : "null").",";
+ $sql .= " total_tva=".(isset($this->total_tva) ? $this->total_tva : "null").",";
+ $sql .= " total_ttc=".(isset($this->total_ttc) ? $this->total_ttc : "null").",";
+ $sql .= " fk_statut=".(isset($this->statut) ? $this->statut : "null").",";
+ $sql .= " fk_user_author=".(isset($this->author) ? $this->author : "null").",";
+ $sql .= " fk_user_valid=".(isset($this->fk_user_valid) ? $this->fk_user_valid : "null").",";
+ $sql .= " fk_facture_source=".(isset($this->fk_facture_source) ? $this->fk_facture_source : "null").",";
+ $sql .= " fk_projet=".(isset($this->fk_project) ? $this->fk_project : "null").",";
+ $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").",";
+ $sql .= " date_lim_reglement=".(dol_strlen($this->date_echeance) != 0 ? "'".$this->db->idate($this->date_echeance)."'" : 'null').",";
+ $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";
+ $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").",";
+ $sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").",";
+ $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null")."";
+ $sql .= " WHERE rowid=".$this->id;
$this->db->begin();
@@ -1313,13 +1366,13 @@ class FactureFournisseur extends CommonInvoice
*/
public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0)
{
- global $conf,$langs;
+ global $conf, $langs;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $now=dol_now();
+ $now = dol_now();
- $error=0;
+ $error = 0;
dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number.', idwarehouse='.$idwarehouse);
// Force to have object complete for checks
@@ -1385,10 +1438,10 @@ class FactureFournisseur extends CommonInvoice
$mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
// We increase stock for product
- $up_ht_disc=$this->lines[$i]->pu_ht;
- if (! empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc=price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU');
- if ($this->type == FactureFournisseur::TYPE_CREDIT_NOTE) $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("InvoiceValidatedInDolibarr", $num));
- else $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("InvoiceValidatedInDolibarr", $num));
+ $up_ht_disc = $this->lines[$i]->pu_ht;
+ if (!empty($this->lines[$i]->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc = price2num($up_ht_disc * (100 - $this->lines[$i]->remise_percent) / 100, 'MU');
+ if ($this->type == FactureFournisseur::TYPE_CREDIT_NOTE) $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("InvoiceValidatedInDolibarr", $num));
+ else $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $up_ht_disc, $langs->trans("InvoiceValidatedInDolibarr", $num));
if ($result < 0) { $error++; }
unset($this->line);
}
@@ -1412,17 +1465,17 @@ class FactureFournisseur extends CommonInvoice
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
// Now we rename also files into index
- $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref)+1).")), filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->db->escape($this->newref)."'";
- $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->db->escape($this->ref)."' and entity = ".$conf->entity;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->db->escape($this->newref)."'";
+ $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'fournisseur/facture/".get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
- if (! $resql) { $error++; $this->error = $this->db->lasterror(); }
+ if (!$resql) { $error++; $this->error = $this->db->lasterror(); }
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$oldref;
$dirdest = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$newref;
- if (! $error && file_exists($dirsource))
+ if (!$error && file_exists($dirsource))
{
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
@@ -1521,16 +1574,16 @@ class FactureFournisseur extends CommonInvoice
$mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
// We increase stock for product
- if ($this->type == FactureFournisseur::TYPE_CREDIT_NOTE) $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref));
- else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref));
+ if ($this->type == FactureFournisseur::TYPE_CREDIT_NOTE) $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref));
+ else $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceBackToDraftInDolibarr", $this->ref));
}
}
}
// Triggers call
- if (! $error && empty($notrigger))
+ if (!$error && empty($notrigger))
{
// Call trigger
- $result=$this->call_trigger('BILL_SUPPLIER_UNVALIDATE', $user);
+ $result = $this->call_trigger('BILL_SUPPLIER_UNVALIDATE', $user);
if ($result < 0) $error++;
// End call triggers
}
@@ -1595,27 +1648,27 @@ class FactureFournisseur extends CommonInvoice
if ($this->statut == self::STATUS_DRAFT)
{
// Clean parameters
- if (empty($remise_percent)) $remise_percent=0;
- if (empty($qty)) $qty=0;
- if (empty($info_bits)) $info_bits=0;
- if (empty($rang)) $rang=0;
- if (empty($ventil)) $ventil=0;
- if (empty($txtva)) $txtva=0;
- if (empty($txlocaltax1)) $txlocaltax1=0;
- if (empty($txlocaltax2)) $txlocaltax2=0;
+ if (empty($remise_percent)) $remise_percent = 0;
+ if (empty($qty)) $qty = 0;
+ if (empty($info_bits)) $info_bits = 0;
+ if (empty($rang)) $rang = 0;
+ if (empty($ventil)) $ventil = 0;
+ if (empty($txtva)) $txtva = 0;
+ if (empty($txlocaltax1)) $txlocaltax1 = 0;
+ if (empty($txlocaltax2)) $txlocaltax2 = 0;
- $remise_percent=price2num($remise_percent);
- $qty=price2num($qty);
- $pu=price2num($pu);
- $txlocaltax1=price2num($txlocaltax1);
- $txlocaltax2=price2num($txlocaltax2);
+ $remise_percent = price2num($remise_percent);
+ $qty = price2num($qty);
+ $pu = price2num($pu);
+ $txlocaltax1 = price2num($txlocaltax1);
+ $txlocaltax2 = price2num($txlocaltax2);
if (!preg_match('/\((.*)\)/', $txtva)) {
- $txtva = price2num($txtva); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1'
+ $txtva = price2num($txtva); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1'
}
if ($date_start && $date_end && $date_start > $date_end) {
$langs->load("errors");
- $this->error=$langs->trans('ErrorStartDateGreaterEnd');
+ $this->error = $langs->trans('ErrorStartDateGreaterEnd');
return -1;
}
@@ -1952,8 +2005,8 @@ class FactureFournisseur extends CommonInvoice
if (is_array($array_options) && count($array_options) > 0) {
// We replace values in this->line->array_options only for entries defined into $array_options
- foreach($array_options as $key => $value) {
- $this->line->array_options[$key] = $array_options[$key];
+ foreach ($array_options as $key => $value) {
+ $line->array_options[$key] = $array_options[$key];
}
}
@@ -2201,31 +2254,31 @@ class FactureFournisseur extends CommonInvoice
global $conf, $langs;
$sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as ff';
- if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= ' WHERE ff.paye=0';
- $sql.= ' AND ff.fk_statut > 0';
- $sql.= " AND ff.entity = ".$conf->entity;
- if ($user->socid) $sql.=' AND ff.fk_soc = '.$user->socid;
- if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND ff.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as ff';
+ if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= ' WHERE ff.paye=0';
+ $sql .= ' AND ff.fk_statut > 0';
+ $sql .= " AND ff.entity = ".$conf->entity;
+ if ($user->socid) $sql .= ' AND ff.fk_soc = '.$user->socid;
+ if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND ff.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql)
{
$langs->load("bills");
- $now=dol_now();
+ $now = dol_now();
$response = new WorkboardResponse();
- $response->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24;
- $response->label=$langs->trans("SupplierBillsToPay");
- $response->labelShort=$langs->trans("StatusToPay");
+ $response->warning_delay = $conf->facture->fournisseur->warning_delay / 60 / 60 / 24;
+ $response->label = $langs->trans("SupplierBillsToPay");
+ $response->labelShort = $langs->trans("StatusToPay");
- $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?search_status=1&mainmenu=billing&leftmenu=suppliers_bills';
- $response->img=img_object($langs->trans("Bills"), "bill");
+ $response->url = DOL_URL_ROOT.'/fourn/facture/list.php?search_status=1&mainmenu=billing&leftmenu=suppliers_bills';
+ $response->img = img_object($langs->trans("Bills"), "bill");
$facturestatic = new FactureFournisseur($this->db);
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
$response->nbtodo++;
@@ -2234,6 +2287,7 @@ class FactureFournisseur extends CommonInvoice
if ($facturestatic->hasDelay()) {
$response->nbtodolate++;
+ $response->url_late = DOL_URL_ROOT.'/fourn/facture/list.php?option=late&mainmenu=billing&leftmenu=suppliers_bills';
}
}
$this->db->free($resql);
@@ -2275,58 +2329,58 @@ class FactureFournisseur extends CommonInvoice
if ($option !== 'nolink')
{
// Add param to save lastsearch_values or not
- $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
- if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
+ $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
+ if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
}
- $picto=$this->picto;
- if ($this->type == self::TYPE_REPLACEMENT) $picto.='r'; // Replacement invoice
- if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note
- if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice
+ $picto = $this->picto;
+ if ($this->type == self::TYPE_REPLACEMENT) $picto .= 'r'; // Replacement invoice
+ if ($this->type == self::TYPE_CREDIT_NOTE) $picto .= 'a'; // Credit note
+ if ($this->type == self::TYPE_DEPOSIT) $picto .= 'd'; // Deposit invoice
- $label = '' . $langs->trans("ShowSupplierInvoice") . ' ';
- if (! empty($this->ref))
- $label .= '' . $langs->trans('Ref') . ': ' . $this->ref;
- if (! empty($this->ref_supplier))
- $label.= '' . $langs->trans('RefSupplier') . ': ' . $this->ref_supplier;
- if (! empty($this->label))
- $label.= '' . $langs->trans('Label') . ': ' . $this->label;
- if (! empty($this->date))
- $label .= '' . $langs->trans('Date') . ': ' . dol_print_date($this->date, 'day');
- if (! empty($this->total_ht))
- $label.= '' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
- if (! empty($this->total_tva))
- $label.= '' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
- if (! empty($this->total_ttc))
- $label.= '' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
- if ($this->type == self::TYPE_REPLACEMENT) $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref;
- elseif ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref;
- elseif ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref;
- if ($moretitle) $label.=' - '.$moretitle;
+ $label = ''.$langs->trans("ShowSupplierInvoice").' ';
+ if (!empty($this->ref))
+ $label .= ''.$langs->trans('Ref').': '.$this->ref;
+ if (!empty($this->ref_supplier))
+ $label .= ''.$langs->trans('RefSupplier').': '.$this->ref_supplier;
+ if (!empty($this->label))
+ $label .= ''.$langs->trans('Label').': '.$this->label;
+ if (!empty($this->date))
+ $label .= ''.$langs->trans('Date').': '.dol_print_date($this->date, 'day');
+ if (!empty($this->total_ht))
+ $label .= ''.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
+ if (!empty($this->total_tva))
+ $label .= ''.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
+ if (!empty($this->total_ttc))
+ $label .= ''.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
+ if ($this->type == self::TYPE_REPLACEMENT) $label = $langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref;
+ elseif ($this->type == self::TYPE_CREDIT_NOTE) $label = $langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref;
+ elseif ($this->type == self::TYPE_DEPOSIT) $label = $langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref;
+ if ($moretitle) $label .= ' - '.$moretitle;
- $ref=$this->ref;
- if (empty($ref)) $ref=$this->id;
+ $ref = $this->ref;
+ if (empty($ref)) $ref = $this->id;
- $linkclose='';
+ $linkclose = '';
if (empty($notooltip))
{
- if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
- $label=$langs->trans("ShowSupplierInvoice");
- $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
+ $label = $langs->trans("ShowSupplierInvoice");
+ $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
- $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
- $linkclose.=' class="classfortooltip"';
+ $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose .= ' class="classfortooltip"';
}
$linkstart = '';
- $linkend=' ';
+ $linkstart .= $linkclose.'>';
+ $linkend = '';
$result .= $linkstart;
- if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
- if ($withpicto != 2) $result.= ($max?dol_trunc($ref, $max):$ref);
+ if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ if ($withpicto != 2) $result .= ($max ?dol_trunc($ref, $max) : $ref);
$result .= $linkend;
if ($addlinktonotes)
@@ -2394,7 +2448,7 @@ class FactureFournisseur extends CommonInvoice
}
else
{
- $this->error=$obj->error;
+ $this->error = $obj->error;
//dol_print_error($db,get_class($this)."::getNextNumRef ".$obj->error);
return false;
}
@@ -2519,27 +2573,27 @@ class FactureFournisseur extends CommonInvoice
// phpcs:enable
global $conf, $user;
- $this->nb=array();
+ $this->nb = array();
$clause = "WHERE";
$sql = "SELECT count(f.rowid) as nb";
- $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
+ $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON f.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->socid)
{
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
- $sql.= " WHERE sc.fk_user = " .$user->id;
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
+ $sql .= " WHERE sc.fk_user = ".$user->id;
$clause = "AND";
}
- $sql.= " ".$clause." f.entity = ".$conf->entity;
+ $sql .= " ".$clause." f.entity = ".$conf->entity;
- $resql=$this->db->query($sql);
+ $resql = $this->db->query($sql);
if ($resql)
{
- while ($obj=$this->db->fetch_object($resql))
+ while ($obj = $this->db->fetch_object($resql))
{
- $this->nb["supplier_invoices"]=$obj->nb;
+ $this->nb["supplier_invoices"] = $obj->nb;
}
$this->db->free($resql);
return 1;
@@ -2564,16 +2618,16 @@ class FactureFournisseur extends CommonInvoice
{
global $langs;
- $error=0;
+ $error = 0;
- $object=new FactureFournisseur($this->db);
+ $object = new FactureFournisseur($this->db);
$this->db->begin();
// Load source object
$object->fetch($fromid);
- $object->id=0;
- $object->statut=self::STATUS_DRAFT;
+ $object->id = 0;
+ $object->statut = self::STATUS_DRAFT;
// Clear fields
$object->ref_supplier = (empty($this->ref_supplier) ? $langs->trans("CopyOf").' '.$object->ref_supplier : $this->ref_supplier);
@@ -2663,7 +2717,7 @@ class FactureFournisseur extends CommonInvoice
}
else
{
- $modelpath = "core/modules/supplier_invoice/pdf/";
+ $modelpath = "core/modules/supplier_invoice/doc/";
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
}
@@ -2728,9 +2782,9 @@ class FactureFournisseur extends CommonInvoice
$sql = "SELECT fk_invoice_supplier FROM ".MAIN_DB_PREFIX."societe_remise_except WHERE fk_invoice_supplier_source=".$this->id;
$resql = $db->query($sql);
- if(!empty($resql)){
+ if (!empty($resql)) {
$obj = $db->fetch_object($resql);
- if(!empty($obj->fk_invoice_supplier))$isUsed=true;
+ if (!empty($obj->fk_invoice_supplier))$isUsed = true;
}
return $isUsed;
@@ -2982,14 +3036,14 @@ class SupplierInvoiceLine extends CommonObjectLine
public function fetch($rowid)
{
$sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.date_start, f.date_end, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx';
- $sql.= ', f.localtax1_type, f.localtax2_type, f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 ';
- $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_facture_fourn, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
- $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc';
- $sql.= ', f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, multicurrency_total_ttc';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
- $sql.= ' WHERE f.rowid = '.$rowid;
- $sql.= ' ORDER BY f.rang, f.rowid';
+ $sql .= ', f.localtax1_type, f.localtax2_type, f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 ';
+ $sql .= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_facture_fourn, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
+ $sql .= ', p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc';
+ $sql .= ', f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, multicurrency_total_ttc';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
+ $sql .= ' WHERE f.rowid = '.$rowid;
+ $sql .= ' ORDER BY f.rang, f.rowid';
$query = $this->db->query($sql);
@@ -3024,21 +3078,21 @@ class SupplierInvoiceLine extends CommonObjectLine
$this->localtax1_type = $obj->localtax1_type;
$this->localtax2_type = $obj->localtax2_type;
$this->qty = $obj->qty;
- $this->remise_percent = $obj->remise_percent;
- $this->tva = $obj->total_tva; // deprecated
- $this->total_ht = $obj->total_ht;
+ $this->remise_percent = $obj->remise_percent;
+ $this->tva = $obj->total_tva; // deprecated
+ $this->total_ht = $obj->total_ht;
$this->total_tva = $obj->total_tva;
$this->total_localtax1 = $obj->total_localtax1;
$this->total_localtax2 = $obj->total_localtax2;
$this->total_ttc = $obj->total_ttc;
$this->fk_product = $obj->fk_product;
- $this->product_type = $obj->product_type;
+ $this->product_type = $obj->product_type;
$this->product_label = $obj->product_label;
$this->info_bits = $obj->info_bits;
- $this->tva_npr = ($obj->info_bits & 1 == 1) ? 1 : 0;
+ $this->tva_npr = ($obj->info_bits & 1 == 1) ? 1 : 0;
$this->fk_parent_line = $obj->fk_parent_line;
- $this->special_code = $obj->special_code;
- $this->rang = $obj->rang;
+ $this->special_code = $obj->special_code;
+ $this->rang = $obj->rang;
$this->fk_unit = $obj->fk_unit;
$this->multicurrency_subprice = $obj->multicurrency_subprice;
@@ -3223,50 +3277,50 @@ class SupplierInvoiceLine extends CommonObjectLine
*/
public function insert($notrigger = 0)
{
- global $user,$conf;
+ global $user, $conf;
- $error=0;
+ $error = 0;
dol_syslog(get_class($this)."::insert rang=".$this->rang, LOG_DEBUG);
// Clean parameters
- $this->desc=trim($this->desc);
- if (empty($this->tva_tx)) $this->tva_tx=0;
- if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
- if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
- if (empty($this->localtax1_type)) $this->localtax1_type='0';
- if (empty($this->localtax2_type)) $this->localtax2_type='0';
- if (empty($this->total_tva)) $this->total_tva=0;
- if (empty($this->total_localtax1)) $this->total_localtax1=0;
- if (empty($this->total_localtax2)) $this->total_localtax2=0;
- if (empty($this->rang)) $this->rang=0;
- if (empty($this->remise_percent)) $this->remise_percent=0;
- if (empty($this->info_bits)) $this->info_bits=0;
- if (empty($this->subprice)) $this->subprice=0;
- if (empty($this->special_code)) $this->special_code=0;
- if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
- if (! isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100;
+ $this->desc = trim($this->desc);
+ if (empty($this->tva_tx)) $this->tva_tx = 0;
+ if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
+ if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
+ if (empty($this->localtax1_type)) $this->localtax1_type = '0';
+ if (empty($this->localtax2_type)) $this->localtax2_type = '0';
+ if (empty($this->total_tva)) $this->total_tva = 0;
+ if (empty($this->total_localtax1)) $this->total_localtax1 = 0;
+ if (empty($this->total_localtax2)) $this->total_localtax2 = 0;
+ if (empty($this->rang)) $this->rang = 0;
+ if (empty($this->remise_percent)) $this->remise_percent = 0;
+ if (empty($this->info_bits)) $this->info_bits = 0;
+ if (empty($this->subprice)) $this->subprice = 0;
+ if (empty($this->special_code)) $this->special_code = 0;
+ if (empty($this->fk_parent_line)) $this->fk_parent_line = 0;
+ if (!isset($this->situation_percent) || $this->situation_percent > 100 || (string) $this->situation_percent == '') $this->situation_percent = 100;
- if (empty($this->pa_ht)) $this->pa_ht=0;
- if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice=0;
- if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0;
- if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0;
- if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0;
+ if (empty($this->pa_ht)) $this->pa_ht = 0;
+ if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0;
+ if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht = 0;
+ if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva = 0;
+ if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc = 0;
// Check parameters
if ($this->product_type < 0)
{
- $this->error='ErrorProductTypeMustBe0orMore';
+ $this->error = 'ErrorProductTypeMustBe0orMore';
return -1;
}
- if (! empty($this->fk_product))
+ if (!empty($this->fk_product))
{
// Check product exists
- $result=Product::isExistingObject('product', $this->fk_product);
+ $result = Product::isExistingObject('product', $this->fk_product);
if ($result <= 0)
{
- $this->error='ErrorProductIdDoesNotExists';
+ $this->error = 'ErrorProductIdDoesNotExists';
return -1;
}
}
diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php
index 717a617b0ca..332e33ece59 100644
--- a/htdocs/fourn/class/fournisseur.product.class.php
+++ b/htdocs/fourn/class/fournisseur.product.class.php
@@ -273,6 +273,7 @@ class ProductFournisseur extends Product
$charges = price2num($charges, 'MU');
$qty = price2num($qty, 'MS');
$unitBuyPrice = price2num($buyprice / $qty, 'MU');
+ $packaging = ($this->packaging < $qty) ? $qty : $this->packaging;
$error = 0;
$now = dol_now();
@@ -359,6 +360,7 @@ class ProductFournisseur extends Product
$sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").",";
$sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
$sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging = ".(empty($packaging) ? 1 : $packaging);
$sql .= " WHERE rowid = ".$this->product_fourn_price_id;
// TODO Add price_base_type and price_ttc
@@ -408,6 +410,7 @@ class ProductFournisseur extends Product
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
$sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
$sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)";
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", packaging";
$sql .= " values(";
$sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').",";
$sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').",";
@@ -435,13 +438,14 @@ class ProductFournisseur extends Product
$sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").",";
$sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
$sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging));
$sql .= ")";
$this->product_fourn_price_id = 0;
$resql = $this->db->query($sql);
if ($resql) {
- $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_fournisseur_price");
+ $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price");
}
else {
$error++;
@@ -501,6 +505,7 @@ class ProductFournisseur extends Product
$sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,";
$sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,";
$sql .= " pfp.barcode, pfp.fk_barcode_type";
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging";
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql .= " WHERE pfp.rowid = ".(int) $rowid;
@@ -544,6 +549,12 @@ class ProductFournisseur extends Product
$this->fourn_barcode = $obj->barcode;
$this->fourn_fk_barcode_type = $obj->fk_barcode_type;
}
+
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
+ $this->packaging = $obj->packaging;
+ if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty;
+ }
+
if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression))
{
$priceparser = new PriceParser($this->db);
@@ -598,7 +609,8 @@ class ProductFournisseur extends Product
$sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,";
$sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,";
$sql .= " pfp.barcode, pfp.fk_barcode_type";
- $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s";
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= ", pfp.packaging";
+ $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")";
$sql .= " AND pfp.fk_soc = s.rowid";
$sql .= " AND s.status=1"; // only enabled company selected
@@ -647,6 +659,11 @@ class ProductFournisseur extends Product
$prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"];
$prodfourn->fourn_multicurrency_code = $record["multicurrency_code"];
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
+ $prodfourn->packaging = $record["packaging"];
+ if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty;
+ }
+
if ($conf->barcode->enabled) {
$prodfourn->barcode = $record["barcode"];
$prodfourn->fk_barcode_type = $record["fk_barcode_type"];
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 59c01d95297..9adad176ab2 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -1907,7 +1907,7 @@ elseif (!empty($object->id))
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1);
}
- $parameters = array('lineid'=>$lineid);
+ $parameters = array('formConfirm' => $formconfirm, 'lineid'=>$lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index eb9093888af..dd55bb36ffb 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -273,7 +273,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) {
$dto = GETPOST("dto_".$reg[1].'_'.$reg[2]);
//update supplier price
- if (isset($_POST[$saveprice])) {
+ if (GETPOSTISSET($saveprice)) {
// TODO Use class
$sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql .= " SET unitprice='".GETPOST($pu)."'";
diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php
index b09b67ba1d3..45abd70e0be 100644
--- a/htdocs/fourn/commande/index.php
+++ b/htdocs/fourn/commande/index.php
@@ -159,17 +159,14 @@ else
/*
* Legends / Status
- *
- * Motivo: Mostrar todos os Status e dar a possibilidade de filtrar apenas um deles
- * Reason: Show all Status and give the possibility to filter only one
*/
-$sql = "SELECT count(cf.rowid), fk_statut";
+$sql = "SELECT count(cf.rowid) as nb, cf.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE cf.fk_soc = s.rowid";
-$sql .= " AND s.entity = ".$conf->entity;
+$sql .= " AND cf.entity IN (".getEntity("supplier_order").")"; // Thirdparty sharing is mandatory with supplier order sharing
if ($user->socid) $sql .= ' AND cf.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
$sql .= " GROUP BY cf.fk_statut";
@@ -189,11 +186,11 @@ if ($resql)
while ($i < $num)
{
- $row = $db->fetch_row($resql);
+ $obj = $db->fetch_object($resql);
print '';
- print ''.$commandestatic->LibStatut($row[1]).' ';
- print ''.$row[0].' '.$commandestatic->LibStatut($row[1], 3).' ';
+ print ''.$commandestatic->LibStatut($obj->nb).' ';
+ print ''.$obj->nb.' '.$commandestatic->LibStatut($obj->fk_statut, 3).' ';
print " \n";
$i++;
@@ -218,7 +215,7 @@ if (!empty($conf->fournisseur->enabled))
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.fk_soc = s.rowid";
- $sql .= " AND c.entity = ".$conf->entity;
+ $sql .= " AND c.entity IN (".getEntity("supplier_order").")"; // Thirdparty sharing is mandatory with supplier order sharing
$sql .= " AND c.fk_statut = 0";
if (!empty($socid)) $sql .= " AND c.fk_soc = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
@@ -254,17 +251,25 @@ if (!empty($conf->fournisseur->enabled))
/*
* List of users allowed
*/
-$sql = "SELECT u.rowid, u.lastname, u.firstname, u.email";
-$sql .= " FROM ".MAIN_DB_PREFIX."user as u,";
-$sql .= " ".MAIN_DB_PREFIX."user_rights as ur";
-$sql .= ", ".MAIN_DB_PREFIX."rights_def as rd";
-$sql .= " WHERE u.rowid = ur.fk_user";
-$sql .= " AND (u.entity IN (0,".$conf->entity.")";
-$sql .= " AND rd.entity = ".$conf->entity.")";
-$sql .= " AND ur.fk_id = rd.id";
-$sql .= " AND module = 'fournisseur'";
-$sql .= " AND perms = 'commande'";
-$sql .= " AND subperms = 'approuver'";
+
+$sql = "SELECT";
+if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ $sql .= " DISTINCT";
+}
+$sql .= " u.rowid, u.lastname, u.firstname, u.email, u.statut";
+$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
+if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
+{
+ $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
+ $sql .= " WHERE ((ug.fk_user = u.rowid";
+ $sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
+ $sql .= " OR u.entity = 0)"; // Show always superadmin
+}
+else
+{
+ $sql .= " WHERE (u.entity IN (".getEntity('user').")";
+}
+$sql .= " AND u.fk_soc IS NULL"; // An external user can not approved
$resql = $db->query($sql);
if ($resql)
@@ -281,15 +286,23 @@ if ($resql)
{
$obj = $db->fetch_object($resql);
- print '';
- print '';
+ $userstatic = new User($db);
$userstatic->id = $obj->rowid;
- $userstatic->lastname = $obj->lastname;
- $userstatic->firstname = $obj->firstname;
- $userstatic->email = $obj->email;
- print $userstatic->getNomUrl(1);
- print ' ';
- print " \n";
+ $userstatic->getrights('fournisseur');
+
+ if (!empty($userstatic->rights->fournisseur->commande->approuver))
+ {
+ print '';
+ print '';
+ $userstatic->lastname = $obj->lastname;
+ $userstatic->firstname = $obj->firstname;
+ $userstatic->email = $obj->email;
+ $userstatic->statut = $obj->statut;
+ print $userstatic->getNomUrl(1);
+ print ' ';
+ print " \n";
+ }
+
$i++;
}
print "
";
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index d7a258b517e..6ab40c3924c 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -917,6 +917,10 @@ if (empty($reshook))
}
}
}
+ elseif (!empty($object->origin) && !empty($object->origin_id))
+ {
+ $object->linkedObjectsIds[$object->origin] = $object->origin_id;
+ }
$id = $object->create($user);
@@ -2406,7 +2410,7 @@ else
if (!$formconfirm)
{
- $parameters = array('lineid'=>$lineid);
+ $parameters = array('formConfirm' => $formconfirm, 'lineid'=>$lineid);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index 9b865cae3e6..6dc24c71b57 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -433,8 +433,8 @@ if ($resql)
}
$param = '&socid='.$socid;
- if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
- if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
+ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
+ if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_all) $param .= '&search_all='.urlencode($search_all);
if ($day) $param .= '&day='.urlencode($day);
if ($month) $param .= '&month='.urlencode($month);
@@ -455,9 +455,9 @@ if ($resql)
if ($search_amount_no_tax) $param .= '&search_amount_no_tax='.urlencode($search_amount_no_tax);
if ($search_amount_all_tax) $param .= '&search_amount_all_tax='.urlencode($search_amount_all_tax);
if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status);
- if ($show_files) $param .= '&show_files='.$show_files;
- if ($option) $param .= "&option=".$option;
- if ($optioncss != '') $param .= '&optioncss='.$optioncss;
+ if ($show_files) $param .= '&show_files='.urlencode($show_files);
+ if ($option) $param .= "&option=".urlencode($option);
+ if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@@ -879,7 +879,7 @@ if ($resql)
// Supplier ref
if (!empty($arrayfields['f.ref_supplier']['checked']))
{
- print '';
+ print ' ';
print $obj->ref_supplier;
print ' ';
if (!$i) $totalarray['nbfield']++;
diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php
index e9198ebcc91..1b6f8257977 100644
--- a/htdocs/fourn/facture/paiement.php
+++ b/htdocs/fourn/facture/paiement.php
@@ -297,9 +297,13 @@ if (empty($reshook))
$paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Array of amounts
$paiement->multicurrency_amounts = $multicurrency_amounts;
- $paiement->paiementid = $_POST['paiementid'];
- $paiement->num_paiement = $_POST['num_paiement'];
- $paiement->note = $_POST['comment'];
+ $paiement->paiementid = GETPOST('paiementid', 'int');
+
+ $paiement->num_payment = GETPOST('num_paiement', 'alpha');
+ $paiement->note_private = GETPOST('comment', 'alpha');
+ $paiement->num_paiement = $paiement->num_payment; // For bacward compatibility
+ $paiement->note = $paiement->note_private; // For bacward compatibility
+
if (!$error)
{
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty);
@@ -370,7 +374,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
$dateinvoice = ($datefacture == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datefacture);
$sql = 'SELECT s.nom as name, s.rowid as socid,';
- $sql .= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
+ $sql .= ' f.rowid, f.ref, f.ref_supplier, f.total_ttc as total, f.fk_mode_reglement, f.fk_account';
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user ";
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f';
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -821,7 +825,7 @@ if (empty($action) || $action == 'list')
$sql .= ' c.code as paiement_type, c.libelle as paiement_libelle,';
$sql .= ' ba.rowid as bid, ba.label,';
if (!$user->rights->societe->client->voir) $sql .= ' sc.fk_soc, sc.fk_user,';
- $sql .= ' SUM(f.amount)';
+ $sql .= ' SUM(pf.amount)';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn';
@@ -1013,9 +1017,9 @@ if (empty($action) || $action == 'list')
// Amount
print ''.price($objp->pamount).' ';
- if (!$i) $totalarray['nbfield']++;
- $totalarray['pos'][7] = 'amount';
+ $totalarray['pos'][$totalarray['nbfield']] = 'amount';
$totalarray['val']['amount'] += $objp->pamount;
+ if (!$i) $totalarray['nbfield']++;
// Ref invoice
/*$invoicesupplierstatic->ref=$objp->ref_supplier;
diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php
index 1fda453ffe4..2cd52bfeb77 100644
--- a/htdocs/fourn/recap-fourn.php
+++ b/htdocs/fourn/recap-fourn.php
@@ -72,7 +72,7 @@ if ($socid > 0)
print '';
- $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.amount, f.datef as df,";
+ $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.datef as df,";
$sql .= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
$sql .= " u.login, u.rowid as userid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u";
diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php
index 9cc287cd28a..bf78cfeafc9 100644
--- a/htdocs/holiday/card.php
+++ b/htdocs/holiday/card.php
@@ -40,23 +40,23 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Get parameters
-$action=GETPOST('action', 'aZ09');
-$cancel=GETPOST('cancel', 'alpha');
+$action = GETPOST('action', 'aZ09');
+$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
-$id=GETPOST('id', 'int');
-$ref=GETPOST('ref', 'alpha');
-$fuserid = (GETPOST('fuserid', 'int')?GETPOST('fuserid', 'int'):$user->id);
+$id = GETPOST('id', 'int');
+$ref = GETPOST('ref', 'alpha');
+$fuserid = (GETPOST('fuserid', 'int') ?GETPOST('fuserid', 'int') : $user->id);
// Load translation files required by the page
-$langs->loadLangs(array("holiday","mails"));
+$langs->loadLangs(array("holiday", "mails"));
-$now=dol_now();
+$now = dol_now();
$childids = $user->getAllChildIds(1);
$morefilter = 'AND employee = 1';
-if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = '';
+if (!empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = '';
$error = 0;
@@ -90,7 +90,7 @@ if (!empty($user->rights->holiday->delete)) $candelete = 1;
if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) $candelete = 1;
// Protection if external user
-if ($user->socid) $socid=$user->socid;
+if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'holiday', $object->id, 'holiday');
@@ -1287,8 +1287,8 @@ else
$htmlhelp = $langs->trans('NbUseDaysCPHelp');
$includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
$includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);
- if ($includesaturday) $htmlhelp.=' '.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
- if ($includesunday) $htmlhelp.=' '.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
+ if ($includesaturday) $htmlhelp .= ' '.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
+ if ($includesunday) $htmlhelp .= ' '.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp);
print '';
print ''.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).' ';
diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php
index 4c4a5212abd..acd4be35b79 100644
--- a/htdocs/holiday/class/holiday.class.php
+++ b/htdocs/holiday/class/holiday.class.php
@@ -1654,21 +1654,24 @@ class Holiday extends CommonObject
{
if ($type)
{
- // Si utilisateur de Dolibarr
-
- $sql = "SELECT u.rowid";
- $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
+ // If user of Dolibarr
+ $sql = "SELECT";
+ if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ $sql .= " DISTINCT";
+ }
+ $sql.= " u.rowid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
- $sql .= " WHERE (ug.fk_user = u.rowid";
- $sql .= " AND ug.entity = ".$conf->entity.")";
- $sql .= " OR u.admin = 1";
+ $sql .= " WHERE ((ug.fk_user = u.rowid";
+ $sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
+ $sql .= " OR u.entity = 0)"; // Show always superadmin
}
else
{
- $sql .= " WHERE u.entity IN (0,".$conf->entity.")";
+ $sql .= " WHERE u.entity IN (".getEntity('user').")";
}
$sql .= " AND u.statut > 0";
if ($filters) $sql .= $filters;
@@ -1709,7 +1712,7 @@ class Holiday extends CommonObject
// 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";
+ $sql .= " WHERE cpu.fk_user = u.rowid";
if ($filters) $sql .= $filters;
$resql = $this->db->query($sql);
@@ -1750,17 +1753,24 @@ class Holiday extends CommonObject
// List for Dolibarr users
if ($type)
{
- $sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
+ // If user of Dolibarr
+ $sql = "SELECT";
+ if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ $sql .= " DISTINCT";
+ }
+ $sql.= " 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))
{
- $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
- $sql.= " WHERE (ug.fk_user = u.rowid";
- $sql.= " AND ug.entity = ".$conf->entity.")";
- $sql.= " OR u.admin = 1";
- } else {
- $sql.= " WHERE u.entity IN (0,".$conf->entity.")";
+ $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
+ $sql .= " WHERE ((ug.fk_user = u.rowid";
+ $sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
+ $sql .= " OR u.entity = 0)"; // Show always superadmin
+ }
+ else
+ {
+ $sql .= " WHERE u.entity IN (".getEntity('user').")";
}
$sql.= " AND u.statut > 0";
diff --git a/htdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php b/htdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php
index eff8bb61f29..d8445fdc70c 100644
--- a/htdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php
+++ b/htdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php
@@ -263,13 +263,7 @@ class AutoLoader
* @return bool false unless className now exists
*/
private function loadLastResort($className, $loader = null) {
- // @CHANGE LDR Add protection to avoid conflict with other autoloader
- /*print 'Try to load '.$className."\n";
- if (in_array($className, array('Google_Client')))
- {
- return false;
- }*/
- $loaders = array_unique(static::$rogueLoaders);
+ $loaders = array_unique(static::$rogueLoaders);
if (isset($loader)) {
if (false === array_search($loader, $loaders))
static::$rogueLoaders[] = $loader;
diff --git a/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php b/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php
index e8248a385fa..2815f1f6c70 100644
--- a/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php
+++ b/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php
@@ -159,7 +159,7 @@ class CommentParser
$addNewline = true;
}
continue;
- } elseif ($line{0} == '@') {
+ } elseif ($line[0] == '@') {
$mode = 2;
$newParam = true;
}
@@ -353,7 +353,7 @@ class CommentParser
$data = $format->decode($str);
}
} else { // auto detect
- if ($str{0} == '{') {
+ if ($str[0] == '{') {
$d = json_decode($str, true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new Exception('Error parsing embedded JSON data'
@@ -445,7 +445,7 @@ class CommentParser
{
$r = array();
$email = end($value);
- if ($email{0} == '<') {
+ if ($email[0] == '<') {
$email = substr($email, 1, -1);
array_pop($value);
$r['email'] = $email;
@@ -470,7 +470,7 @@ class CommentParser
$data = array_shift($value);
if (empty($data)) {
$r['type'] = 'mixed';
- } elseif ($data{0} == '$') {
+ } elseif ($data[0] == '$') {
$r['name'] = substr($data, 1);
$r['type'] = 'mixed';
} else {
@@ -478,7 +478,7 @@ class CommentParser
$r['type'] = count($data) == 1 ? $data[0] : $data;
$data = array_shift($value);
- if (!empty($data) && $data{0} == '$') {
+ if (!empty($data) && $data[0] == '$') {
$r['name'] = substr($data, 1);
}
}
@@ -498,7 +498,7 @@ class CommentParser
$data = array_shift($value);
if (empty($data)) {
$r['type'] = 'mixed';
- } elseif ($data{0} == '$') {
+ } elseif ($data[0] == '$') {
$r['name'] = substr($data, 1);
$r['type'] = 'mixed';
} else {
diff --git a/htdocs/includes/restler/framework/Luracast/Restler/Format/XmlFormat.php b/htdocs/includes/restler/framework/Luracast/Restler/Format/XmlFormat.php
index b51fa707a53..ceec32e4cb5 100644
--- a/htdocs/includes/restler/framework/Luracast/Restler/Format/XmlFormat.php
+++ b/htdocs/includes/restler/framework/Luracast/Restler/Format/XmlFormat.php
@@ -221,7 +221,7 @@ class XmlFormat extends Format
$namespaces = $xml->getNamespaces();
if (count($namespaces)) {
$p = strpos($data, $xml->getName());
- if ($p && $data{$p - 1} == ':') {
+ if ($p && $data[$p - 1] == ':') {
$s = strpos($data, '<') + 1;
$prefix = substr($data, $s, $p - $s - 1);
static::$namespacedProperties[static::$rootName] = $prefix;
diff --git a/htdocs/includes/restler/framework/Luracast/Restler/Resources.php b/htdocs/includes/restler/framework/Luracast/Restler/Resources.php
index 43e95fa02be..2986968a990 100644
--- a/htdocs/includes/restler/framework/Luracast/Restler/Resources.php
+++ b/htdocs/includes/restler/framework/Luracast/Restler/Resources.php
@@ -198,7 +198,7 @@ class Resources implements iUseAuthentication, iProvideMultiVersionApi
} elseif (false !== ($pos = strpos($id, '-v'))) {
//$version = intval(substr($id, $pos + 2));
$id = substr($id, 0, $pos);
- } elseif ($id{0} == 'v' && is_numeric($v = substr($id, 1))) {
+ } elseif ($id[0] == 'v' && is_numeric($v = substr($id, 1))) {
$id = '';
//$version = $v;
} elseif ($id == 'root' || $id == 'index') {
@@ -233,7 +233,7 @@ class Resources implements iUseAuthentication, iProvideMultiVersionApi
if ($tSlash) {
if ($fLen != $tLen && !Text::beginsWith($fullPath, $target . '/'))
continue;
- } elseif ($fLen > $tLen + 1 && $fullPath{$tLen + 1} != '{' && !Text::beginsWith($fullPath, '{')) {
+ } elseif ($fLen > $tLen + 1 && $fullPath[$tLen + 1] != '{' && !Text::beginsWith($fullPath, '{')) {
//when mapped to root exclude paths that have static parts
//they are listed else where under that static part name
continue;
@@ -275,7 +275,7 @@ class Resources implements iUseAuthentication, iProvideMultiVersionApi
if (count($parts) == 1 && $httpMethod == 'GET') {
} else {
for ($i = 0; $i < count($parts); $i++) {
- if (strlen($parts[$i]) && $parts[$i]{0} == '{') {
+ if (strlen($parts[$i]) && $parts[$i][0] == '{') {
$pos = $i - 1;
break;
}
diff --git a/htdocs/includes/restler/framework/Luracast/Restler/Restler.php b/htdocs/includes/restler/framework/Luracast/Restler/Restler.php
index c2e9b1acb73..fcb5388726c 100644
--- a/htdocs/includes/restler/framework/Luracast/Restler/Restler.php
+++ b/htdocs/includes/restler/framework/Luracast/Restler/Restler.php
@@ -533,7 +533,7 @@ class Restler extends EventDispatcher
rtrim($path, '/') //remove trailing slash if found
);
- if (Defaults::$useUrlBasedVersioning && strlen($path) && $path{0} == 'v') {
+ if (Defaults::$useUrlBasedVersioning && strlen($path) && $path[0] == 'v') {
$version = intval(substr($path, 1));
if ($version && $version <= $this->apiVersion) {
$this->requestedApiVersion = $version;
@@ -1599,7 +1599,7 @@ class Restler extends EventDispatcher
*/
public function __get($name)
{
- if ($name{0} == '_') {
+ if ($name[0] == '_') {
$hiddenProperty = substr($name, 1);
if (isset($this->$hiddenProperty)) {
return $this->$hiddenProperty;
diff --git a/htdocs/includes/restler/framework/Luracast/Restler/Routes.php b/htdocs/includes/restler/framework/Luracast/Restler/Routes.php
index 73e78dc0039..999094dec4c 100644
--- a/htdocs/includes/restler/framework/Luracast/Restler/Routes.php
+++ b/htdocs/includes/restler/framework/Luracast/Restler/Routes.php
@@ -87,7 +87,7 @@ class Routes
foreach ($methods as $method) {
$methodUrl = strtolower($method->getName());
//method name should not begin with _
- if ($methodUrl{0} == '_') {
+ if ($methodUrl[0] == '_') {
continue;
}
$doc = $method->getDocComment();
@@ -330,7 +330,7 @@ class Routes
if (!$type) {
return 's';
}
- switch ($type{0}) {
+ switch ($type[0]) {
case 'i':
case 'f':
return 'n';
@@ -428,7 +428,7 @@ class Routes
}
$index = intval(substr($k, 1));
$details = $value[$httpMethod]['metadata']['param'][$index];
- if ($k{0} == 's' || strpos($k, static::pathVarTypeOf($v)) === 0) {
+ if ($k[0] == 's' || strpos($k, static::pathVarTypeOf($v)) === 0) {
//remove the newlines
$data[$details['name']] = trim($v, PHP_EOL);
} else {
diff --git a/htdocs/includes/restler/framework/Luracast/Restler/Scope.php b/htdocs/includes/restler/framework/Luracast/Restler/Scope.php
index 251262017c3..16ccdd33561 100644
--- a/htdocs/includes/restler/framework/Luracast/Restler/Scope.php
+++ b/htdocs/includes/restler/framework/Luracast/Restler/Scope.php
@@ -203,7 +203,7 @@ class Scope
$divider = '\\';
$qualified = false;
- if ($className{0} == $divider) {
+ if ($className[0] == $divider) {
$qualified = trim($className, $divider);
} elseif (array_key_exists($className, $scope)) {
$qualified = $scope[$className];
diff --git a/htdocs/includes/restler/framework/Luracast/Restler/UI/Emmet.php b/htdocs/includes/restler/framework/Luracast/Restler/UI/Emmet.php
index abd4a3a73ba..435804b4469 100644
--- a/htdocs/includes/restler/framework/Luracast/Restler/UI/Emmet.php
+++ b/htdocs/includes/restler/framework/Luracast/Restler/UI/Emmet.php
@@ -356,7 +356,7 @@ class Emmet
$pos = strpos($string, $f, $start);
$tokens = array();
for ($i = $start; $i < $pos; $i++) {
- $token = $string{$i};
+ $token = $string[$i];
if (('#' == $token || '.' == $token) &&
(!empty($tokens) || $i == 0)
) {
@@ -368,7 +368,7 @@ class Emmet
$r[] = $f;
} while (false != ($f = strtok(static::DELIMITERS)));
for ($i = $pos; $i < strlen($string); $i++) {
- $token = $string{$i};
+ $token = $string[$i];
$r[] = $tokens[] = $token;
}
return $r;
diff --git a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php
index aa66879f7a1..96ab2f4cbb6 100644
--- a/htdocs/includes/tecnickcom/tcpdf/tcpdf.php
+++ b/htdocs/includes/tecnickcom/tcpdf/tcpdf.php
@@ -6878,7 +6878,9 @@ class TCPDF {
}
// check if file exist and it is valid
if (!@TCPDF_STATIC::file_exists($file)) {
- return false;
+ // DOL CHANGE If we keep this, the image is not visible on pages after the first one.
+ //var_dump($file.' '.(!@TCPDF_STATIC::file_exists($file)));
+ //return false;
}
if (($imsize = @getimagesize($file)) === FALSE) {
if (in_array($file, $this->imagekeys)) {
@@ -7810,6 +7812,8 @@ class TCPDF {
'bufferlen',
'buffer',
'cached_files',
+// @CHANGE DOL
+// 'imagekeys',
'sign',
'signature_data',
'signature_max_length',
diff --git a/htdocs/index.php b/htdocs/index.php
index 250a0c1736b..110de972f2b 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -80,7 +80,7 @@ llxHeader('', $title);
$resultboxes = FormOther::getBoxesArea($user, "0"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
-print load_fiche_titre($langs->trans("HomeArea"), $resultboxes['selectboxlist'], 'home');
+print load_fiche_titre($langs->trans("HomeArea"), $resultboxes['selectboxlist'], 'home', 0, '', 'titleforhome');
if (!empty($conf->global->MAIN_MOTD))
{
@@ -268,6 +268,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS))
DOL_URL_ROOT.'/societe/list.php?type=f&mainmenu=companies',
DOL_URL_ROOT.'/contact/list.php?mainmenu=companies',
DOL_URL_ROOT.'/adherents/list.php?statut=1&mainmenu=members',
+ DOL_URL_ROOT.'/adherents/list.php?statut=-1&mainmenu=members',
DOL_URL_ROOT.'/product/list.php?type=0&mainmenu=products',
DOL_URL_ROOT.'/product/list.php?type=1&mainmenu=products',
DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial&leftmenu=propals',
@@ -284,7 +285,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS))
DOL_URL_ROOT.'/don/list.php?leftmenu=donations'
);
// Translation lang files
- $langfile=array(
+ $langfile = array(
"users",
"companies",
"prospects",
@@ -358,89 +359,89 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
$dashboardlines = array();
// Do not include sections without management permission
- require_once DOL_DOCUMENT_ROOT . '/core/class/workboardresponse.class.php';
+ require_once 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';
+ include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
$board = new ActionComm($db);
$dashboardlines[$board->element] = $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';
+ include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$board = new Project($db);
$dashboardlines[$board->element] = $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';
+ include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
$board = new Task($db);
$dashboardlines[$board->element] = $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';
+ include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$board = new Propal($db);
- $dashboardlines[$board->element . '_opened'] = $board->load_board($user, "opened");
+ $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
// Number of commercial proposals CLOSED signed (billed)
- $dashboardlines[$board->element . '_signed'] = $board->load_board($user, "signed");
+ $dashboardlines[$board->element.'_signed'] = $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';
+ include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
$board = new SupplierProposal($db);
- $dashboardlines[$board->element . '_opened'] = $board->load_board($user, "opened");
+ $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
// Number of commercial proposals CLOSED signed (billed)
- $dashboardlines[$board->element . '_signed'] = $board->load_board($user, "signed");
+ $dashboardlines[$board->element.'_signed'] = $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';
+ include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$board = new Commande($db);
$dashboardlines[$board->element] = $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';
+ include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$board = new CommandeFournisseur($db);
- $dashboardlines[$board->element . '_opened'] = $board->load_board($user, "opened");
- $dashboardlines[$board->element . '_awaiting'] = $board->load_board($user, 'awaiting');
+ $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
+ $dashboardlines[$board->element.'_awaiting'] = $board->load_board($user, 'awaiting');
}
// Number of services enabled (delayed)
if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) {
- include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$board = new Contrat($db);
- $dashboardlines[$board->element . '_inactive'] = $board->load_board($user, "inactive");
+ $dashboardlines[$board->element.'_inactive'] = $board->load_board($user, "inactive");
// Number of active services (expired)
- $dashboardlines[$board->element . '_active'] = $board->load_board($user, "active");
+ $dashboardlines[$board->element.'_active'] = $board->load_board($user, "active");
}
// 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';
+ include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$board = new Facture($db);
$dashboardlines[$board->element] = $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';
+ include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$board = new FactureFournisseur($db);
$dashboardlines[$board->element] = $board->load_board($user);
}
// Number of transactions to conciliate
if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->socid) {
- include_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$board = new Account($db);
- $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate
+ $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate
if ($nb > 0) {
$dashboardlines[$board->element] = $board->load_board($user);
}
@@ -448,35 +449,36 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
// Number of cheque to send
if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->socid && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) {
- include_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
$board = new RemiseCheque($db);
$dashboardlines['RemiseCheque'] = $board->load_board($user);
}
// Number of foundation members
if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire && !$user->socid) {
- include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$board = new Adherent($db);
- $dashboardlines['Adherent'] = $board->load_board($user);
+ $dashboardlines[$board->element.'_shift'] = $board->load_board($user, 'shift');
+ $dashboardlines[$board->element.'_expired'] = $board->load_board($user, 'expired');
}
// 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';
+ include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$board = new ExpenseReport($db);
$dashboardlines['ExpenseReport'] = $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';
+ include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$board = new ExpenseReport($db);
$dashboardlines['ExpenseReport'] = $board->load_board($user, 'topay');
}
// Number of holidays to approve
if (!empty($conf->holiday->enabled) && $user->rights->holiday->approve) {
- include_once DOL_DOCUMENT_ROOT . '/holiday/class/holiday.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
$board = new Holiday($db);
$dashboardlines['Holiday'] = $board->load_board($user);
}
@@ -563,7 +565,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
'groupName' => 'Members',
'globalStatsKey' => 'members',
'stats' =>
- array('Adherent'),
+ array('member_shift', 'member_expired'),
),
'ExpenseReport' =>
array(
@@ -875,23 +877,23 @@ print '';
* Show boxes
*/
-$boxlist.='
';
+$boxlist .= '
';
-$boxlist.='
';
-if(!empty($nbworkboardcount))
+$boxlist .= '
';
+if (!empty($nbworkboardcount))
{
- $boxlist.=$boxwork;
+ $boxlist .= $boxwork;
}
-$boxlist.=$resultboxes['boxlista'];
+$boxlist .= $resultboxes['boxlista'];
-$boxlist.= '
';
+$boxlist .= '
';
if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS))
{
// Remove allready present info in new dash board
- if(!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0){
+ if (!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0) {
foreach ($boxstatItems as $boxstatItemKey => $boxstatItemHtml) {
if (in_array($boxstatItemKey, $globalStatInTopOpenedDashBoard)) {
unset($boxstatItems[$boxstatItemKey]);
diff --git a/htdocs/install/check.php b/htdocs/install/check.php
index 9d197c752dc..6fb01d5329c 100644
--- a/htdocs/install/check.php
+++ b/htdocs/install/check.php
@@ -127,7 +127,7 @@ if (!function_exists("imagecreate"))
{
$langs->load("errors");
print '
'.$langs->trans("ErrorPHPDoesNotSupportGD")."
\n";
- // $checksok=0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
+ // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
}
else
{
@@ -140,7 +140,7 @@ if (!function_exists("curl_init"))
{
$langs->load("errors");
print '
'.$langs->trans("ErrorPHPDoesNotSupportCurl")."
\n";
- // $checksok=0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
+ // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
}
else
{
@@ -163,7 +163,7 @@ if (!function_exists("utf8_encode"))
{
$langs->load("errors");
print '
'.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
\n";
- // $checksok=0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
+ // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
}
else
{
@@ -178,7 +178,7 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc
{
$langs->load("errors");
print '
'.$langs->trans("ErrorPHPDoesNotSupportIntl")."
\n";
- // $checksok=0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
+ // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
}
else
{
@@ -186,6 +186,16 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc
}
}
+if (!class_exists('ZipArchive'))
+{
+ $langs->load("errors");
+ print '
'.$langs->trans("ErrorPHPDoesNotSupport", "ZIP")."
\n";
+ // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install)
+}
+else
+{
+ print '
'.$langs->trans("PHPSupport", "ZIP")."
\n";
+}
// Check memory
$memrequiredorig = '64M';
diff --git a/htdocs/install/default.css b/htdocs/install/default.css
index 7a3bb7b3290..65d8e8021a8 100644
--- a/htdocs/install/default.css
+++ b/htdocs/install/default.css
@@ -16,6 +16,9 @@
*/
+.opacitymedium {
+ opacity: 0.5;
+}
body {
font-size:14px;
@@ -50,10 +53,9 @@ div.titre {
}
span.titre {
- font-size: 90%;
font-weight: bold;
background: #FFFFFF;
- color: #444;
+ color: rgb(0,113,121);
border: 1px solid #bbb;
padding: 10px 10px 10px 10px;
margin: 0 0 10px 10px;
@@ -344,13 +346,14 @@ ul {
.button {
- background: #fcfcfc;
- border: 1px solid #e0e0e0;
+ background: rgb(0,113,121);
+ color: #fff;
+ /* border: 1px solid #e0e0e0; */
padding: 0.3em 0.7em;
margin: 0 0.5em;
- -moz-border-radius: 5px 5px 5px 5px;
- -webkit-border-radius: 5px 5px 5px 5px;
- border-radius: 5px 5px 5px 5px;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
-moz-box-shadow: 2px 2px 3px #ddd;
-webkit-box-shadow: 2px 2px 3px #ddd;
box-shadow: 2px 2px 3px #ddd;
@@ -360,7 +363,7 @@ a.button:hover {
}
.choiceselected {
- background-color: #dfd;
+ background-color: #f4fcf4;
background-repeat: repeat-x;
background-position: top left;
}
diff --git a/htdocs/install/doctemplates/websites/website_template-corporate.zip b/htdocs/install/doctemplates/websites/website_template-corporate.zip
index f83fecc2c2e..9ef5f4aee5a 100644
Binary files a/htdocs/install/doctemplates/websites/website_template-corporate.zip and b/htdocs/install/doctemplates/websites/website_template-corporate.zip differ
diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php
index b800f5f6ad4..4770575774a 100644
--- a/htdocs/install/fileconf.php
+++ b/htdocs/install/fileconf.php
@@ -136,7 +136,7 @@ if (!empty($force_install_noedit)) {
>
';
@@ -1906,7 +1911,7 @@ elseif (! empty($module))
print $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).' ';
}
- if (! empty($moduleobj))
+ if (!empty($moduleobj))
{
print ' ';
@@ -1995,8 +2000,8 @@ elseif (! empty($module))
{
$pathtofile = $modulelowercase.'/langs/'.$langfile['relativename'];
print ' '.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.' ';
- print ''.img_picto($langs->trans("Edit"), 'edit').' ';
- print ''.img_picto($langs->trans("Delete"), 'delete').' ';
+ print ''.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ''.img_picto($langs->trans("Delete"), 'delete').' ';
print ' ';
}
print '
';
@@ -2041,16 +2046,16 @@ elseif (! empty($module))
if ($action != 'editfile' || empty($file))
{
print '
';
- $htmlhelp=$langs->trans("DictionariesDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Dictionaries').' ');
+ $htmlhelp = $langs->trans("DictionariesDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Dictionaries').' ');
print $form->textwithpicto($langs->trans("DictionariesDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').' ';
print ' ';
print '
';
print '
'.$langs->trans("DescriptorFile").' :
'.$pathtofile.' ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print '
';
print '
'.$langs->trans("LanguageFile").' : ';
- if (! is_array($dicts) || empty($dicts)) print '
'.$langs->trans("NoDictionaries").' ';
+ if (!is_array($dicts) || empty($dicts)) print '
'.$langs->trans("NoDictionaries").' ';
else print '
'.$dicts['langs'].' ';
print '
';
@@ -2143,7 +2148,7 @@ elseif (! empty($module))
}
else
{
- $fullpathoffile=dol_buildpath($file, 0);
+ $fullpathoffile = dol_buildpath($file, 0);
$content = file_get_contents($fullpathoffile);
@@ -2155,8 +2160,8 @@ elseif (! empty($module))
print '
';
print '
';
- $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
- print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html'));
+ $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
+ print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html'));
print '
';
print '
';
print ' ';
@@ -2171,12 +2176,12 @@ elseif (! empty($module))
if ($tab == 'objects')
{
$head3 = array();
- $h=0;
+ $h = 0;
// Dir for module
$dir = $dirread.'/'.$modulelowercase.'/class';
- $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=newobject';
+ $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj=newobject';
$head3[$h][1] = ''.$langs->trans("NewObjectInModulebuilder").' ';
$head3[$h][2] = 'newobject';
$h++;
@@ -2229,10 +2234,10 @@ elseif (! empty($module))
print ''.$langs->trans("EnterNameOfObjectDesc").' ';
- print ' ';
+ print ' ';
print ' '.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).' ';
print ' '.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).' ';
- print ' ';
+ print ' ';
print ' ';
print ' ';
print ' ';
@@ -2322,15 +2327,15 @@ elseif (! empty($module))
}
print '';
- print '
'.$langs->trans("ClassFile").' :
'.($realpathtoclass?'':'').$pathtoclass.($realpathtoclass?'':' ').' ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.$langs->trans("ClassFile").' :
'.($realpathtoclass ? '' : '').$pathtoclass.($realpathtoclass ? '' : ' ').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print '
';
- print '
'.$langs->trans("ApiClassFile").' :
'.($realpathtoapi?'':'').$pathtoapi.($realpathtoapi?'':' ').' ';
+ print '
'.$langs->trans("ApiClassFile").' :
'.($realpathtoapi ? '' : '').$pathtoapi.($realpathtoapi ? '' : ' ').' ';
if ($realpathtoapi)
{
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
- print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
+ print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
print ' ';
if (empty($conf->global->$const_name)) // If module is not activated
{
@@ -2344,67 +2349,67 @@ elseif (! empty($module))
else
{
//print '
'.$langs->trans("FileNotYetGenerated").' ';
- print '
';
+ print '
';
}
// PHPUnit
print '
';
- print '
'.$langs->trans("TestClassFile").' :
'.($realpathtophpunit?'':'').$pathtophpunit.($realpathtophpunit?'':' ').' ';
+ print '
'.$langs->trans("TestClassFile").' :
'.($realpathtophpunit ? '' : '').$pathtophpunit.($realpathtophpunit ? '' : ' ').' ';
if ($realpathtophpunit)
{
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
- print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
+ print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
}
else
{
//print '
'.$langs->trans("FileNotYetGenerated").' ';
- print '
';
+ print '
';
}
print '
';
print '
';
- print '
'.$langs->trans("PageForLib").' :
'.($realpathtolib?'':'').$pathtolib.($realpathtolib?'':' ').' ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.$langs->trans("PageForLib").' :
'.($realpathtolib ? '' : '').$pathtolib.($realpathtolib ? '' : ' ').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print '
';
- print '
'.$langs->trans("PageForObjLib").' :
'.($realpathtoobjlib?'':'').$pathtoobjlib.($realpathtoobjlib?'':' ').' ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.$langs->trans("PageForObjLib").' :
'.($realpathtoobjlib ? '' : '').$pathtoobjlib.($realpathtoobjlib ? '' : ' ').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print '
';
- print '
'.$langs->trans("Image").' :
'.($realpathtopicto?'':'').$pathtopicto.($realpathtopicto?'':' ').' ';
+ print '
'.$langs->trans("Image").' :
'.($realpathtopicto ? '' : '').$pathtopicto.($realpathtopicto ? '' : ' ').' ';
//print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print '
';
print '
';
- print '
'.$langs->trans("SqlFile").' :
'.($realpathtosql?'':'').$pathtosql.($realpathtosql?'':' ').' ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
- print '
'.$langs->trans("DropTableIfEmpty").' ';
+ print '
'.$langs->trans("SqlFile").' :
'.($realpathtosql ? '' : '').$pathtosql.($realpathtosql ? '' : ' ').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.$langs->trans("DropTableIfEmpty").' ';
//print '
'.$langs->trans("RunSql").' ';
print '
';
- print '
'.$langs->trans("SqlFileKey").' :
'.($realpathtosqlkey?'':'').$pathtosqlkey.($realpathtosqlkey?'':' ').' ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.$langs->trans("SqlFileKey").' :
'.($realpathtosqlkey ? '' : '').$pathtosqlkey.($realpathtosqlkey ? '' : ' ').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
//print '
'.$langs->trans("RunSql").' ';
print '
';
- print '
'.$langs->trans("SqlFileExtraFields").' :
'.($realpathtosqlextra?'':'').$pathtosqlextra.($realpathtosqlextra?'':' ').' ';
+ print '
'.$langs->trans("SqlFileExtraFields").' :
'.($realpathtosqlextra ? '' : '').$pathtosqlextra.($realpathtosqlextra ? '' : ' ').' ';
if ($realpathtosqlextra)
{
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
- print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
+ print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
print ' ';
- print '
'.$langs->trans("DropTableIfEmpty").' ';
+ print '
'.$langs->trans("DropTableIfEmpty").' ';
}
else {
- print '
';
+ print '
';
}
//print '
'.$langs->trans("RunSql").' ';
print '
';
- print '
'.$langs->trans("SqlFileKeyExtraFields").' :
'.($realpathtosqlextrakey?'':'').$pathtosqlextrakey.($realpathtosqlextrakey?'':' ').' ';
+ print '
'.$langs->trans("SqlFileKeyExtraFields").' :
'.($realpathtosqlextrakey ? '' : '').$pathtosqlextrakey.($realpathtosqlextrakey ? '' : ' ').' ';
if ($realpathtosqlextrakey)
{
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
- print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
+ print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
}
//print '
'.$langs->trans("RunSql").' ';
print '
';
@@ -2416,34 +2421,34 @@ elseif (! empty($module))
$urlofcard = dol_buildpath($pathtocard, 1);
print '
';
- print '
'.$langs->trans("PageForList").' :
'.($realpathtolist?'':'').$pathtolist.($realpathtolist?'':' ').' ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.$langs->trans("PageForList").' :
'.($realpathtolist ? '' : '').$pathtolist.($realpathtolist ? '' : ' ').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print '
';
- print '
'.$langs->trans("PageForCreateEditView").' :
'.($realpathtocard?'':'').$pathtocard.($realpathtocard?'':' ').'?action=create ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.$langs->trans("PageForCreateEditView").' :
'.($realpathtocard ? '' : '').$pathtocard.($realpathtocard ? '' : ' ').'?action=create ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print '
';
- print '
'.$langs->trans("PageForAgendaTab").' :
'.($realpathtoagenda?'':'').$pathtoagenda.($realpathtoagenda?'':' ').' ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.$langs->trans("PageForAgendaTab").' :
'.($realpathtoagenda ? '' : '').$pathtoagenda.($realpathtoagenda ? '' : ' ').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
if ($realpathtoagenda)
{
print ' ';
- print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
+ print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
}
print '
';
- print '
'.$langs->trans("PageForDocumentTab").' :
'.($realpathtodocument?'':'').$pathtodocument.($realpathtodocument?'':' ').' ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.$langs->trans("PageForDocumentTab").' :
'.($realpathtodocument ? '' : '').$pathtodocument.($realpathtodocument ? '' : ' ').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
if ($realpathtodocument)
{
print ' ';
- print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
+ print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
}
print '
';
- print '
'.$langs->trans("PageForNoteTab").' :
'.($realpathtonote?'':'').$pathtonote.($realpathtonote?'':' ').' ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ print '
'.$langs->trans("PageForNoteTab").' :
'.($realpathtonote ? '' : '').$pathtonote.($realpathtonote ? '' : ' ').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
if ($realpathtonote)
{
print ' ';
- print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
+ print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
}
print '
';
@@ -2579,25 +2584,25 @@ elseif (! empty($module))
if (in_array($propname, array('fk_element', 'lines'))) continue;
}*/
- $propname=$propkey;
- $proplabel=$propval['label'];
- $proptype=$propval['type'];
- $proparrayofkeyval=$propval['arrayofkeyval'];
- $propnotnull=$propval['notnull'];
- $propdefault=$propval['default'];
- $propindex=$propval['index'];
- $propforeignkey=$propval['foreignkey'];
- $propposition=$propval['position'];
- $propenabled=$propval['enabled'];
- $propvisible=$propval['visible'];
- $propnoteditable=$propval['noteditable'];
- $propsearchall=$propval['searchall'];
- $propisameasure=$propval['isameasure'];
- $propcss=$propval['css'];
- $prophelp=$propval['help'];
- $propshowoncombobox=$propval['showoncombobox'];
+ $propname = $propkey;
+ $proplabel = $propval['label'];
+ $proptype = $propval['type'];
+ $proparrayofkeyval = $propval['arrayofkeyval'];
+ $propnotnull = $propval['notnull'];
+ $propdefault = $propval['default'];
+ $propindex = $propval['index'];
+ $propforeignkey = $propval['foreignkey'];
+ $propposition = $propval['position'];
+ $propenabled = $propval['enabled'];
+ $propvisible = $propval['visible'];
+ $propnoteditable = $propval['noteditable'];
+ $propsearchall = $propval['searchall'];
+ $propisameasure = $propval['isameasure'];
+ $propcss = $propval['css'];
+ $prophelp = $propval['help'];
+ $propshowoncombobox = $propval['showoncombobox'];
//$propdisabled=$propval['disabled'];
- $propcomment=$propval['comment'];
+ $propcomment = $propval['comment'];
print '
';
@@ -2622,37 +2627,37 @@ elseif (! empty($module))
print $propdefault;
print '';
print '';
- print $propindex?'1':'';
+ print $propindex ? '1' : '';
print ' ';
print '';
- print $propforeignkey?$propforeignkey:'';
+ print $propforeignkey ? $propforeignkey : '';
print ' ';
print '';
print $propposition;
print ' ';
print '';
- print $propenabled?$propenabled:'';
+ print $propenabled ? $propenabled : '';
print ' ';
print '';
- print $propvisible?$propvisible:'';
+ print $propvisible ? $propvisible : '';
print ' ';
print '';
- print $propnoteditable?$propnoteditable:'';
+ print $propnoteditable ? $propnoteditable : '';
print ' ';
print '';
- print $propsearchall?'1':'';
+ print $propsearchall ? '1' : '';
print ' ';
print '';
- print $propisameasure?$propisameasure:'';
+ print $propisameasure ? $propisameasure : '';
print ' ';
print '';
- print $propcss?$propcss:'';
+ print $propcss ? $propcss : '';
print ' ';
print '';
- print $prophelp?$prophelp:'';
+ print $prophelp ? $prophelp : '';
print ' ';
print '';
- print $propshowoncombobox?$propshowoncombobox:'';
+ print $propshowoncombobox ? $propshowoncombobox : '';
print ' ';
/*print '';
print $propdisabled?$propdisabled:'';
@@ -2687,7 +2692,7 @@ elseif (! empty($module))
$format = 'asciidoc';
if (preg_match('/\.md$/i', $spec['name'])) $format = 'markdown';
print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.' ';
- print ' '.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ' '.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
}
}
@@ -2785,13 +2790,13 @@ elseif (! empty($module))
if ($action != 'editfile' || empty($file))
{
print '';
- $htmlhelp=$langs->trans("MenusDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Menus').' ');
+ $htmlhelp = $langs->trans("MenusDefDescTooltip", ''.$langs->trans('Setup').' - '.$langs->trans('Menus').' ');
print $form->textwithpicto($langs->trans("MenusDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').' ';
print ' ';
print ' ';
print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.' ';
- print ' '.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ' '.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
print ' ';
@@ -2925,13 +2930,13 @@ elseif (! empty($module))
if ($action != 'editfile' || empty($file))
{
print '';
- $htmlhelp=$langs->trans("PermissionsDefDescTooltip", ''.$langs->trans('DefaultPermissions').' ');
+ $htmlhelp = $langs->trans("PermissionsDefDescTooltip", ''.$langs->trans('DefaultPermissions').' ');
print $form->textwithpicto($langs->trans("PermissionsDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').' ';
print ' ';
print ' ';
print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.' ';
- print ' '.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ' '.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
print ' ';
@@ -3028,7 +3033,7 @@ elseif (! empty($module))
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.' ';
print ' ';
- print ''.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ''.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
print '
';
@@ -3037,13 +3042,13 @@ elseif (! empty($module))
if (dol_is_file($dirins.'/'.$pathtohook))
{
print ''.$pathtohook.' ';
- print ' '.img_picto($langs->trans("Edit"), 'edit').' ';
- print ''.img_picto($langs->trans("Delete"), 'delete').' ';
+ print ''.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ''.img_picto($langs->trans("Delete"), 'delete').' ';
}
else
{
print ''.$langs->trans("FileNotYetGenerated").' ';
- print ' ';
+ print ' ';
}
print '';
}
@@ -3095,8 +3100,8 @@ elseif (! empty($module))
print '
';
print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.' ';
- print ' '.img_picto($langs->trans("Edit"), 'edit').' ';
- print ''.img_picto($langs->trans("Delete"), 'delete').' ';
+ print ''.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ''.img_picto($langs->trans("Delete"), 'delete').' ';
print '';
}
}
@@ -3104,7 +3109,7 @@ elseif (! empty($module))
{
print '
';
print ' '.$langs->trans("NoTrigger");
- print ' ';
+ print ' ';
print '';
}
print '
';
@@ -3151,19 +3156,19 @@ elseif (! empty($module))
if (dol_is_file($dirins.'/'.$pathtohook))
{
print ''.$pathtohook.' ';
- print ''.img_picto($langs->trans("Edit"), 'edit').' ';
- print ''.img_picto($langs->trans("Delete"), 'delete').' ';
+ print ''.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ''.img_picto($langs->trans("Delete"), 'delete').' ';
}
else
{
print ''.$langs->trans("FileNotYetGenerated").' ';
- print ' ';
+ print ' ';
}
print '';
}
else
{
- $fullpathoffile=dol_buildpath($file, 0);
+ $fullpathoffile = dol_buildpath($file, 0);
$content = file_get_contents($fullpathoffile);
@@ -3175,8 +3180,8 @@ elseif (! empty($module))
print ' ';
print ' ';
- $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
- print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html'));
+ $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
+ print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html'));
print ' ';
print '';
print ' ';
@@ -3203,19 +3208,19 @@ elseif (! empty($module))
if (dol_is_file($dirins.'/'.$pathtohook))
{
print ''.$pathtohook.' ';
- print ''.img_picto($langs->trans("Edit"), 'edit').' ';
- print ''.img_picto($langs->trans("Delete"), 'delete').' ';
+ print ''.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ''.img_picto($langs->trans("Delete"), 'delete').' ';
}
else
{
print ''.$langs->trans("FileNotYetGenerated").' ';
- print ' ';
+ print ' ';
}
print '';
}
else
{
- $fullpathoffile=dol_buildpath($file, 0);
+ $fullpathoffile = dol_buildpath($file, 0);
$content = file_get_contents($fullpathoffile);
@@ -3227,8 +3232,8 @@ elseif (! empty($module))
print ' ';
print ' ';
- $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
- print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html'));
+ $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
+ print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html'));
print ' ';
print '';
print ' ';
@@ -3259,15 +3264,15 @@ elseif (! empty($module))
$pathtofile = $widget['relpath'];
print ' '.$langs->trans("WidgetFile").' : '.$pathtofile.' ';
- print ''.img_picto($langs->trans("Edit"), 'edit').' ';
- print ''.img_picto($langs->trans("Delete"), 'delete').' ';
+ print ''.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ''.img_picto($langs->trans("Delete"), 'delete').' ';
print ' ';
}
}
else
{
print ' '.$langs->trans("NoWidget");
- print ' ';
+ print ' ';
print ' ';
}
print '
';
@@ -3345,15 +3350,15 @@ elseif (! empty($module))
$pathtofile = $clifile['relpath'];
print ' '.$langs->trans("CLIFile").' : '.$pathtofile.' ';
- print ''.img_picto($langs->trans("Edit"), 'edit').' ';
- print ''.img_picto($langs->trans("Delete"), 'delete').' ';
+ print ''.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ''.img_picto($langs->trans("Delete"), 'delete').' ';
print ' ';
}
}
else
{
print ' '.$langs->trans("NoCLIFile");
- print ' ';
+ print ' ';
print ' ';
}
print '
';
@@ -3397,7 +3402,7 @@ elseif (! empty($module))
print ' ';
print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.' ';
- print ' '.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ' '.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
print ' ';
@@ -3526,8 +3531,8 @@ elseif (! empty($module))
if (preg_match('/\.md$/i', $spec['name'])) $format = 'markdown';
print '';
print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.' ';
- print ' '.img_picto($langs->trans("Edit"), 'edit').' ';
- print ''.img_picto($langs->trans("Delete"), 'delete').' ';
+ print ''.img_picto($langs->trans("Edit"), 'edit').' ';
+ print ''.img_picto($langs->trans("Delete"), 'delete').' ';
print ' ';
}
}
@@ -3535,7 +3540,7 @@ elseif (! empty($module))
{
print '';
print ' '.$langs->trans("FileNotYetGenerated");
- print ' ';
+ print ' ';
print ' ';
}
print '
';
@@ -3613,7 +3618,7 @@ elseif (! empty($module))
print ' ';
print ' ';
print ' ';
print '';
}
@@ -3623,28 +3628,28 @@ elseif (! empty($module))
print ''.$langs->trans("BuildPackageDesc").' ';
print ' ';
- if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP'))
+ if (!class_exists('ZipArchive') && !defined('ODTPHP_PATHTOPCLZIP'))
{
print img_warning().' '.$langs->trans("ErrNoZipEngine");
print ' ';
}
- $modulelowercase=strtolower($module);
+ $modulelowercase = strtolower($module);
// Zip file to build
- $FILENAMEZIP='';
+ $FILENAMEZIP = '';
// Load module
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
dol_include_once($pathtofile);
- $class='mod'.$module;
+ $class = 'mod'.$module;
if (class_exists($class))
{
try {
$moduleobj = new $class($db);
}
- catch(Exception $e)
+ catch (Exception $e)
{
$error++;
dol_print_error($e->getMessage());
diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php
index 530b320b111..45548c28312 100644
--- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php
+++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php
@@ -117,7 +117,7 @@ class ActionsMyModule
/**
- * Overloading the doActions function : replacing the parent's function with the one below
+ * Overloading the doMassActions function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadatas (context, etc...)
* @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
@@ -238,5 +238,46 @@ class ActionsMyModule
return $ret;
}
+
+
+ /**
+ * Overloading the loadDataForCustomReports function : returns data to complete the customreport tool
+ *
+ * @param array $parameters Hook metadatas (context, etc...)
+ * @param string $action Current action (if set). Generally create or edit or null
+ * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
+ * @return int < 0 on error, 0 on success, 1 to replace standard code
+ */
+ public function loadDataForCustomReports($parameters, &$action, $hookmanager)
+ {
+ global $conf, $user, $langs;
+
+ $langs->load("mymodule@mymodule");
+
+ $this->results = array();
+
+ $head = array();
+ $h = 0;
+
+ if ($parameters['tabfamily'] == 'mymodule') {
+ $head[$h][0] = dol_buildpath('/module/index.php', 1);
+ $head[$h][1] = $langs->trans("Home");
+ $head[$h][2] = 'home';
+ $h++;
+
+ $this->results['title'] = $langs->trans("MyModule");
+ $this->results['picto'] = 'mymodule@mymodule';
+ }
+
+ $head[$h][0] = 'customreports.php?objecttype='.$parameters['objecttype'].(empty($parameters['tabfamily'])?'':'&tabfamily='.$parameters['tabfamily']);
+ $head[$h][1] = $langs->trans("CustomReports");
+ $head[$h][2] = 'customreports';
+
+ $this->results['head'] = $head;
+
+ return 1;
+ }
+
+
/* Add here any other hooked methods... */
}
diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php
index d7a810ac2cd..6dd93aceacd 100644
--- a/htdocs/modulebuilder/template/class/api_mymodule.class.php
+++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php
@@ -63,6 +63,7 @@ class MyModuleApi extends DolibarrApi
* @return array|mixed data without useless information
*
* @url GET myobjects/{id}
+ *
* @throws RestException
*/
public function get($id)
@@ -186,6 +187,8 @@ class MyModuleApi extends DolibarrApi
* @param array $request_data Request datas
* @return int ID of myobject
*
+ * @throws RestException
+ *
* @url POST myobjects/
*/
public function post($request_data = null)
@@ -212,6 +215,8 @@ class MyModuleApi extends DolibarrApi
* @param array $request_data Datas
* @return int
*
+ * @throws RestException
+ *
* @url PUT myobjects/{id}
*/
public function put($id, $request_data = null)
@@ -250,6 +255,8 @@ class MyModuleApi extends DolibarrApi
* @param int $id MyObject ID
* @return array
*
+ * @throws RestException
+ *
* @url DELETE myobjects/{id}
*/
public function delete($id)
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index 596e47e12c0..fe4cc0931fd 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -43,7 +43,8 @@ class MyObject extends CommonObject
public $table_element = 'mymodule_myobject';
/**
- * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+ * @var int Does this object support multicompany module ?
+ * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
*/
public $ismultientitymanaged = 0;
@@ -67,7 +68,7 @@ class MyObject extends CommonObject
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
* 'label' the translation key.
- * 'enabled' is a condition when the field must be managed.
+ * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
* 'position' is the sort order of field.
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
@@ -237,13 +238,13 @@ class MyObject extends CommonObject
// Translate some data of arrayofkeyval
if (is_object($langs))
{
- foreach($this->fields as $key => $val)
+ foreach ($this->fields as $key => $val)
{
if (is_array($val['arrayofkeyval']))
{
- foreach($val['arrayofkeyval'] as $key2 => $val2)
+ foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
- $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2);
+ $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
}
}
}
@@ -733,7 +734,7 @@ class MyObject extends CommonObject
$label .= ' ';
$label .= ''.$langs->trans('Ref').': '.$this->ref;
if (isset($this->status)) {
- $label.= '' . $langs->trans("Status").": ".$this->getLibStatut(5);
+ $label .= ''.$langs->trans("Status").": ".$this->getLibStatut(5);
}
$url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id;
diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php
index 43970122919..b6aa0399447 100644
--- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php
+++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php
@@ -18,19 +18,19 @@ dol_include_once("/mymodule/class/myobject.class.php");
class mailing_mailinglist_mymodule_myobject extends MailingTargets
{
// CHANGE THIS: Put here a name not already used
- public $name='mailinglist_mymodule_myobject';
+ public $name = 'mailinglist_mymodule_myobject';
// CHANGE THIS: Put here a description of your selector module
- public $desc='My object emailing target selector';
+ public $desc = 'My object emailing target selector';
// CHANGE THIS: Set to 1 if selector is available for admin users only
- public $require_admin=0;
+ public $require_admin = 0;
- public $enabled=0;
- public $require_module=array();
+ public $enabled = 0;
+ public $require_module = array();
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
- public $picto='mymodule@mymodule';
+ public $picto = 'mymodule@mymodule';
/**
* @var DoliDB Database handler.
@@ -47,10 +47,10 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
{
global $conf;
- $this->db=$db;
+ $this->db = $db;
if (is_array($conf->modules))
{
- $this->enabled=in_array('mymodule', $conf->modules)?1:0;
+ $this->enabled = in_array('mymodule', $conf->modules) ? 1 : 0;
}
}
@@ -65,20 +65,20 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
global $langs;
$langs->load("members");
- $form=new Form($this->db);
+ $form = new Form($this->db);
- $arraystatus=array(1=>'Option 1', 2=>'Option 2');
+ $arraystatus = array(1=>'Option 1', 2=>'Option 2');
- $s='';
- $s.=$langs->trans("Status").': ';
- $s.='';
- $s.=' ';
- foreach($arraystatus as $status)
+ $s = '';
+ $s .= $langs->trans("Status").': ';
+ $s .= '';
+ $s .= ' ';
+ foreach ($arraystatus as $status)
{
- $s.=''.$status.' ';
+ $s .= ''.$status.' ';
}
- $s.=' ';
- $s.=' ';
+ $s .= ' ';
+ $s .= ' ';
return $s;
}
@@ -110,13 +110,13 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
$j = 0;
$sql = " select rowid as id, email, firstname, lastname, plan, partner";
- $sql.= " from ".MAIN_DB_PREFIX."myobject";
- $sql.= " where email IS NOT NULL AND email != ''";
- if (! empty($_POST['filter']) && $_POST['filter'] != 'none') $sql.= " AND status = '".$this->db->escape($_POST['filter'])."'";
- $sql.= " ORDER BY email";
+ $sql .= " from ".MAIN_DB_PREFIX."myobject";
+ $sql .= " where email IS NOT NULL AND email != ''";
+ if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'";
+ $sql .= " ORDER BY email";
// Stocke destinataires dans target
- $result=$this->db->query($sql);
+ $result = $this->db->query($sql);
if ($result)
{
$num = $this->db->num_rows($result);
@@ -150,7 +150,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
else
{
dol_syslog($this->db->error());
- $this->error=$this->db->error();
+ $this->error = $this->db->error();
return -1;
}
@@ -197,7 +197,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
*/
public function getNbOfRecipients($filter = 1, $option = '')
{
- $a=parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''");
+ $a = parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''");
if ($a < 0) return -1;
return $a;
diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php
index 371a287dffb..09e4902d6f9 100644
--- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php
+++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php
@@ -104,7 +104,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
$old_code_type = $mysoc->typent_code;
$mysoc->code_client = 'CCCCCCCCCC';
$mysoc->typent_code = 'TTTTTTTTTT';
- $numExample = $this->getNextValue($mysoc, '');
+ $numExample = $this->getNextValue($mysoc);
$mysoc->code_client = $old_code_client;
$mysoc->typent_code = $old_code_type;
diff --git a/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php
index aeabc4a95db..8c0675e5157 100644
--- a/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php
+++ b/htdocs/modulebuilder/template/core/tpl/linkedobjectblock_myobject.tpl.php
@@ -50,7 +50,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
date, 'day'); ?>
getLibStatut(7); ?>
- id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
+ id.'&action=dellink&dellinkid='.$key; ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
-if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php";
-if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php";
+$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
+while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
+if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
+if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
// Try main.inc.php using relative path
-if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php";
-if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php";
-if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php";
-if (! $res) die("Include of main fails");
+if (!$res && file_exists("../main.inc.php")) $res = @include "../main.inc.php";
+if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
+if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
+if (!$res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page
$langs->loadLangs(array("mymodule@mymodule"));
-$action=GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
-// Securite acces client
-if (! $user->rights->mymodule->read) accessforbidden();
-$socid=GETPOST('socid', 'int');
+// Security check
+//if (! $user->rights->mymodule->myobject->read) accessforbidden();
+$socid = GETPOST('socid', 'int');
if (isset($user->socid) && $user->socid > 0)
{
$action = '';
$socid = $user->socid;
}
-$max=5;
-$now=dol_now();
+$max = 5;
+$now = dol_now();
/*
@@ -164,8 +164,8 @@ END MODULEBUILDER DRAFT MYOBJECT */
print '