Passed
Push — master ( a56e33...222e44 )
by Alxarafe
36:56
created
dolibarr/htdocs/core/modules/modImport.class.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -33,63 +33,63 @@
 block discarded – undo
33 33
 class modImport extends DolibarrModules
34 34
 {
35 35
 
36
-	/**
37
-	 *   Constructor. Define names, constants, directories, boxes, permissions
38
-	 *
39
-	 *   @param      DoliDB		$db      Database handler
40
-	 */
41
-	function __construct($db)
42
-	{
43
-		$this->db = $db;
44
-		$this->numero = 250;
36
+    /**
37
+     *   Constructor. Define names, constants, directories, boxes, permissions
38
+     *
39
+     *   @param      DoliDB		$db      Database handler
40
+     */
41
+    function __construct($db)
42
+    {
43
+        $this->db = $db;
44
+        $this->numero = 250;
45 45
 
46
-		$this->family = "technic";
46
+        $this->family = "technic";
47 47
         $this->module_position = '70';
48 48
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
50
-		$this->description = "Outils d'imports de donnees Dolibarr (via un assistant)";
51
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
52
-		$this->version = 'dolibarr';
53
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
-		$this->picto = 'technic';
49
+        $this->name = preg_replace('/^mod/i','',get_class($this));
50
+        $this->description = "Outils d'imports de donnees Dolibarr (via un assistant)";
51
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
52
+        $this->version = 'dolibarr';
53
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
+        $this->picto = 'technic';
55 55
 
56
-		// Data directories to create when module is enabled
57
-		$this->dirs = array("/import/temp");
56
+        // Data directories to create when module is enabled
57
+        $this->dirs = array("/import/temp");
58 58
 
59
-		// Config pages
60
-		$this->config_page_url = array();
59
+        // Config pages
60
+        $this->config_page_url = array();
61 61
 
62
-		// Dependencies
63
-		$this->hidden = false;			// A condition to hide module
64
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
65
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
66
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
67
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs.
68
-		$this->phpmax = array();
69
-		$this->need_dolibarr_version = array(2,7,-1);	// Minimum version of Dolibarr required by module
70
-		$this->need_javascript_ajax = 1;
62
+        // Dependencies
63
+        $this->hidden = false;			// A condition to hide module
64
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
65
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
66
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
67
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs.
68
+        $this->phpmax = array();
69
+        $this->need_dolibarr_version = array(2,7,-1);	// Minimum version of Dolibarr required by module
70
+        $this->need_javascript_ajax = 1;
71 71
 
72
-		// Constants
73
-		$this->const = array();
72
+        // Constants
73
+        $this->const = array();
74 74
 
75
-		// Boxes
76
-		$this->boxes = array();
75
+        // Boxes
76
+        $this->boxes = array();
77 77
 
78
-		// Permissions
79
-		$this->rights = array();
80
-		$this->rights_class = 'import';
81
-		$r=0;
78
+        // Permissions
79
+        $this->rights = array();
80
+        $this->rights_class = 'import';
81
+        $r=0;
82 82
 
83
-		$r++;
84
-		$this->rights[$r][0] = 1251;
85
-		$this->rights[$r][1] = 'Run mass imports of external data (data load)';
86
-		$this->rights[$r][2] = 'r';
87
-		$this->rights[$r][3] = 0;
88
-		$this->rights[$r][4] = 'run';
83
+        $r++;
84
+        $this->rights[$r][0] = 1251;
85
+        $this->rights[$r][1] = 'Run mass imports of external data (data load)';
86
+        $this->rights[$r][2] = 'r';
87
+        $this->rights[$r][3] = 0;
88
+        $this->rights[$r][4] = 'run';
89 89
 
90 90
 
91
-		// Menus
92
-		//-------
93
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
94
-	}
91
+        // Menus
92
+        //-------
93
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
94
+    }
95 95
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *	\brief      Fichier de description et activation du module Import
25 25
  */
26 26
 
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 
30 30
 /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$this->family = "technic";
47 47
         $this->module_position = '70';
48 48
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
49
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
50 50
 		$this->description = "Outils d'imports de donnees Dolibarr (via un assistant)";
51 51
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
52 52
 		$this->version = 'dolibarr';
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 		$this->config_page_url = array();
61 61
 
62 62
 		// Dependencies
63
-		$this->hidden = false;			// A condition to hide module
64
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
65
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
66
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
67
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs.
63
+		$this->hidden = false; // A condition to hide module
64
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
65
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
66
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
67
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module - Need auto_detect_line_endings php option to solve MAC pbs.
68 68
 		$this->phpmax = array();
69
-		$this->need_dolibarr_version = array(2,7,-1);	// Minimum version of Dolibarr required by module
69
+		$this->need_dolibarr_version = array(2, 7, -1); // Minimum version of Dolibarr required by module
70 70
 		$this->need_javascript_ajax = 1;
71 71
 
72 72
 		// Constants
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		// Permissions
79 79
 		$this->rights = array();
80 80
 		$this->rights_class = 'import';
81
-		$r=0;
81
+		$r = 0;
82 82
 
83 83
 		$r++;
84 84
 		$this->rights[$r][0] = 1251;
@@ -90,6 +90,6 @@  discard block
 block discarded – undo
90 90
 
91 91
 		// Menus
92 92
 		//-------
93
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
93
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
94 94
 	}
95 95
 }
Please login to merge, or discard this patch.
modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php 3 patches
Indentation   +486 added lines, -486 removed lines patch added patch discarded remove patch
@@ -38,502 +38,502 @@
 block discarded – undo
38 38
  */
39 39
 class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
40 40
 {
41
-	/**
42
-	 * Issuer
43
-	 * @var Societe
44
-	 */
45
-	public $emetteur;
46
-
47
-	/**
48
-   * @var array() Minimum version of PHP required by module.
49
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
50
-   */
51
-	public $phpmin = array(5, 4);
52
-
53
-	/**
54
-   * Dolibarr version of the loaded document
55
-   * @public string
56
-   */
57
-	public $version = 'dolibarr';
58
-
59
-
60
-	/**
61
-	 *	Constructor
62
-	 *
63
-	 *  @param		DoliDB		$db      Database handler
64
-	 */
65
-	function __construct($db)
66
-	{
67
-		global $conf, $langs, $mysoc;
68
-
69
-		// Load translation files required by the page
41
+    /**
42
+     * Issuer
43
+     * @var Societe
44
+     */
45
+    public $emetteur;
46
+
47
+    /**
48
+     * @var array() Minimum version of PHP required by module.
49
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
50
+     */
51
+    public $phpmin = array(5, 4);
52
+
53
+    /**
54
+     * Dolibarr version of the loaded document
55
+     * @public string
56
+     */
57
+    public $version = 'dolibarr';
58
+
59
+
60
+    /**
61
+     *	Constructor
62
+     *
63
+     *  @param		DoliDB		$db      Database handler
64
+     */
65
+    function __construct($db)
66
+    {
67
+        global $conf, $langs, $mysoc;
68
+
69
+        // Load translation files required by the page
70 70
         $langs->loadLangs(array("main","companies"));
71 71
 
72
-		$this->db = $db;
73
-		$this->name = "ODT templates";
74
-		$this->description = $langs->trans("DocumentModelOdt");
75
-		$this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
76
-
77
-		// Dimension page pour format A4
78
-		$this->type = 'odt';
79
-		$this->page_largeur = 0;
80
-		$this->page_hauteur = 0;
81
-		$this->format = array($this->page_largeur,$this->page_hauteur);
82
-		$this->marge_gauche=0;
83
-		$this->marge_droite=0;
84
-		$this->marge_haute=0;
85
-		$this->marge_basse=0;
86
-
87
-		$this->option_logo = 1;                    // Affiche logo
88
-		$this->option_tva = 0;                     // Gere option tva PROPALE_TVAOPTION
89
-		$this->option_modereg = 0;                 // Affiche mode reglement
90
-		$this->option_condreg = 0;                 // Affiche conditions reglement
91
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
92
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
93
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
94
-		$this->option_credit_note = 0;             // Support credit notes
95
-		$this->option_freetext = 1;				   // Support add of a personalised text
96
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
97
-
98
-		// Recupere emetteur
99
-		$this->emetteur=$mysoc;
100
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
101
-	}
102
-
103
-
104
-	/**
105
-	 *	Return description of a module
106
-	 *
107
-	 *	@param	Translate	$langs      Lang object to use for output
108
-	 *	@return string       			Description
109
-	 */
110
-	function info($langs)
111
-	{
112
-		global $conf, $langs;
113
-
114
-		// Load translation files required by the page
72
+        $this->db = $db;
73
+        $this->name = "ODT templates";
74
+        $this->description = $langs->trans("DocumentModelOdt");
75
+        $this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
76
+
77
+        // Dimension page pour format A4
78
+        $this->type = 'odt';
79
+        $this->page_largeur = 0;
80
+        $this->page_hauteur = 0;
81
+        $this->format = array($this->page_largeur,$this->page_hauteur);
82
+        $this->marge_gauche=0;
83
+        $this->marge_droite=0;
84
+        $this->marge_haute=0;
85
+        $this->marge_basse=0;
86
+
87
+        $this->option_logo = 1;                    // Affiche logo
88
+        $this->option_tva = 0;                     // Gere option tva PROPALE_TVAOPTION
89
+        $this->option_modereg = 0;                 // Affiche mode reglement
90
+        $this->option_condreg = 0;                 // Affiche conditions reglement
91
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
92
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
93
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
94
+        $this->option_credit_note = 0;             // Support credit notes
95
+        $this->option_freetext = 1;				   // Support add of a personalised text
96
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
97
+
98
+        // Recupere emetteur
99
+        $this->emetteur=$mysoc;
100
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
101
+    }
102
+
103
+
104
+    /**
105
+     *	Return description of a module
106
+     *
107
+     *	@param	Translate	$langs      Lang object to use for output
108
+     *	@return string       			Description
109
+     */
110
+    function info($langs)
111
+    {
112
+        global $conf, $langs;
113
+
114
+        // Load translation files required by the page
115 115
         $langs->loadLangs(array('companies', 'errors'));
116 116
 
117
-		$form = new Form($this->db);
118
-
119
-		$texte = $this->description.".<br>\n";
120
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
123
-		$texte.= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
124
-		if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
125
-		{
126
-			$texte.= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
127
-			$texte.= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
128
-			$texte.= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
129
-		}
130
-		$texte.= '<table class="nobordernopadding" width="100%">';
131
-
132
-		// List of directories area
133
-		$texte.= '<tr><td>';
134
-		$texttitle=$langs->trans("ListOfDirectories");
135
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
136
-		$listoffiles=array();
137
-		foreach($listofdir as $key=>$tmpdir)
138
-		{
139
-			$tmpdir=trim($tmpdir);
140
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
141
-			if (! $tmpdir) {
142
-				unset($listofdir[$key]); continue;
143
-			}
144
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
-			else
146
-			{
147
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
149
-			}
150
-		}
151
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
152
-		// Add list of substitution keys
153
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
155
-
156
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
157
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
159
-		$texte.=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
160
-		$texte.= '</textarea>';
161
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
162
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
-		$texte.= '<br></div></div>';
164
-
165
-		// Scan directories
166
-		$nbofiles=count($listoffiles);
167
-		if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))
168
-		{
169
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
170
-			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
171
-			$texte.=count($listoffiles);
172
-			//$texte.=$nbofiles?'</a>':'';
173
-			$texte.='</b>';
174
-		}
175
-
176
-		if ($nbofiles)
177
-		{
178
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
179
-   			foreach($listoffiles as $file)
180
-   			{
117
+        $form = new Form($this->db);
118
+
119
+        $texte = $this->description.".<br>\n";
120
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
123
+        $texte.= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
124
+        if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
125
+        {
126
+            $texte.= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
127
+            $texte.= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
128
+            $texte.= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
129
+        }
130
+        $texte.= '<table class="nobordernopadding" width="100%">';
131
+
132
+        // List of directories area
133
+        $texte.= '<tr><td>';
134
+        $texttitle=$langs->trans("ListOfDirectories");
135
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
136
+        $listoffiles=array();
137
+        foreach($listofdir as $key=>$tmpdir)
138
+        {
139
+            $tmpdir=trim($tmpdir);
140
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
141
+            if (! $tmpdir) {
142
+                unset($listofdir[$key]); continue;
143
+            }
144
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
+            else
146
+            {
147
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
149
+            }
150
+        }
151
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
152
+        // Add list of substitution keys
153
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
155
+
156
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
157
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
159
+        $texte.=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
160
+        $texte.= '</textarea>';
161
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
162
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
+        $texte.= '<br></div></div>';
164
+
165
+        // Scan directories
166
+        $nbofiles=count($listoffiles);
167
+        if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))
168
+        {
169
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
170
+            //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
171
+            $texte.=count($listoffiles);
172
+            //$texte.=$nbofiles?'</a>':'';
173
+            $texte.='</b>';
174
+        }
175
+
176
+        if ($nbofiles)
177
+        {
178
+                $texte.='<div id="div_'.get_class($this).'" class="hidden">';
179
+                foreach($listoffiles as $file)
180
+                {
181 181
                 $texte.=$file['name'].'<br>';
182
-   			}
183
-   			$texte.='<div id="div_'.get_class($this).'">';
184
-
185
-			if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
186
-			{
187
-				// Model for creation
188
-				$liste=ModelePDFSupplierProposal::liste_modeles($this->db);
189
-				$texte.= '<table width="50%;">';
190
-				$texte.= '<tr>';
191
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
192
-				$texte.= '<td colspan="">';
193
-				$texte.= $form->selectarray('value2',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
194
-				$texte.= "</td></tr>";
195
-
196
-				$texte.= '<tr>';
197
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
198
-				$texte.= '<td colspan="">';
199
-				$texte.= $form->selectarray('value3',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
200
-				$texte.= "</td></tr>";
201
-				$texte.= '<tr>';
202
-
203
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
204
-				$texte.= '<td colspan="">';
205
-				$texte.= $form->selectarray('value4',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
206
-				$texte.= "</td></tr>";
207
-				$texte.= '</table>';
208
-			}
209
-		}
210
-
211
-		$texte.= '</td>';
212
-
213
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
214
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
215
-		$texte.= '</td>';
216
-		$texte.= '</tr>';
217
-
218
-		$texte.= '</table>';
219
-		$texte.= '</form>';
220
-
221
-		return $texte;
222
-	}
182
+                }
183
+                $texte.='<div id="div_'.get_class($this).'">';
184
+
185
+            if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
186
+            {
187
+                // Model for creation
188
+                $liste=ModelePDFSupplierProposal::liste_modeles($this->db);
189
+                $texte.= '<table width="50%;">';
190
+                $texte.= '<tr>';
191
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
192
+                $texte.= '<td colspan="">';
193
+                $texte.= $form->selectarray('value2',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
194
+                $texte.= "</td></tr>";
195
+
196
+                $texte.= '<tr>';
197
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
198
+                $texte.= '<td colspan="">';
199
+                $texte.= $form->selectarray('value3',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
200
+                $texte.= "</td></tr>";
201
+                $texte.= '<tr>';
202
+
203
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
204
+                $texte.= '<td colspan="">';
205
+                $texte.= $form->selectarray('value4',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
206
+                $texte.= "</td></tr>";
207
+                $texte.= '</table>';
208
+            }
209
+        }
210
+
211
+        $texte.= '</td>';
212
+
213
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
214
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
215
+        $texte.= '</td>';
216
+        $texte.= '</tr>';
217
+
218
+        $texte.= '</table>';
219
+        $texte.= '</form>';
220
+
221
+        return $texte;
222
+    }
223 223
 
224 224
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
225
-	/**
226
-	 *	Function to build a document on disk using the generic odt module.
227
-	 *
228
-	 *	@param		Propale		$object				Object source to build document
229
-	 *	@param		Translate	$outputlangs		Lang output object
230
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
231
-	 *  @param		int			$hidedetails		Do not show line details
232
-	 *  @param		int			$hidedesc			Do not show desc
233
-	 *  @param		int			$hideref			Do not show ref
234
-	 *	@return		int         					1 if OK, <=0 if KO
235
-	 */
236
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
237
-	{
225
+    /**
226
+     *	Function to build a document on disk using the generic odt module.
227
+     *
228
+     *	@param		Propale		$object				Object source to build document
229
+     *	@param		Translate	$outputlangs		Lang output object
230
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
231
+     *  @param		int			$hidedetails		Do not show line details
232
+     *  @param		int			$hidedesc			Do not show desc
233
+     *  @param		int			$hideref			Do not show ref
234
+     *	@return		int         					1 if OK, <=0 if KO
235
+     */
236
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
237
+    {
238 238
         // phpcs:enable
239
-		global $user, $langs, $conf, $mysoc, $hookmanager;
240
-
241
-		if (empty($srctemplatepath))
242
-		{
243
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
244
-			return -1;
245
-		}
246
-
247
-		// Add odtgeneration hook
248
-		if (! is_object($hookmanager))
249
-		{
250
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
251
-			$hookmanager=new HookManager($this->db);
252
-		}
253
-		$hookmanager->initHooks(array('odtgeneration'));
254
-		global $action;
255
-
256
-		if (! is_object($outputlangs)) $outputlangs=$langs;
257
-		$sav_charset_output=$outputlangs->charset_output;
258
-		$outputlangs->charset_output='UTF-8';
259
-
260
-		// Load translation files required by the page
261
-		$outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
262
-
263
-		if ($conf->supplier_proposal->dir_output)
264
-		{
265
-			// If $object is id instead of object
266
-			if (! is_object($object))
267
-			{
268
-				$id = $object;
269
-				$object = new SupplierProposal($this->db);
270
-				$result=$object->fetch($id);
271
-				if ($result < 0)
272
-				{
273
-					dol_print_error($this->db,$object->error);
274
-					return -1;
275
-				}
276
-			}
277
-
278
-			$dir = $conf->supplier_proposal->dir_output;
279
-			$objectref = dol_sanitizeFileName($object->ref);
280
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
281
-			$file = $dir . "/" . $objectref . ".odt";
282
-
283
-			if (! file_exists($dir))
284
-			{
285
-				if (dol_mkdir($dir) < 0)
286
-				{
287
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
288
-					return -1;
289
-				}
290
-			}
291
-
292
-			if (file_exists($dir))
293
-			{
294
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
295
-				$newfile=basename($srctemplatepath);
296
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
297
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
298
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
299
-
300
-				$newfiletmp=$objectref.'_'.$newfiletmp;
301
-
302
-				// Get extension (ods or odt)
303
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
304
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
305
-				{
306
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
307
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
308
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
309
-				}
310
-				else
311
-				{
312
-					$filename=$newfiletmp.'.'.$newfileformat;
313
-				}
314
-				$file=$dir.'/'.$filename;
315
-				//print "newdir=".$dir;
316
-				//print "newfile=".$newfile;
317
-				//print "file=".$file;
318
-				//print "conf->propal->dir_temp=".$conf->propal->dir_temp;
319
-
320
-				dol_mkdir($conf->supplier_proposal->dir_temp);
321
-
322
-
323
-				// If BILLING contact defined on invoice, we use it
324
-				$usecontact=false;
325
-				$arrayidcontact=$object->getIdContact('external','BILLING');
326
-				if (count($arrayidcontact) > 0)
327
-				{
328
-					$usecontact=true;
329
-					$result=$object->fetch_contact($arrayidcontact[0]);
330
-				}
331
-
332
-				// Recipient name
333
-				if (! empty($usecontact))
334
-				{
335
-					// On peut utiliser le nom de la societe du contact
336
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
337
-					else $socobject = $object->thirdparty;
338
-				}
339
-				else
340
-				{
341
-					$socobject=$object->thirdparty;
342
-				}
343
-
344
-				// Make substitution
345
-				$substitutionarray=array(
346
-				'__FROM_NAME__' => $this->emetteur->name,
347
-				'__FROM_EMAIL__' => $this->emetteur->email,
348
-				'__TOTAL_TTC__' => $object->total_ttc,
349
-				'__TOTAL_HT__' => $object->total_ht,
350
-				'__TOTAL_VAT__' => $object->total_vat
351
-				);
352
-				complete_substitutions_array($substitutionarray, $langs, $object);
353
-				// Call the ODTSubstitution hook
354
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
355
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
356
-
357
-				// Line of free text
358
-				$newfreetext='';
359
-				$paramfreetext='SUPPLIER_PROPOSAL_FREE_TEXT';
360
-				if (! empty($conf->global->$paramfreetext))
361
-				{
362
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
363
-				}
364
-
365
-				// Open and load template
366
-				require_once ODTPHP_PATH.'odf.php';
367
-				try {
368
-					$odfHandler = new odf(
369
-						$srctemplatepath,
370
-						array(
371
-							'PATH_TO_TMP'	  => $conf->supplier_proposal->dir_temp,
372
-							'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
373
-							'DELIMITER_LEFT'  => '{',
374
-							'DELIMITER_RIGHT' => '}'
375
-						)
376
-					);
377
-				}
378
-				catch (Exception $e)
379
-				{
380
-					$this->error=$e->getMessage();
381
-					dol_syslog($e->getMessage(), LOG_INFO);
382
-					return -1;
383
-				}
384
-				// After construction $odfHandler->contentXml contains content and
385
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
386
-				// [!-- BEGIN lines --]*[!-- END lines --]
387
-				//print html_entity_decode($odfHandler->__toString());
388
-				//print exit;
389
-
390
-
391
-				// Make substitutions into odt of freetext
392
-				try {
393
-					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
394
-				}
395
-				catch (OdfException $e)
396
-				{
397
-					dol_syslog($e->getMessage(), LOG_INFO);
398
-				}
399
-
400
-				// Define substitution array
401
-				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
402
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
403
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
404
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
405
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
406
-				$array_other=$this->get_substitutionarray_other($outputlangs);
407
-
408
-				$tmparray = array_merge($substitutionarray,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
409
-				complete_substitutions_array($tmparray, $outputlangs, $object);
410
-
411
-				// Call the ODTSubstitution hook
412
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
413
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
414
-
415
-				foreach($tmparray as $key=>$value)
416
-				{
417
-					try {
418
-						if (preg_match('/logo$/',$key)) // Image
419
-						{
420
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
421
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
422
-						}
423
-						else    // Text
424
-						{
425
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
426
-						}
427
-					}
428
-					catch(OdfException $e)
429
-					{
239
+        global $user, $langs, $conf, $mysoc, $hookmanager;
240
+
241
+        if (empty($srctemplatepath))
242
+        {
243
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
244
+            return -1;
245
+        }
246
+
247
+        // Add odtgeneration hook
248
+        if (! is_object($hookmanager))
249
+        {
250
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
251
+            $hookmanager=new HookManager($this->db);
252
+        }
253
+        $hookmanager->initHooks(array('odtgeneration'));
254
+        global $action;
255
+
256
+        if (! is_object($outputlangs)) $outputlangs=$langs;
257
+        $sav_charset_output=$outputlangs->charset_output;
258
+        $outputlangs->charset_output='UTF-8';
259
+
260
+        // Load translation files required by the page
261
+        $outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
262
+
263
+        if ($conf->supplier_proposal->dir_output)
264
+        {
265
+            // If $object is id instead of object
266
+            if (! is_object($object))
267
+            {
268
+                $id = $object;
269
+                $object = new SupplierProposal($this->db);
270
+                $result=$object->fetch($id);
271
+                if ($result < 0)
272
+                {
273
+                    dol_print_error($this->db,$object->error);
274
+                    return -1;
275
+                }
276
+            }
277
+
278
+            $dir = $conf->supplier_proposal->dir_output;
279
+            $objectref = dol_sanitizeFileName($object->ref);
280
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
281
+            $file = $dir . "/" . $objectref . ".odt";
282
+
283
+            if (! file_exists($dir))
284
+            {
285
+                if (dol_mkdir($dir) < 0)
286
+                {
287
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
288
+                    return -1;
289
+                }
290
+            }
291
+
292
+            if (file_exists($dir))
293
+            {
294
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
295
+                $newfile=basename($srctemplatepath);
296
+                $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
297
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
298
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
299
+
300
+                $newfiletmp=$objectref.'_'.$newfiletmp;
301
+
302
+                // Get extension (ods or odt)
303
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
304
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
305
+                {
306
+                    $format=$conf->global->MAIN_DOC_USE_TIMING;
307
+                    if ($format == '1') $format='%Y%m%d%H%M%S';
308
+                    $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
309
+                }
310
+                else
311
+                {
312
+                    $filename=$newfiletmp.'.'.$newfileformat;
313
+                }
314
+                $file=$dir.'/'.$filename;
315
+                //print "newdir=".$dir;
316
+                //print "newfile=".$newfile;
317
+                //print "file=".$file;
318
+                //print "conf->propal->dir_temp=".$conf->propal->dir_temp;
319
+
320
+                dol_mkdir($conf->supplier_proposal->dir_temp);
321
+
322
+
323
+                // If BILLING contact defined on invoice, we use it
324
+                $usecontact=false;
325
+                $arrayidcontact=$object->getIdContact('external','BILLING');
326
+                if (count($arrayidcontact) > 0)
327
+                {
328
+                    $usecontact=true;
329
+                    $result=$object->fetch_contact($arrayidcontact[0]);
330
+                }
331
+
332
+                // Recipient name
333
+                if (! empty($usecontact))
334
+                {
335
+                    // On peut utiliser le nom de la societe du contact
336
+                    if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
337
+                    else $socobject = $object->thirdparty;
338
+                }
339
+                else
340
+                {
341
+                    $socobject=$object->thirdparty;
342
+                }
343
+
344
+                // Make substitution
345
+                $substitutionarray=array(
346
+                '__FROM_NAME__' => $this->emetteur->name,
347
+                '__FROM_EMAIL__' => $this->emetteur->email,
348
+                '__TOTAL_TTC__' => $object->total_ttc,
349
+                '__TOTAL_HT__' => $object->total_ht,
350
+                '__TOTAL_VAT__' => $object->total_vat
351
+                );
352
+                complete_substitutions_array($substitutionarray, $langs, $object);
353
+                // Call the ODTSubstitution hook
354
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
355
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
356
+
357
+                // Line of free text
358
+                $newfreetext='';
359
+                $paramfreetext='SUPPLIER_PROPOSAL_FREE_TEXT';
360
+                if (! empty($conf->global->$paramfreetext))
361
+                {
362
+                    $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
363
+                }
364
+
365
+                // Open and load template
366
+                require_once ODTPHP_PATH.'odf.php';
367
+                try {
368
+                    $odfHandler = new odf(
369
+                        $srctemplatepath,
370
+                        array(
371
+                            'PATH_TO_TMP'	  => $conf->supplier_proposal->dir_temp,
372
+                            'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
373
+                            'DELIMITER_LEFT'  => '{',
374
+                            'DELIMITER_RIGHT' => '}'
375
+                        )
376
+                    );
377
+                }
378
+                catch (Exception $e)
379
+                {
380
+                    $this->error=$e->getMessage();
381
+                    dol_syslog($e->getMessage(), LOG_INFO);
382
+                    return -1;
383
+                }
384
+                // After construction $odfHandler->contentXml contains content and
385
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
386
+                // [!-- BEGIN lines --]*[!-- END lines --]
387
+                //print html_entity_decode($odfHandler->__toString());
388
+                //print exit;
389
+
390
+
391
+                // Make substitutions into odt of freetext
392
+                try {
393
+                    $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
394
+                }
395
+                catch (OdfException $e)
396
+                {
397
+                    dol_syslog($e->getMessage(), LOG_INFO);
398
+                }
399
+
400
+                // Define substitution array
401
+                $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
402
+                $array_objet=$this->get_substitutionarray_object($object,$outputlangs);
403
+                $array_user=$this->get_substitutionarray_user($user,$outputlangs);
404
+                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
405
+                $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
406
+                $array_other=$this->get_substitutionarray_other($outputlangs);
407
+
408
+                $tmparray = array_merge($substitutionarray,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
409
+                complete_substitutions_array($tmparray, $outputlangs, $object);
410
+
411
+                // Call the ODTSubstitution hook
412
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
413
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
414
+
415
+                foreach($tmparray as $key=>$value)
416
+                {
417
+                    try {
418
+                        if (preg_match('/logo$/',$key)) // Image
419
+                        {
420
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
421
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
422
+                        }
423
+                        else    // Text
424
+                        {
425
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
426
+                        }
427
+                    }
428
+                    catch(OdfException $e)
429
+                    {
430 430
                         dol_syslog($e->getMessage(), LOG_INFO);
431
-					}
432
-				}
433
-				// Replace tags of lines
434
-				try
435
-				{
436
-					$foundtagforlines = 1;
437
-					try {
438
-						$listlines = $odfHandler->setSegment('lines');
439
-					}
440
-					catch(OdfException $e)
441
-					{
442
-						// We may arrive here if tags for lines not present into template
443
-						$foundtagforlines = 0;
444
-						dol_syslog($e->getMessage(), LOG_INFO);
445
-					}
446
-					if ($foundtagforlines)
447
-					{
448
-						foreach ($object->lines as $line)
449
-						{
450
-							$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
451
-							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
452
-							// Call the ODTSubstitutionLine hook
453
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
454
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
455
-							foreach($tmparray as $key => $val)
456
-							{
457
-								try
458
-								{
459
-									$listlines->setVars($key, $val, true, 'UTF-8');
460
-								}
461
-								catch(OdfException $e)
462
-								{
463
-									dol_syslog($e->getMessage(), LOG_INFO);
464
-								}
465
-								catch(SegmentException $e)
466
-								{
467
-									dol_syslog($e->getMessage(), LOG_INFO);
468
-								}
469
-							}
470
-							$listlines->merge();
471
-						}
472
-						$odfHandler->mergeSegment($listlines);
473
-					}
474
-				}
475
-				catch(OdfException $e)
476
-				{
477
-					$this->error=$e->getMessage();
478
-					dol_syslog($this->error, LOG_WARNING);
479
-					return -1;
480
-				}
481
-
482
-				// Replace labels translated
483
-				$tmparray=$outputlangs->get_translations_for_substitutions();
484
-				foreach($tmparray as $key=>$value)
485
-				{
486
-					try {
487
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
488
-					}
489
-					catch(OdfException $e)
490
-					{
431
+                    }
432
+                }
433
+                // Replace tags of lines
434
+                try
435
+                {
436
+                    $foundtagforlines = 1;
437
+                    try {
438
+                        $listlines = $odfHandler->setSegment('lines');
439
+                    }
440
+                    catch(OdfException $e)
441
+                    {
442
+                        // We may arrive here if tags for lines not present into template
443
+                        $foundtagforlines = 0;
491 444
                         dol_syslog($e->getMessage(), LOG_INFO);
492
-					}
493
-				}
494
-
495
-				// Call the beforeODTSave hook
496
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
497
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
498
-
499
-				// Write new file
500
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
501
-					try {
502
-						$odfHandler->exportAsAttachedPDF($file);
503
-					} catch (Exception $e) {
504
-						$this->error=$e->getMessage();
445
+                    }
446
+                    if ($foundtagforlines)
447
+                    {
448
+                        foreach ($object->lines as $line)
449
+                        {
450
+                            $tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
451
+                            complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
452
+                            // Call the ODTSubstitutionLine hook
453
+                            $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
454
+                            $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
455
+                            foreach($tmparray as $key => $val)
456
+                            {
457
+                                try
458
+                                {
459
+                                    $listlines->setVars($key, $val, true, 'UTF-8');
460
+                                }
461
+                                catch(OdfException $e)
462
+                                {
463
+                                    dol_syslog($e->getMessage(), LOG_INFO);
464
+                                }
465
+                                catch(SegmentException $e)
466
+                                {
467
+                                    dol_syslog($e->getMessage(), LOG_INFO);
468
+                                }
469
+                            }
470
+                            $listlines->merge();
471
+                        }
472
+                        $odfHandler->mergeSegment($listlines);
473
+                    }
474
+                }
475
+                catch(OdfException $e)
476
+                {
477
+                    $this->error=$e->getMessage();
478
+                    dol_syslog($this->error, LOG_WARNING);
479
+                    return -1;
480
+                }
481
+
482
+                // Replace labels translated
483
+                $tmparray=$outputlangs->get_translations_for_substitutions();
484
+                foreach($tmparray as $key=>$value)
485
+                {
486
+                    try {
487
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
488
+                    }
489
+                    catch(OdfException $e)
490
+                    {
505 491
                         dol_syslog($e->getMessage(), LOG_INFO);
506
-						return -1;
507
-					}
508
-				}
509
-				else {
510
-					try {
511
-						$odfHandler->saveToDisk($file);
512
-					} catch (Exception $e) {
513
-						$this->error=$e->getMessage();
492
+                    }
493
+                }
494
+
495
+                // Call the beforeODTSave hook
496
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
497
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
498
+
499
+                // Write new file
500
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
501
+                    try {
502
+                        $odfHandler->exportAsAttachedPDF($file);
503
+                    } catch (Exception $e) {
504
+                        $this->error=$e->getMessage();
514 505
                         dol_syslog($e->getMessage(), LOG_INFO);
515
-						return -1;
516
-					}
517
-				}
518
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
519
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
520
-
521
-				if (! empty($conf->global->MAIN_UMASK))
522
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
523
-
524
-				$odfHandler=null;	// Destroy object
525
-
526
-				$this->result = array('fullpath'=>$file);
527
-
528
-				return 1;   // Success
529
-			}
530
-			else
531
-			{
532
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
533
-				return -1;
534
-			}
535
-		}
536
-
537
-		return -1;
538
-	}
506
+                        return -1;
507
+                    }
508
+                }
509
+                else {
510
+                    try {
511
+                        $odfHandler->saveToDisk($file);
512
+                    } catch (Exception $e) {
513
+                        $this->error=$e->getMessage();
514
+                        dol_syslog($e->getMessage(), LOG_INFO);
515
+                        return -1;
516
+                    }
517
+                }
518
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
519
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
520
+
521
+                if (! empty($conf->global->MAIN_UMASK))
522
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
523
+
524
+                $odfHandler=null;	// Destroy object
525
+
526
+                $this->result = array('fullpath'=>$file);
527
+
528
+                return 1;   // Success
529
+            }
530
+            else
531
+            {
532
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
533
+                return -1;
534
+            }
535
+        }
536
+
537
+        return -1;
538
+    }
539 539
 }
Please login to merge, or discard this patch.
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -67,37 +67,37 @@  discard block
 block discarded – undo
67 67
 		global $conf, $langs, $mysoc;
68 68
 
69 69
 		// Load translation files required by the page
70
-        $langs->loadLangs(array("main","companies"));
70
+        $langs->loadLangs(array("main", "companies"));
71 71
 
72 72
 		$this->db = $db;
73 73
 		$this->name = "ODT templates";
74 74
 		$this->description = $langs->trans("DocumentModelOdt");
75
-		$this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
75
+		$this->scandir = 'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
76 76
 
77 77
 		// Dimension page pour format A4
78 78
 		$this->type = 'odt';
79 79
 		$this->page_largeur = 0;
80 80
 		$this->page_hauteur = 0;
81
-		$this->format = array($this->page_largeur,$this->page_hauteur);
82
-		$this->marge_gauche=0;
83
-		$this->marge_droite=0;
84
-		$this->marge_haute=0;
85
-		$this->marge_basse=0;
86
-
87
-		$this->option_logo = 1;                    // Affiche logo
88
-		$this->option_tva = 0;                     // Gere option tva PROPALE_TVAOPTION
89
-		$this->option_modereg = 0;                 // Affiche mode reglement
90
-		$this->option_condreg = 0;                 // Affiche conditions reglement
91
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
92
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
93
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
94
-		$this->option_credit_note = 0;             // Support credit notes
95
-		$this->option_freetext = 1;				   // Support add of a personalised text
96
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
81
+		$this->format = array($this->page_largeur, $this->page_hauteur);
82
+		$this->marge_gauche = 0;
83
+		$this->marge_droite = 0;
84
+		$this->marge_haute = 0;
85
+		$this->marge_basse = 0;
86
+
87
+		$this->option_logo = 1; // Affiche logo
88
+		$this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION
89
+		$this->option_modereg = 0; // Affiche mode reglement
90
+		$this->option_condreg = 0; // Affiche conditions reglement
91
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
92
+		$this->option_multilang = 1; // Dispo en plusieurs langues
93
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
94
+		$this->option_credit_note = 0; // Support credit notes
95
+		$this->option_freetext = 1; // Support add of a personalised text
96
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
97 97
 
98 98
 		// Recupere emetteur
99
-		$this->emetteur=$mysoc;
100
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
99
+		$this->emetteur = $mysoc;
100
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
101 101
 	}
102 102
 
103 103
 
@@ -117,106 +117,106 @@  discard block
 block discarded – undo
117 117
 		$form = new Form($this->db);
118 118
 
119 119
 		$texte = $this->description.".<br>\n";
120
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
123
-		$texte.= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
120
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
121
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
122
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
123
+		$texte .= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
124 124
 		if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
125 125
 		{
126
-			$texte.= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
127
-			$texte.= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
128
-			$texte.= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
126
+			$texte .= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
127
+			$texte .= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
128
+			$texte .= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
129 129
 		}
130
-		$texte.= '<table class="nobordernopadding" width="100%">';
130
+		$texte .= '<table class="nobordernopadding" width="100%">';
131 131
 
132 132
 		// List of directories area
133
-		$texte.= '<tr><td>';
134
-		$texttitle=$langs->trans("ListOfDirectories");
135
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
136
-		$listoffiles=array();
137
-		foreach($listofdir as $key=>$tmpdir)
133
+		$texte .= '<tr><td>';
134
+		$texttitle = $langs->trans("ListOfDirectories");
135
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH)));
136
+		$listoffiles = array();
137
+		foreach ($listofdir as $key=>$tmpdir)
138 138
 		{
139
-			$tmpdir=trim($tmpdir);
140
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
141
-			if (! $tmpdir) {
139
+			$tmpdir = trim($tmpdir);
140
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
141
+			if (!$tmpdir) {
142 142
 				unset($listofdir[$key]); continue;
143 143
 			}
144
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
144
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
145 145
 			else
146 146
 			{
147
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
147
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
148
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
149 149
 			}
150 150
 		}
151
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
151
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
152 152
 		// Add list of substitution keys
153
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
155
-
156
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
157
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
159
-		$texte.=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
160
-		$texte.= '</textarea>';
161
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
162
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
-		$texte.= '<br></div></div>';
153
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
154
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
155
+
156
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
157
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
158
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
159
+		$texte .= $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
160
+		$texte .= '</textarea>';
161
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
162
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
163
+		$texte .= '<br></div></div>';
164 164
 
165 165
 		// Scan directories
166
-		$nbofiles=count($listoffiles);
167
-		if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))
166
+		$nbofiles = count($listoffiles);
167
+		if (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH))
168 168
 		{
169
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
169
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
170 170
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
171
-			$texte.=count($listoffiles);
171
+			$texte .= count($listoffiles);
172 172
 			//$texte.=$nbofiles?'</a>':'';
173
-			$texte.='</b>';
173
+			$texte .= '</b>';
174 174
 		}
175 175
 
176 176
 		if ($nbofiles)
177 177
 		{
178
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
179
-   			foreach($listoffiles as $file)
178
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
179
+   			foreach ($listoffiles as $file)
180 180
    			{
181
-                $texte.=$file['name'].'<br>';
181
+                $texte .= $file['name'].'<br>';
182 182
    			}
183
-   			$texte.='<div id="div_'.get_class($this).'">';
183
+   			$texte .= '<div id="div_'.get_class($this).'">';
184 184
 
185 185
 			if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0)
186 186
 			{
187 187
 				// Model for creation
188
-				$liste=ModelePDFSupplierProposal::liste_modeles($this->db);
189
-				$texte.= '<table width="50%;">';
190
-				$texte.= '<tr>';
191
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
192
-				$texte.= '<td colspan="">';
193
-				$texte.= $form->selectarray('value2',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
194
-				$texte.= "</td></tr>";
195
-
196
-				$texte.= '<tr>';
197
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
198
-				$texte.= '<td colspan="">';
199
-				$texte.= $form->selectarray('value3',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
200
-				$texte.= "</td></tr>";
201
-				$texte.= '<tr>';
202
-
203
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
204
-				$texte.= '<td colspan="">';
205
-				$texte.= $form->selectarray('value4',$liste,$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
206
-				$texte.= "</td></tr>";
207
-				$texte.= '</table>';
188
+				$liste = ModelePDFSupplierProposal::liste_modeles($this->db);
189
+				$texte .= '<table width="50%;">';
190
+				$texte .= '<tr>';
191
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalCreate").'</td>';
192
+				$texte .= '<td colspan="">';
193
+				$texte .= $form->selectarray('value2', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
194
+				$texte .= "</td></tr>";
195
+
196
+				$texte .= '<tr>';
197
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalToBill").'</td>';
198
+				$texte .= '<td colspan="">';
199
+				$texte .= $form->selectarray('value3', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
200
+				$texte .= "</td></tr>";
201
+				$texte .= '<tr>';
202
+
203
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelSupplierProposalClosed").'</td>';
204
+				$texte .= '<td colspan="">';
205
+				$texte .= $form->selectarray('value4', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
206
+				$texte .= "</td></tr>";
207
+				$texte .= '</table>';
208 208
 			}
209 209
 		}
210 210
 
211
-		$texte.= '</td>';
211
+		$texte .= '</td>';
212 212
 
213
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
214
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
215
-		$texte.= '</td>';
216
-		$texte.= '</tr>';
213
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
214
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
215
+		$texte .= '</td>';
216
+		$texte .= '</tr>';
217 217
 
218
-		$texte.= '</table>';
219
-		$texte.= '</form>';
218
+		$texte .= '</table>';
219
+		$texte .= '</form>';
220 220
 
221 221
 		return $texte;
222 222
 	}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 *  @param		int			$hideref			Do not show ref
234 234
 	 *	@return		int         					1 if OK, <=0 if KO
235 235
 	 */
236
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
236
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
237 237
 	{
238 238
         // phpcs:enable
239 239
 		global $user, $langs, $conf, $mysoc, $hookmanager;
@@ -245,17 +245,17 @@  discard block
 block discarded – undo
245 245
 		}
246 246
 
247 247
 		// Add odtgeneration hook
248
-		if (! is_object($hookmanager))
248
+		if (!is_object($hookmanager))
249 249
 		{
250 250
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
251
-			$hookmanager=new HookManager($this->db);
251
+			$hookmanager = new HookManager($this->db);
252 252
 		}
253 253
 		$hookmanager->initHooks(array('odtgeneration'));
254 254
 		global $action;
255 255
 
256
-		if (! is_object($outputlangs)) $outputlangs=$langs;
257
-		$sav_charset_output=$outputlangs->charset_output;
258
-		$outputlangs->charset_output='UTF-8';
256
+		if (!is_object($outputlangs)) $outputlangs = $langs;
257
+		$sav_charset_output = $outputlangs->charset_output;
258
+		$outputlangs->charset_output = 'UTF-8';
259 259
 
260 260
 		// Load translation files required by the page
261 261
 		$outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
@@ -263,28 +263,28 @@  discard block
 block discarded – undo
263 263
 		if ($conf->supplier_proposal->dir_output)
264 264
 		{
265 265
 			// If $object is id instead of object
266
-			if (! is_object($object))
266
+			if (!is_object($object))
267 267
 			{
268 268
 				$id = $object;
269 269
 				$object = new SupplierProposal($this->db);
270
-				$result=$object->fetch($id);
270
+				$result = $object->fetch($id);
271 271
 				if ($result < 0)
272 272
 				{
273
-					dol_print_error($this->db,$object->error);
273
+					dol_print_error($this->db, $object->error);
274 274
 					return -1;
275 275
 				}
276 276
 			}
277 277
 
278 278
 			$dir = $conf->supplier_proposal->dir_output;
279 279
 			$objectref = dol_sanitizeFileName($object->ref);
280
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
281
-			$file = $dir . "/" . $objectref . ".odt";
280
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
281
+			$file = $dir."/".$objectref.".odt";
282 282
 
283
-			if (! file_exists($dir))
283
+			if (!file_exists($dir))
284 284
 			{
285 285
 				if (dol_mkdir($dir) < 0)
286 286
 				{
287
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
287
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
288 288
 					return -1;
289 289
 				}
290 290
 			}
@@ -292,26 +292,26 @@  discard block
 block discarded – undo
292 292
 			if (file_exists($dir))
293 293
 			{
294 294
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
295
-				$newfile=basename($srctemplatepath);
296
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
297
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
298
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
295
+				$newfile = basename($srctemplatepath);
296
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
297
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
298
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
299 299
 
300
-				$newfiletmp=$objectref.'_'.$newfiletmp;
300
+				$newfiletmp = $objectref.'_'.$newfiletmp;
301 301
 
302 302
 				// Get extension (ods or odt)
303
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
304
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
303
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
304
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
305 305
 				{
306
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
307
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
308
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
306
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
307
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
308
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
309 309
 				}
310 310
 				else
311 311
 				{
312
-					$filename=$newfiletmp.'.'.$newfileformat;
312
+					$filename = $newfiletmp.'.'.$newfileformat;
313 313
 				}
314
-				$file=$dir.'/'.$filename;
314
+				$file = $dir.'/'.$filename;
315 315
 				//print "newdir=".$dir;
316 316
 				//print "newfile=".$newfile;
317 317
 				//print "file=".$file;
@@ -321,28 +321,28 @@  discard block
 block discarded – undo
321 321
 
322 322
 
323 323
 				// If BILLING contact defined on invoice, we use it
324
-				$usecontact=false;
325
-				$arrayidcontact=$object->getIdContact('external','BILLING');
324
+				$usecontact = false;
325
+				$arrayidcontact = $object->getIdContact('external', 'BILLING');
326 326
 				if (count($arrayidcontact) > 0)
327 327
 				{
328
-					$usecontact=true;
329
-					$result=$object->fetch_contact($arrayidcontact[0]);
328
+					$usecontact = true;
329
+					$result = $object->fetch_contact($arrayidcontact[0]);
330 330
 				}
331 331
 
332 332
 				// Recipient name
333
-				if (! empty($usecontact))
333
+				if (!empty($usecontact))
334 334
 				{
335 335
 					// On peut utiliser le nom de la societe du contact
336
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
336
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
337 337
 					else $socobject = $object->thirdparty;
338 338
 				}
339 339
 				else
340 340
 				{
341
-					$socobject=$object->thirdparty;
341
+					$socobject = $object->thirdparty;
342 342
 				}
343 343
 
344 344
 				// Make substitution
345
-				$substitutionarray=array(
345
+				$substitutionarray = array(
346 346
 				'__FROM_NAME__' => $this->emetteur->name,
347 347
 				'__FROM_EMAIL__' => $this->emetteur->email,
348 348
 				'__TOTAL_TTC__' => $object->total_ttc,
@@ -351,15 +351,15 @@  discard block
 block discarded – undo
351 351
 				);
352 352
 				complete_substitutions_array($substitutionarray, $langs, $object);
353 353
 				// Call the ODTSubstitution hook
354
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
355
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
354
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
355
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
356 356
 
357 357
 				// Line of free text
358
-				$newfreetext='';
359
-				$paramfreetext='SUPPLIER_PROPOSAL_FREE_TEXT';
360
-				if (! empty($conf->global->$paramfreetext))
358
+				$newfreetext = '';
359
+				$paramfreetext = 'SUPPLIER_PROPOSAL_FREE_TEXT';
360
+				if (!empty($conf->global->$paramfreetext))
361 361
 				{
362
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
362
+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
363 363
 				}
364 364
 
365 365
 				// Open and load template
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 						$srctemplatepath,
370 370
 						array(
371 371
 							'PATH_TO_TMP'	  => $conf->supplier_proposal->dir_temp,
372
-							'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
372
+							'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
373 373
 							'DELIMITER_LEFT'  => '{',
374 374
 							'DELIMITER_RIGHT' => '}'
375 375
 						)
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 				}
378 378
 				catch (Exception $e)
379 379
 				{
380
-					$this->error=$e->getMessage();
380
+					$this->error = $e->getMessage();
381 381
 					dol_syslog($e->getMessage(), LOG_INFO);
382 382
 					return -1;
383 383
 				}
@@ -399,23 +399,23 @@  discard block
 block discarded – undo
399 399
 
400 400
 				// Define substitution array
401 401
 				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
402
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
403
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
404
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
405
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
406
-				$array_other=$this->get_substitutionarray_other($outputlangs);
402
+				$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
403
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
404
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
405
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
406
+				$array_other = $this->get_substitutionarray_other($outputlangs);
407 407
 
408
-				$tmparray = array_merge($substitutionarray,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
408
+				$tmparray = array_merge($substitutionarray, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other);
409 409
 				complete_substitutions_array($tmparray, $outputlangs, $object);
410 410
 
411 411
 				// Call the ODTSubstitution hook
412
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
413
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
412
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
413
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
414 414
 
415
-				foreach($tmparray as $key=>$value)
415
+				foreach ($tmparray as $key=>$value)
416 416
 				{
417 417
 					try {
418
-						if (preg_match('/logo$/',$key)) // Image
418
+						if (preg_match('/logo$/', $key)) // Image
419 419
 						{
420 420
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
421 421
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
426 426
 						}
427 427
 					}
428
-					catch(OdfException $e)
428
+					catch (OdfException $e)
429 429
 					{
430 430
                         dol_syslog($e->getMessage(), LOG_INFO);
431 431
 					}
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 					try {
438 438
 						$listlines = $odfHandler->setSegment('lines');
439 439
 					}
440
-					catch(OdfException $e)
440
+					catch (OdfException $e)
441 441
 					{
442 442
 						// We may arrive here if tags for lines not present into template
443 443
 						$foundtagforlines = 0;
@@ -447,22 +447,22 @@  discard block
 block discarded – undo
447 447
 					{
448 448
 						foreach ($object->lines as $line)
449 449
 						{
450
-							$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
450
+							$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
451 451
 							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
452 452
 							// Call the ODTSubstitutionLine hook
453
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
454
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
455
-							foreach($tmparray as $key => $val)
453
+							$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
454
+							$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
455
+							foreach ($tmparray as $key => $val)
456 456
 							{
457 457
 								try
458 458
 								{
459 459
 									$listlines->setVars($key, $val, true, 'UTF-8');
460 460
 								}
461
-								catch(OdfException $e)
461
+								catch (OdfException $e)
462 462
 								{
463 463
 									dol_syslog($e->getMessage(), LOG_INFO);
464 464
 								}
465
-								catch(SegmentException $e)
465
+								catch (SegmentException $e)
466 466
 								{
467 467
 									dol_syslog($e->getMessage(), LOG_INFO);
468 468
 								}
@@ -472,36 +472,36 @@  discard block
 block discarded – undo
472 472
 						$odfHandler->mergeSegment($listlines);
473 473
 					}
474 474
 				}
475
-				catch(OdfException $e)
475
+				catch (OdfException $e)
476 476
 				{
477
-					$this->error=$e->getMessage();
477
+					$this->error = $e->getMessage();
478 478
 					dol_syslog($this->error, LOG_WARNING);
479 479
 					return -1;
480 480
 				}
481 481
 
482 482
 				// Replace labels translated
483
-				$tmparray=$outputlangs->get_translations_for_substitutions();
484
-				foreach($tmparray as $key=>$value)
483
+				$tmparray = $outputlangs->get_translations_for_substitutions();
484
+				foreach ($tmparray as $key=>$value)
485 485
 				{
486 486
 					try {
487 487
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
488 488
 					}
489
-					catch(OdfException $e)
489
+					catch (OdfException $e)
490 490
 					{
491 491
                         dol_syslog($e->getMessage(), LOG_INFO);
492 492
 					}
493 493
 				}
494 494
 
495 495
 				// Call the beforeODTSave hook
496
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
497
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
496
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
497
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
498 498
 
499 499
 				// Write new file
500 500
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
501 501
 					try {
502 502
 						$odfHandler->exportAsAttachedPDF($file);
503 503
 					} catch (Exception $e) {
504
-						$this->error=$e->getMessage();
504
+						$this->error = $e->getMessage();
505 505
                         dol_syslog($e->getMessage(), LOG_INFO);
506 506
 						return -1;
507 507
 					}
@@ -510,26 +510,26 @@  discard block
 block discarded – undo
510 510
 					try {
511 511
 						$odfHandler->saveToDisk($file);
512 512
 					} catch (Exception $e) {
513
-						$this->error=$e->getMessage();
513
+						$this->error = $e->getMessage();
514 514
                         dol_syslog($e->getMessage(), LOG_INFO);
515 515
 						return -1;
516 516
 					}
517 517
 				}
518
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
519
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
518
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
519
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
520 520
 
521
-				if (! empty($conf->global->MAIN_UMASK))
521
+				if (!empty($conf->global->MAIN_UMASK))
522 522
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
523 523
 
524
-				$odfHandler=null;	// Destroy object
524
+				$odfHandler = null; // Destroy object
525 525
 
526 526
 				$this->result = array('fullpath'=>$file);
527 527
 
528
-				return 1;   // Success
528
+				return 1; // Success
529 529
 			}
530 530
 			else
531 531
 			{
532
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
532
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
533 533
 				return -1;
534 534
 			}
535 535
 		}
Please login to merge, or discard this patch.
Braces   +45 added lines, -39 removed lines patch added patch discarded remove patch
@@ -97,7 +97,10 @@  discard block
 block discarded – undo
97 97
 
98 98
 		// Recupere emetteur
99 99
 		$this->emetteur=$mysoc;
100
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
100
+		if (! $this->emetteur->country_code) {
101
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
102
+		}
103
+		// By default if not defined
101 104
 	}
102 105
 
103 106
 
@@ -141,11 +144,14 @@  discard block
 block discarded – undo
141 144
 			if (! $tmpdir) {
142 145
 				unset($listofdir[$key]); continue;
143 146
 			}
144
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
-			else
147
+			if (! is_dir($tmpdir)) {
148
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
149
+			} else
146 150
 			{
147 151
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
148
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
152
+				if (count($tmpfiles)) {
153
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
154
+				}
149 155
 			}
150 156
 		}
151 157
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -253,7 +259,9 @@  discard block
 block discarded – undo
253 259
 		$hookmanager->initHooks(array('odtgeneration'));
254 260
 		global $action;
255 261
 
256
-		if (! is_object($outputlangs)) $outputlangs=$langs;
262
+		if (! is_object($outputlangs)) {
263
+		    $outputlangs=$langs;
264
+		}
257 265
 		$sav_charset_output=$outputlangs->charset_output;
258 266
 		$outputlangs->charset_output='UTF-8';
259 267
 
@@ -277,7 +285,9 @@  discard block
 block discarded – undo
277 285
 
278 286
 			$dir = $conf->supplier_proposal->dir_output;
279 287
 			$objectref = dol_sanitizeFileName($object->ref);
280
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
288
+			if (! preg_match('/specimen/i',$objectref)) {
289
+			    $dir.= "/" . $objectref;
290
+			}
281 291
 			$file = $dir . "/" . $objectref . ".odt";
282 292
 
283 293
 			if (! file_exists($dir))
@@ -304,10 +314,11 @@  discard block
 block discarded – undo
304 314
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
305 315
 				{
306 316
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
307
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
317
+				    if ($format == '1') {
318
+				        $format='%Y%m%d%H%M%S';
319
+				    }
308 320
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
309
-				}
310
-				else
321
+				} else
311 322
 				{
312 323
 					$filename=$newfiletmp.'.'.$newfileformat;
313 324
 				}
@@ -333,10 +344,12 @@  discard block
 block discarded – undo
333 344
 				if (! empty($usecontact))
334 345
 				{
335 346
 					// On peut utiliser le nom de la societe du contact
336
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
337
-					else $socobject = $object->thirdparty;
338
-				}
339
-				else
347
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
348
+					    $socobject = $object->contact;
349
+					} else {
350
+					    $socobject = $object->thirdparty;
351
+					}
352
+				} else
340 353
 				{
341 354
 					$socobject=$object->thirdparty;
342 355
 				}
@@ -374,8 +387,7 @@  discard block
 block discarded – undo
374 387
 							'DELIMITER_RIGHT' => '}'
375 388
 						)
376 389
 					);
377
-				}
378
-				catch (Exception $e)
390
+				} catch (Exception $e)
379 391
 				{
380 392
 					$this->error=$e->getMessage();
381 393
 					dol_syslog($e->getMessage(), LOG_INFO);
@@ -391,8 +403,7 @@  discard block
 block discarded – undo
391 403
 				// Make substitutions into odt of freetext
392 404
 				try {
393 405
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
394
-				}
395
-				catch (OdfException $e)
406
+				} catch (OdfException $e)
396 407
 				{
397 408
 					dol_syslog($e->getMessage(), LOG_INFO);
398 409
 				}
@@ -415,17 +426,18 @@  discard block
 block discarded – undo
415 426
 				foreach($tmparray as $key=>$value)
416 427
 				{
417 428
 					try {
418
-						if (preg_match('/logo$/',$key)) // Image
429
+						if (preg_match('/logo$/',$key)) {
430
+						    // Image
419 431
 						{
420 432
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
421
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
422
-						}
423
-						else    // Text
433
+						} else {
434
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
435
+							}
436
+						} else    // Text
424 437
 						{
425 438
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
426 439
 						}
427
-					}
428
-					catch(OdfException $e)
440
+					} catch(OdfException $e)
429 441
 					{
430 442
                         dol_syslog($e->getMessage(), LOG_INFO);
431 443
 					}
@@ -436,8 +448,7 @@  discard block
 block discarded – undo
436 448
 					$foundtagforlines = 1;
437 449
 					try {
438 450
 						$listlines = $odfHandler->setSegment('lines');
439
-					}
440
-					catch(OdfException $e)
451
+					} catch(OdfException $e)
441 452
 					{
442 453
 						// We may arrive here if tags for lines not present into template
443 454
 						$foundtagforlines = 0;
@@ -457,12 +468,10 @@  discard block
 block discarded – undo
457 468
 								try
458 469
 								{
459 470
 									$listlines->setVars($key, $val, true, 'UTF-8');
460
-								}
461
-								catch(OdfException $e)
471
+								} catch(OdfException $e)
462 472
 								{
463 473
 									dol_syslog($e->getMessage(), LOG_INFO);
464
-								}
465
-								catch(SegmentException $e)
474
+								} catch(SegmentException $e)
466 475
 								{
467 476
 									dol_syslog($e->getMessage(), LOG_INFO);
468 477
 								}
@@ -471,8 +480,7 @@  discard block
 block discarded – undo
471 480
 						}
472 481
 						$odfHandler->mergeSegment($listlines);
473 482
 					}
474
-				}
475
-				catch(OdfException $e)
483
+				} catch(OdfException $e)
476 484
 				{
477 485
 					$this->error=$e->getMessage();
478 486
 					dol_syslog($this->error, LOG_WARNING);
@@ -485,8 +493,7 @@  discard block
 block discarded – undo
485 493
 				{
486 494
 					try {
487 495
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
488
-					}
489
-					catch(OdfException $e)
496
+					} catch(OdfException $e)
490 497
 					{
491 498
                         dol_syslog($e->getMessage(), LOG_INFO);
492 499
 					}
@@ -505,8 +512,7 @@  discard block
 block discarded – undo
505 512
                         dol_syslog($e->getMessage(), LOG_INFO);
506 513
 						return -1;
507 514
 					}
508
-				}
509
-				else {
515
+				} else {
510 516
 					try {
511 517
 						$odfHandler->saveToDisk($file);
512 518
 					} catch (Exception $e) {
@@ -518,16 +524,16 @@  discard block
 block discarded – undo
518 524
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
519 525
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
520 526
 
521
-				if (! empty($conf->global->MAIN_UMASK))
522
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
527
+				if (! empty($conf->global->MAIN_UMASK)) {
528
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
529
+				}
523 530
 
524 531
 				$odfHandler=null;	// Destroy object
525 532
 
526 533
 				$this->result = array('fullpath'=>$file);
527 534
 
528 535
 				return 1;   // Success
529
-			}
530
-			else
536
+			} else
531 537
 			{
532 538
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
533 539
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php 3 patches
Indentation   +1228 added lines, -1228 removed lines patch added patch discarded remove patch
@@ -38,160 +38,160 @@  discard block
 block discarded – undo
38 38
  */
39 39
 class pdf_aurore extends ModelePDFSupplierProposal
40 40
 {
41
-	/**
41
+    /**
42 42
      * @var DoliDb Database handler
43 43
      */
44 44
     public $db;
45 45
 
46
-	/**
46
+    /**
47 47
      * @var string model name
48 48
      */
49 49
     public $name;
50 50
 
51
-	/**
51
+    /**
52 52
      * @var string model description (short text)
53 53
      */
54 54
     public $description;
55 55
 
56
-	/**
56
+    /**
57 57
      * @var string document type
58 58
      */
59 59
     public $type;
60 60
 
61
-	/**
61
+    /**
62 62
      * @var array() Minimum version of PHP required by module.
63
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
63
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
64 64
      */
65
-	public $phpmin = array(5, 4);
65
+    public $phpmin = array(5, 4);
66 66
 
67
-	/**
67
+    /**
68 68
      * Dolibarr version of the loaded document
69 69
      * @public string
70 70
      */
71
-	public $version = 'dolibarr';
71
+    public $version = 'dolibarr';
72 72
 
73
-	/**
73
+    /**
74 74
      * @var int page_largeur
75 75
      */
76 76
     public $page_largeur;
77 77
 
78
-	/**
78
+    /**
79 79
      * @var int page_hauteur
80 80
      */
81 81
     public $page_hauteur;
82 82
 
83
-	/**
83
+    /**
84 84
      * @var array format
85 85
      */
86 86
     public $format;
87 87
 
88
-	/**
88
+    /**
89 89
      * @var int marge_gauche
90 90
      */
91
-	public $marge_gauche;
91
+    public $marge_gauche;
92 92
 
93
-	/**
93
+    /**
94 94
      * @var int marge_droite
95 95
      */
96
-	public $marge_droite;
96
+    public $marge_droite;
97 97
 
98
-	/**
98
+    /**
99 99
      * @var int marge_haute
100 100
      */
101
-	public $marge_haute;
101
+    public $marge_haute;
102 102
 
103
-	/**
103
+    /**
104 104
      * @var int marge_basse
105 105
      */
106
-	public $marge_basse;
107
-
108
-	/**
109
-	* Issuer
110
-	* @var Societe
111
-	*/
112
-	public $emetteur;
113
-
114
-
115
-	/**
116
-	 *	Constructor
117
-	 *
118
-	 *  @param		DoliDB		$db      Database handler
119
-	 */
120
-	public function __construct($db)
121
-	{
122
-		global $conf, $langs, $mysoc;
123
-
124
-		// Translations
125
-		$langs->loadLangs(array("main", "bills"));
126
-
127
-		$this->db = $db;
128
-		$this->name = "aurore";
129
-		$this->description = $langs->trans('DocModelAuroreDescription');
130
-
131
-		// Dimension page pour format A4
132
-		$this->type = 'pdf';
133
-		$formatarray=pdf_getFormat();
134
-		$this->page_largeur = $formatarray['width'];
135
-		$this->page_hauteur = $formatarray['height'];
136
-		$this->format = array($this->page_largeur,$this->page_hauteur);
137
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
138
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
139
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
140
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
141
-
142
-		$this->option_logo = 1;                    // Affiche logo
143
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
144
-		$this->option_modereg = 1;                 // Affiche mode reglement
145
-		$this->option_condreg = 1;                 // Affiche conditions reglement
146
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
147
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
148
-		$this->option_escompte = 1;                // Affiche si il y a eu escompte
149
-		$this->option_credit_note = 1;             // Support credit notes
150
-		$this->option_freetext = 1;				   // Support add of a personalised text
151
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
152
-
153
-		$this->franchise=!$mysoc->tva_assuj;
154
-
155
-		// Get source company
156
-		$this->emetteur=$mysoc;
157
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
158
-
159
-		// Define position of columns
160
-		$this->posxdesc=$this->marge_gauche+1;
161
-		$this->posxdiscount=162;
162
-		$this->postotalht=174;
163
-
164
-		if ($conf->global->PRODUCT_USE_UNITS)
165
-		{
166
-		    $this->posxtva=101;
167
-		    $this->posxup=118;
168
-		    $this->posxqty=135;
169
-		    $this->posxunit=151;
170
-		} else {
171
-		    $this->posxtva=102;
172
-		    $this->posxup=126;
173
-		    $this->posxqty=145;
174
-		}
175
-
176
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
177
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
178
-		if ($this->page_largeur < 210) // To work with US executive format
179
-		{
180
-			$this->posxpicture-=20;
181
-			$this->posxtva-=20;
182
-			$this->posxup-=20;
183
-			$this->posxqty-=20;
184
-			$this->posxunit-=20;
185
-			$this->posxdiscount-=20;
186
-			$this->postotalht-=20;
187
-		}
188
-
189
-		$this->tva=array();
190
-		$this->localtax1=array();
191
-		$this->localtax2=array();
192
-		$this->atleastoneratenotnull=0;
193
-		$this->atleastonediscount=0;
194
-	}
106
+    public $marge_basse;
107
+
108
+    /**
109
+     * Issuer
110
+     * @var Societe
111
+     */
112
+    public $emetteur;
113
+
114
+
115
+    /**
116
+     *	Constructor
117
+     *
118
+     *  @param		DoliDB		$db      Database handler
119
+     */
120
+    public function __construct($db)
121
+    {
122
+        global $conf, $langs, $mysoc;
123
+
124
+        // Translations
125
+        $langs->loadLangs(array("main", "bills"));
126
+
127
+        $this->db = $db;
128
+        $this->name = "aurore";
129
+        $this->description = $langs->trans('DocModelAuroreDescription');
130
+
131
+        // Dimension page pour format A4
132
+        $this->type = 'pdf';
133
+        $formatarray=pdf_getFormat();
134
+        $this->page_largeur = $formatarray['width'];
135
+        $this->page_hauteur = $formatarray['height'];
136
+        $this->format = array($this->page_largeur,$this->page_hauteur);
137
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
138
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
139
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
140
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
141
+
142
+        $this->option_logo = 1;                    // Affiche logo
143
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
144
+        $this->option_modereg = 1;                 // Affiche mode reglement
145
+        $this->option_condreg = 1;                 // Affiche conditions reglement
146
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
147
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
148
+        $this->option_escompte = 1;                // Affiche si il y a eu escompte
149
+        $this->option_credit_note = 1;             // Support credit notes
150
+        $this->option_freetext = 1;				   // Support add of a personalised text
151
+        $this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
152
+
153
+        $this->franchise=!$mysoc->tva_assuj;
154
+
155
+        // Get source company
156
+        $this->emetteur=$mysoc;
157
+        if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
158
+
159
+        // Define position of columns
160
+        $this->posxdesc=$this->marge_gauche+1;
161
+        $this->posxdiscount=162;
162
+        $this->postotalht=174;
163
+
164
+        if ($conf->global->PRODUCT_USE_UNITS)
165
+        {
166
+            $this->posxtva=101;
167
+            $this->posxup=118;
168
+            $this->posxqty=135;
169
+            $this->posxunit=151;
170
+        } else {
171
+            $this->posxtva=102;
172
+            $this->posxup=126;
173
+            $this->posxqty=145;
174
+        }
175
+
176
+        if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
177
+        $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
178
+        if ($this->page_largeur < 210) // To work with US executive format
179
+        {
180
+            $this->posxpicture-=20;
181
+            $this->posxtva-=20;
182
+            $this->posxup-=20;
183
+            $this->posxqty-=20;
184
+            $this->posxunit-=20;
185
+            $this->posxdiscount-=20;
186
+            $this->postotalht-=20;
187
+        }
188
+
189
+        $this->tva=array();
190
+        $this->localtax1=array();
191
+        $this->localtax2=array();
192
+        $this->atleastoneratenotnull=0;
193
+        $this->atleastonediscount=0;
194
+    }
195 195
 
196 196
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
197 197
     /**
@@ -204,105 +204,105 @@  discard block
 block discarded – undo
204 204
      *  @param		int			$hidedesc			Do not show desc
205 205
      *  @param		int			$hideref			Do not show ref
206 206
      *  @return     int             				1=OK, 0=KO
207
-	 */
208
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
209
-	{
207
+     */
208
+    function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
209
+    {
210 210
         // phpcs:enable
211
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
211
+        global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
212 212
 
213
-		if (! is_object($outputlangs)) $outputlangs=$langs;
214
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
215
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
213
+        if (! is_object($outputlangs)) $outputlangs=$langs;
214
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
215
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
216 216
 
217
-		// Load traductions files requiredby by page
218
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal"));
217
+        // Load traductions files requiredby by page
218
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal"));
219 219
 
220
-		$nblignes = count($object->lines);
220
+        $nblignes = count($object->lines);
221 221
 
222
-		// Loop on each lines to detect if there is at least one image to show
223
-		$realpatharray=array();
224
-		if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
225
-		{
226
-			for ($i = 0 ; $i < $nblignes ; $i++)
227
-			{
228
-				if (empty($object->lines[$i]->fk_product)) continue;
229
-
230
-				$objphoto = new Product($this->db);
231
-				$objphoto->fetch($object->lines[$i]->fk_product);
222
+        // Loop on each lines to detect if there is at least one image to show
223
+        $realpatharray=array();
224
+        if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
225
+        {
226
+            for ($i = 0 ; $i < $nblignes ; $i++)
227
+            {
228
+                if (empty($object->lines[$i]->fk_product)) continue;
232 229
 
233
-				if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
234
-				{
235
-					$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
236
-					$dir = $conf->product->dir_output.'/'.$pdir;
237
-				}
238
-				else
239
-				{
240
-					$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
241
-					$dir = $conf->product->dir_output.'/'.$pdir;
242
-				}
243
-
244
-				$realpath='';
245
-				foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
246
-				{
247
-					$filename=$obj['photo'];
248
-					//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
249
-					$realpath = $dir.$filename;
250
-					break;
251
-				}
252
-
253
-				if ($realpath) $realpatharray[$i]=$realpath;
254
-			}
255
-		}
256
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
257
-
258
-		if ($conf->supplier_proposal->dir_output)
259
-		{
260
-			$object->fetch_thirdparty();
230
+                $objphoto = new Product($this->db);
231
+                $objphoto->fetch($object->lines[$i]->fk_product);
261 232
 
262
-			// $deja_regle = 0;
233
+                if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
234
+                {
235
+                    $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
236
+                    $dir = $conf->product->dir_output.'/'.$pdir;
237
+                }
238
+                else
239
+                {
240
+                    $pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
241
+                    $dir = $conf->product->dir_output.'/'.$pdir;
242
+                }
263 243
 
264
-			// Definition of $dir and $file
265
-			if ($object->specimen)
266
-			{
267
-				$dir = $conf->supplier_proposal->dir_output;
268
-				$file = $dir . "/SPECIMEN.pdf";
269
-			}
270
-			else
271
-			{
272
-				$objectref = dol_sanitizeFileName($object->ref);
273
-				$dir = $conf->supplier_proposal->dir_output . "/" . $objectref;
274
-				$file = $dir . "/" . $objectref . ".pdf";
275
-			}
244
+                $realpath='';
245
+                foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
246
+                {
247
+                    $filename=$obj['photo'];
248
+                    //if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
249
+                    $realpath = $dir.$filename;
250
+                    break;
251
+                }
276 252
 
277
-			if (! file_exists($dir))
278
-			{
279
-				if (dol_mkdir($dir) < 0)
280
-				{
281
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
282
-					return 0;
283
-				}
284
-			}
253
+                if ($realpath) $realpatharray[$i]=$realpath;
254
+            }
255
+        }
256
+        if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
257
+
258
+        if ($conf->supplier_proposal->dir_output)
259
+        {
260
+            $object->fetch_thirdparty();
261
+
262
+            // $deja_regle = 0;
263
+
264
+            // Definition of $dir and $file
265
+            if ($object->specimen)
266
+            {
267
+                $dir = $conf->supplier_proposal->dir_output;
268
+                $file = $dir . "/SPECIMEN.pdf";
269
+            }
270
+            else
271
+            {
272
+                $objectref = dol_sanitizeFileName($object->ref);
273
+                $dir = $conf->supplier_proposal->dir_output . "/" . $objectref;
274
+                $file = $dir . "/" . $objectref . ".pdf";
275
+            }
276
+
277
+            if (! file_exists($dir))
278
+            {
279
+                if (dol_mkdir($dir) < 0)
280
+                {
281
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
282
+                    return 0;
283
+                }
284
+            }
285 285
 
286
-			if (file_exists($dir))
287
-			{
288
-				// Add pdfgeneration hook
289
-				if (! is_object($hookmanager))
290
-				{
291
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
292
-					$hookmanager=new HookManager($this->db);
293
-				}
294
-				$hookmanager->initHooks(array('pdfgeneration'));
295
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
296
-				global $action;
297
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
286
+            if (file_exists($dir))
287
+            {
288
+                // Add pdfgeneration hook
289
+                if (! is_object($hookmanager))
290
+                {
291
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
292
+                    $hookmanager=new HookManager($this->db);
293
+                }
294
+                $hookmanager->initHooks(array('pdfgeneration'));
295
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
296
+                global $action;
297
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
298 298
 
299
-				// Create pdf instance
299
+                // Create pdf instance
300 300
                 $pdf=pdf_getInstance($this->format);
301 301
                 $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
302 302
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
303
-		        $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
304
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
305
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
303
+                $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
304
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
305
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
306 306
                 $pdf->SetAutoPageBreak(1,0);
307 307
 
308 308
                 if (class_exists('TCPDF'))
@@ -318,189 +318,189 @@  discard block
 block discarded – undo
318 318
                     $tplidx = $pdf->importPage(1);
319 319
                 }
320 320
 
321
-				$pdf->Open();
322
-				$pagenb=0;
323
-				$pdf->SetDrawColor(128,128,128);
321
+                $pdf->Open();
322
+                $pagenb=0;
323
+                $pdf->SetDrawColor(128,128,128);
324 324
 
325
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
326
-				$pdf->SetSubject($outputlangs->transnoentities("CommercialAsk"));
327
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
328
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
329
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
330
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
325
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
326
+                $pdf->SetSubject($outputlangs->transnoentities("CommercialAsk"));
327
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
328
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
329
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
330
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
331 331
 
332
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
332
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
333 333
 
334
-				// Positionne $this->atleastonediscount si on a au moins une remise
335
-				for ($i = 0 ; $i < $nblignes ; $i++)
336
-				{
337
-					if ($object->lines[$i]->remise_percent)
338
-					{
339
-						$this->atleastonediscount++;
340
-					}
341
-				}
342
-				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
343
-				{
344
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
345
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
346
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
347
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
348
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
349
-					//$this->postotalht;
350
-				}
334
+                // Positionne $this->atleastonediscount si on a au moins une remise
335
+                for ($i = 0 ; $i < $nblignes ; $i++)
336
+                {
337
+                    if ($object->lines[$i]->remise_percent)
338
+                    {
339
+                        $this->atleastonediscount++;
340
+                    }
341
+                }
342
+                if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
343
+                {
344
+                    $this->posxpicture+=($this->postotalht - $this->posxdiscount);
345
+                    $this->posxtva+=($this->postotalht - $this->posxdiscount);
346
+                    $this->posxup+=($this->postotalht - $this->posxdiscount);
347
+                    $this->posxqty+=($this->postotalht - $this->posxdiscount);
348
+                    $this->posxdiscount+=($this->postotalht - $this->posxdiscount);
349
+                    //$this->postotalht;
350
+                }
351 351
 
352
-				// New page
353
-				$pdf->AddPage();
354
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
355
-				$pagenb++;
356
-				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
357
-				$pdf->SetFont('','', $default_font_size - 1);
358
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
359
-				$pdf->SetTextColor(0,0,0);
360
-
361
-				$tab_top = 90+$top_shift;
362
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
363
-
364
-				// Affiche notes
365
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
366
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
367
-				{
368
-					// Get first sale rep
369
-					if (is_object($object->thirdparty))
370
-					{
371
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
372
-						$salerepobj=new User($this->db);
373
-						$salerepobj->fetch($salereparray[0]['id']);
374
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
375
-					}
376
-				}
377
-				if ($notetoshow)
378
-				{
379
-					$tab_top -= 2;
352
+                // New page
353
+                $pdf->AddPage();
354
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
355
+                $pagenb++;
356
+                $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
357
+                $pdf->SetFont('','', $default_font_size - 1);
358
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
359
+                $pdf->SetTextColor(0,0,0);
360
+
361
+                $tab_top = 90+$top_shift;
362
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
363
+
364
+                // Affiche notes
365
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
366
+                if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
367
+                {
368
+                    // Get first sale rep
369
+                    if (is_object($object->thirdparty))
370
+                    {
371
+                        $salereparray=$object->thirdparty->getSalesRepresentatives($user);
372
+                        $salerepobj=new User($this->db);
373
+                        $salerepobj->fetch($salereparray[0]['id']);
374
+                        if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
375
+                    }
376
+                }
377
+                if ($notetoshow)
378
+                {
379
+                    $tab_top -= 2;
380 380
 
381 381
                     $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
382
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
383
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
384
-
385
-					$pdf->SetFont('','', $default_font_size - 1);
386
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
387
-					$nexY = $pdf->GetY();
388
-					$height_note=$nexY-$tab_top;
389
-
390
-					// Rect prend une longueur en 3eme param
391
-					$pdf->SetDrawColor(192,192,192);
392
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
393
-
394
-					$tab_top = $nexY+6;
395
-				}
396
-
397
-				$iniY = $tab_top + 7;
398
-				$curY = $tab_top + 7;
399
-				$nexY = $tab_top + 7;
400
-
401
-				// Loop on each lines
402
-				for ($i = 0 ; $i < $nblignes ; $i++)
403
-				{
404
-					$curY = $nexY;
405
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
406
-					$pdf->SetTextColor(0,0,0);
407
-
408
-					// Define size of image if we need it
409
-					$imglinesize=array();
410
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
411
-
412
-					$pdf->setTopMargin($tab_top_newpage);
413
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
414
-					$pageposbefore=$pdf->getPage();
415
-
416
-					$showpricebeforepagebreak=1;
417
-					$posYAfterImage=0;
418
-					$posYAfterDescription=0;
419
-
420
-					// We start with Photo of product line
421
-					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
422
-					{
423
-						$pdf->AddPage('','',true);
424
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
425
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
426
-						$pdf->setPage($pageposbefore+1);
427
-
428
-						$curY = $tab_top_newpage;
429
-						$showpricebeforepagebreak=0;
430
-					}
431
-
432
-					if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
433
-					{
434
-						$curX = $this->posxpicture-1;
435
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
436
-						// $pdf->Image does not increase value return by getY, so we save it manually
437
-						$posYAfterImage=$curY+$imglinesize['height'];
438
-					}
382
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
383
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
439 384
 
440
-					// Description of product line
441
-					$curX = $this->posxdesc-1;
385
+                    $pdf->SetFont('','', $default_font_size - 1);
386
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
387
+                    $nexY = $pdf->GetY();
388
+                    $height_note=$nexY-$tab_top;
442 389
 
443
-					$pdf->startTransaction();
444
-					if ($posYAfterImage > 0)
445
-					{
446
-						$descWidth = $this->posxpicture-$curX;
447
-					}
448
-					else
449
-					{
450
-						$descWidth = $this->posxtva-$curX;
451
-					}
452
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
453
-
454
-					$pageposafter=$pdf->getPage();
455
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
456
-					{
457
-						$pdf->rollbackTransaction(true);
458
-						$pageposafter=$pageposbefore;
459
-						//print $pageposafter.'-'.$pageposbefore;exit;
460
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
461
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc);
462
-
463
-						$pageposafter=$pdf->getPage();
464
-						$posyafter=$pdf->GetY();
465
-						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
466
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
467
-						{
468
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
469
-							{
470
-								$pdf->AddPage('','',true);
471
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
472
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
473
-								$pdf->setPage($pageposafter+1);
474
-							}
475
-						}
476
-						else
477
-						{
478
-							// We found a page break
479
-							$showpricebeforepagebreak=0;
480
-						}
481
-					}
482
-					else	// No pagebreak
483
-					{
484
-						$pdf->commitTransaction();
485
-					}
486
-					$posYAfterDescription=$pdf->GetY();
487
-
488
-					$nexY = $pdf->GetY();
489
-					$pageposafter=$pdf->getPage();
390
+                    // Rect prend une longueur en 3eme param
391
+                    $pdf->SetDrawColor(192,192,192);
392
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
490 393
 
491
-					$pdf->setPage($pageposbefore);
492
-					$pdf->setTopMargin($this->marge_haute);
493
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
494
-
495
-					// We suppose that a too long description or photo were moved completely on next page
496
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
497
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
498
-					}
394
+                    $tab_top = $nexY+6;
395
+                }
499 396
 
500
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
397
+                $iniY = $tab_top + 7;
398
+                $curY = $tab_top + 7;
399
+                $nexY = $tab_top + 7;
501 400
 
502
-					// VAT Rate
503
-					/*
401
+                // Loop on each lines
402
+                for ($i = 0 ; $i < $nblignes ; $i++)
403
+                {
404
+                    $curY = $nexY;
405
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
406
+                    $pdf->SetTextColor(0,0,0);
407
+
408
+                    // Define size of image if we need it
409
+                    $imglinesize=array();
410
+                    if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
411
+
412
+                    $pdf->setTopMargin($tab_top_newpage);
413
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
414
+                    $pageposbefore=$pdf->getPage();
415
+
416
+                    $showpricebeforepagebreak=1;
417
+                    $posYAfterImage=0;
418
+                    $posYAfterDescription=0;
419
+
420
+                    // We start with Photo of product line
421
+                    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
422
+                    {
423
+                        $pdf->AddPage('','',true);
424
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
425
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
426
+                        $pdf->setPage($pageposbefore+1);
427
+
428
+                        $curY = $tab_top_newpage;
429
+                        $showpricebeforepagebreak=0;
430
+                    }
431
+
432
+                    if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
433
+                    {
434
+                        $curX = $this->posxpicture-1;
435
+                        $pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
436
+                        // $pdf->Image does not increase value return by getY, so we save it manually
437
+                        $posYAfterImage=$curY+$imglinesize['height'];
438
+                    }
439
+
440
+                    // Description of product line
441
+                    $curX = $this->posxdesc-1;
442
+
443
+                    $pdf->startTransaction();
444
+                    if ($posYAfterImage > 0)
445
+                    {
446
+                        $descWidth = $this->posxpicture-$curX;
447
+                    }
448
+                    else
449
+                    {
450
+                        $descWidth = $this->posxtva-$curX;
451
+                    }
452
+                    pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
453
+
454
+                    $pageposafter=$pdf->getPage();
455
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
456
+                    {
457
+                        $pdf->rollbackTransaction(true);
458
+                        $pageposafter=$pageposbefore;
459
+                        //print $pageposafter.'-'.$pageposbefore;exit;
460
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
461
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc);
462
+
463
+                        $pageposafter=$pdf->getPage();
464
+                        $posyafter=$pdf->GetY();
465
+                        //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
466
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
467
+                        {
468
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
469
+                            {
470
+                                $pdf->AddPage('','',true);
471
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
472
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
473
+                                $pdf->setPage($pageposafter+1);
474
+                            }
475
+                        }
476
+                        else
477
+                        {
478
+                            // We found a page break
479
+                            $showpricebeforepagebreak=0;
480
+                        }
481
+                    }
482
+                    else	// No pagebreak
483
+                    {
484
+                        $pdf->commitTransaction();
485
+                    }
486
+                    $posYAfterDescription=$pdf->GetY();
487
+
488
+                    $nexY = $pdf->GetY();
489
+                    $pageposafter=$pdf->getPage();
490
+
491
+                    $pdf->setPage($pageposbefore);
492
+                    $pdf->setTopMargin($this->marge_haute);
493
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
494
+
495
+                    // We suppose that a too long description or photo were moved completely on next page
496
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
497
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
498
+                    }
499
+
500
+                    $pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
501
+
502
+                    // VAT Rate
503
+                    /*
504 504
 					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
505 505
 					{
506 506
 						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
@@ -515,29 +515,29 @@  discard block
 block discarded – undo
515 515
 						$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
516 516
                     */
517 517
 
518
-					// Quantity
519
-					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
520
-					$pdf->SetXY($this->posxqty, $curY);
521
-					// Enough for 6 chars
522
-					if($conf->global->PRODUCT_USE_UNITS)
523
-					{
524
-					    $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 3, $qty, 0, 'R');
525
-					}
526
-					else
527
-					{
528
-					    $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R');
529
-					}
530
-
531
-					// Unit
532
-					if($conf->global->PRODUCT_USE_UNITS)
533
-					{
534
-					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
535
-					    $pdf->SetXY($this->posxunit, $curY);
536
-					    $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
537
-					}
538
-
539
-					// Discount on line
540
-					/*
518
+                    // Quantity
519
+                    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
520
+                    $pdf->SetXY($this->posxqty, $curY);
521
+                    // Enough for 6 chars
522
+                    if($conf->global->PRODUCT_USE_UNITS)
523
+                    {
524
+                        $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 3, $qty, 0, 'R');
525
+                    }
526
+                    else
527
+                    {
528
+                        $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R');
529
+                    }
530
+
531
+                    // Unit
532
+                    if($conf->global->PRODUCT_USE_UNITS)
533
+                    {
534
+                        $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
535
+                        $pdf->SetXY($this->posxunit, $curY);
536
+                        $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
537
+                    }
538
+
539
+                    // Discount on line
540
+                    /*
541 541
 					if ($object->lines[$i]->remise_percent)
542 542
 					{
543 543
 						$pdf->SetXY($this->posxdiscount-2, $curY);
@@ -552,217 +552,217 @@  discard block
 block discarded – undo
552 552
 						$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
553 553
                     */
554 554
 
555
-					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
556
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
557
-					else $tvaligne=$object->lines[$i]->total_tva;
558
-
559
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
560
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
561
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
562
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
563
-					$localtax1_type=$object->lines[$i]->localtax1_type;
564
-					$localtax2_type=$object->lines[$i]->localtax2_type;
565
-
566
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
567
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
568
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
569
-
570
-					$vatrate=(string) $object->lines[$i]->tva_tx;
571
-
572
-					// Retrieve type from database for backward compatibility with old records
573
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
574
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
575
-					{
576
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
577
-						$localtax1_type = $localtaxtmp_array[0];
578
-						$localtax2_type = $localtaxtmp_array[2];
579
-					}
580
-
581
-				    // retrieve global local tax
582
-					if ($localtax1_type && $localtax1ligne != 0)
583
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
584
-					if ($localtax2_type && $localtax2ligne != 0)
585
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
586
-
587
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
588
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
589
-					$this->tva[$vatrate] += $tvaligne;
590
-
591
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
592
-
593
-					// Add line
594
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
595
-					{
596
-						$pdf->setPage($pageposafter);
597
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
598
-						//$pdf->SetDrawColor(190,190,200);
599
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
600
-						$pdf->SetLineStyle(array('dash'=>0));
601
-					}
602
-
603
-					$nexY+=2;    // Passe espace entre les lignes
604
-
605
-					// Detect if some page were added automatically and output _tableau for past pages
606
-					while ($pagenb < $pageposafter)
607
-					{
608
-						$pdf->setPage($pagenb);
609
-						if ($pagenb == 1)
610
-						{
611
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
612
-						}
613
-						else
614
-						{
615
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
616
-						}
617
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
618
-						$pagenb++;
619
-						$pdf->setPage($pagenb);
620
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
621
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
622
-					}
623
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
624
-					{
625
-						if ($pagenb == 1)
626
-						{
627
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
628
-						}
629
-						else
630
-						{
631
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
632
-						}
633
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
634
-						// New page
635
-						$pdf->AddPage();
636
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
637
-						$pagenb++;
638
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
639
-					}
640
-				}
555
+                    // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
556
+                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
557
+                    else $tvaligne=$object->lines[$i]->total_tva;
558
+
559
+                    $localtax1ligne=$object->lines[$i]->total_localtax1;
560
+                    $localtax2ligne=$object->lines[$i]->total_localtax2;
561
+                    $localtax1_rate=$object->lines[$i]->localtax1_tx;
562
+                    $localtax2_rate=$object->lines[$i]->localtax2_tx;
563
+                    $localtax1_type=$object->lines[$i]->localtax1_type;
564
+                    $localtax2_type=$object->lines[$i]->localtax2_type;
565
+
566
+                    if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
567
+                    if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
568
+                    if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
569
+
570
+                    $vatrate=(string) $object->lines[$i]->tva_tx;
571
+
572
+                    // Retrieve type from database for backward compatibility with old records
573
+                    if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
574
+                    && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
575
+                    {
576
+                        $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
577
+                        $localtax1_type = $localtaxtmp_array[0];
578
+                        $localtax2_type = $localtaxtmp_array[2];
579
+                    }
580
+
581
+                    // retrieve global local tax
582
+                    if ($localtax1_type && $localtax1ligne != 0)
583
+                        $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
584
+                    if ($localtax2_type && $localtax2ligne != 0)
585
+                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
586
+
587
+                    if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
588
+                    if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
589
+                    $this->tva[$vatrate] += $tvaligne;
590
+
591
+                    if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
592
+
593
+                    // Add line
594
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
595
+                    {
596
+                        $pdf->setPage($pageposafter);
597
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
598
+                        //$pdf->SetDrawColor(190,190,200);
599
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
600
+                        $pdf->SetLineStyle(array('dash'=>0));
601
+                    }
602
+
603
+                    $nexY+=2;    // Passe espace entre les lignes
604
+
605
+                    // Detect if some page were added automatically and output _tableau for past pages
606
+                    while ($pagenb < $pageposafter)
607
+                    {
608
+                        $pdf->setPage($pagenb);
609
+                        if ($pagenb == 1)
610
+                        {
611
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
612
+                        }
613
+                        else
614
+                        {
615
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
616
+                        }
617
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
618
+                        $pagenb++;
619
+                        $pdf->setPage($pagenb);
620
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
621
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
622
+                    }
623
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
624
+                    {
625
+                        if ($pagenb == 1)
626
+                        {
627
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
628
+                        }
629
+                        else
630
+                        {
631
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
632
+                        }
633
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
634
+                        // New page
635
+                        $pdf->AddPage();
636
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
637
+                        $pagenb++;
638
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
639
+                    }
640
+                }
641 641
 
642
-				// Show square
643
-				if ($pagenb == 1)
644
-				{
645
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
646
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
647
-				}
648
-				else
649
-				{
650
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
651
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
652
-				}
642
+                // Show square
643
+                if ($pagenb == 1)
644
+                {
645
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
646
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
647
+                }
648
+                else
649
+                {
650
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
651
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
652
+                }
653 653
 
654
-				// Affiche zone infos
655
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
654
+                // Affiche zone infos
655
+                $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
656 656
 
657
-				// Affiche zone totaux
658
-				//$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
657
+                // Affiche zone totaux
658
+                //$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
659 659
 
660
-				// Affiche zone versements
661
-				/*
660
+                // Affiche zone versements
661
+                /*
662 662
 				if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
663 663
 				{
664 664
 					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
665 665
 				}
666 666
 				*/
667 667
 
668
-				// Pied de page
669
-				$this->_pagefoot($pdf,$object,$outputlangs);
670
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
668
+                // Pied de page
669
+                $this->_pagefoot($pdf,$object,$outputlangs);
670
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
671 671
 
672
-				$pdf->Close();
672
+                $pdf->Close();
673 673
 
674
-				$pdf->Output($file,'F');
674
+                $pdf->Output($file,'F');
675 675
 
676
-				//Add pdfgeneration hook
677
-				$hookmanager->initHooks(array('pdfgeneration'));
678
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
679
-				global $action;
680
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
676
+                //Add pdfgeneration hook
677
+                $hookmanager->initHooks(array('pdfgeneration'));
678
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
679
+                global $action;
680
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
681 681
 
682
-				if (! empty($conf->global->MAIN_UMASK))
683
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
682
+                if (! empty($conf->global->MAIN_UMASK))
683
+                @chmod($file, octdec($conf->global->MAIN_UMASK));
684 684
 
685
-				$this->result = array('fullpath'=>$file);
685
+                $this->result = array('fullpath'=>$file);
686 686
 
687
-				return 1;   // Pas d'erreur
688
-			}
689
-			else
690
-			{
691
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
692
-				return 0;
693
-			}
694
-		}
695
-		else
696
-		{
697
-			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_PROPOSAL_OUTPUTDIR");
698
-			return 0;
699
-		}
700
-	}
687
+                return 1;   // Pas d'erreur
688
+            }
689
+            else
690
+            {
691
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
692
+                return 0;
693
+            }
694
+        }
695
+        else
696
+        {
697
+            $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_PROPOSAL_OUTPUTDIR");
698
+            return 0;
699
+        }
700
+    }
701 701
 
702 702
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
703
-	/**
704
-	 *  Show payments table
705
-	 *
703
+    /**
704
+     *  Show payments table
705
+     *
706 706
      *  @param	PDF			$pdf           Object PDF
707 707
      *  @param  Object		$object         Object proposal
708 708
      *  @param  int			$posy           Position y in PDF
709 709
      *  @param  Translate	$outputlangs    Object langs for output
710 710
      *  @return int             			<0 if KO, >0 if OK
711
-	 */
712
-	function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
713
-	{
711
+     */
712
+    function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
713
+    {
714 714
         // phpcs:enable
715
-	}
715
+    }
716 716
 
717 717
 
718 718
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
719
-	/**
720
-	 *   Show miscellaneous information (payment mode, payment term, ...)
721
-	 *
722
-	 *   @param		PDF			$pdf     		Object PDF
723
-	 *   @param		Object		$object			Object to show
724
-	 *   @param		int			$posy			Y
725
-	 *   @param		Translate	$outputlangs	Langs object
726
-	 *   @return	void
727
-	 */
728
-	function _tableau_info(&$pdf, $object, $posy, $outputlangs)
729
-	{
719
+    /**
720
+     *   Show miscellaneous information (payment mode, payment term, ...)
721
+     *
722
+     *   @param		PDF			$pdf     		Object PDF
723
+     *   @param		Object		$object			Object to show
724
+     *   @param		int			$posy			Y
725
+     *   @param		Translate	$outputlangs	Langs object
726
+     *   @return	void
727
+     */
728
+    function _tableau_info(&$pdf, $object, $posy, $outputlangs)
729
+    {
730 730
         // phpcs:enable
731
-		global $conf;
732
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
731
+        global $conf;
732
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
733 733
 
734
-		$pdf->SetFont('','', $default_font_size - 1);
734
+        $pdf->SetFont('','', $default_font_size - 1);
735 735
 
736
-		$posxval=52;
736
+        $posxval=52;
737 737
 
738 738
         // Show shipping date
739 739
         if (! empty($object->date_livraison))
740
-		{
740
+        {
741 741
             $outputlangs->load("sendings");
742
-			$pdf->SetFont('','B', $default_font_size - 2);
743
-			$pdf->SetXY($this->marge_gauche, $posy);
744
-			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
745
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
746
-			$pdf->SetFont('','', $default_font_size - 2);
747
-			$pdf->SetXY($posxval, $posy);
748
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
749
-			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
742
+            $pdf->SetFont('','B', $default_font_size - 2);
743
+            $pdf->SetXY($this->marge_gauche, $posy);
744
+            $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
745
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
746
+            $pdf->SetFont('','', $default_font_size - 2);
747
+            $pdf->SetXY($posxval, $posy);
748
+            $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
749
+            $pdf->MultiCell(80, 4, $dlp, 0, 'L');
750 750
 
751 751
             $posy=$pdf->GetY()+1;
752
-		}
753
-		else {
754
-			$outputlangs->load("sendings");
755
-			$pdf->SetFont('','B', $default_font_size - 2);
756
-			$pdf->SetXY($this->marge_gauche, $posy);
757
-			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
758
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
759
-			$pdf->SetFont('','', $default_font_size - 2);
760
-			$pdf->SetXY($posxval, $posy);
761
-			//$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
762
-			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
752
+        }
753
+        else {
754
+            $outputlangs->load("sendings");
755
+            $pdf->SetFont('','B', $default_font_size - 2);
756
+            $pdf->SetXY($this->marge_gauche, $posy);
757
+            $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
758
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
759
+            $pdf->SetFont('','', $default_font_size - 2);
760
+            $pdf->SetXY($posxval, $posy);
761
+            //$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
762
+            $pdf->MultiCell(80, 4, $dlp, 0, 'L');
763 763
 
764 764
             $posy=$pdf->GetY()+1;
765
-		}
765
+        }
766 766
         /* PHFAVRE
767 767
 		elseif ($object->availability_code || $object->availability)    // Show availability conditions
768 768
 		{
@@ -780,350 +780,350 @@  discard block
 block discarded – undo
780 780
 			$posy=$pdf->GetY()+1;
781 781
 		}*/
782 782
 
783
-		// Show payments conditions
784
-		if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
785
-		{
786
-			$pdf->SetFont('','B', $default_font_size - 2);
787
-			$pdf->SetXY($this->marge_gauche, $posy);
788
-			$titre = $outputlangs->transnoentities("PaymentConditions").':';
789
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
790
-
791
-			$pdf->SetFont('','', $default_font_size - 2);
792
-			$pdf->SetXY($posxval, $posy);
793
-			$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);
794
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
795
-			$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
796
-
797
-			$posy=$pdf->GetY()+3;
798
-		}
799
-
800
-		if (! empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE))
801
-		{
802
-			// Show payment mode
803
-			if ($object->mode_reglement_code
804
-			&& $object->mode_reglement_code != 'CHQ'
805
-			&& $object->mode_reglement_code != 'VIR')
806
-			{
807
-				$pdf->SetFont('','B', $default_font_size - 2);
808
-				$pdf->SetXY($this->marge_gauche, $posy-2);
809
-				$titre = $outputlangs->transnoentities("PaymentMode").':';
810
-				$pdf->MultiCell(80, 5, $titre, 0, 'L');
811
-				$pdf->SetFont('','', $default_font_size - 2);
812
-				$pdf->SetXY($posxval, $posy-2);
813
-				$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);
814
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
815
-
816
-				$posy=$pdf->GetY()+2;
817
-			}
818
-
819
-			// Show payment mode CHQ
820
-			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
821
-			{
822
-				// Si mode reglement non force ou si force a CHQ
823
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
824
-				{
825
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
826
-
827
-					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
828
-					{
829
-						$account = new Account($this->db);
830
-						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
831
-
832
-						$pdf->SetXY($this->marge_gauche, $posy);
833
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
834
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
835
-						$posy=$pdf->GetY()+1;
836
-
837
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
838
-			            {
839
-							$pdf->SetXY($this->marge_gauche, $posy);
840
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
841
-							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
842
-							$posy=$pdf->GetY()+2;
843
-			            }
844
-					}
845
-					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
846
-					{
847
-						$pdf->SetXY($this->marge_gauche, $posy);
848
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
849
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
850
-						$posy=$pdf->GetY()+1;
851
-
852
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
853
-			            {
854
-							$pdf->SetXY($this->marge_gauche, $posy);
855
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
856
-							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
857
-							$posy=$pdf->GetY()+2;
858
-			            }
859
-					}
860
-				}
861
-			}
783
+        // Show payments conditions
784
+        if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
785
+        {
786
+            $pdf->SetFont('','B', $default_font_size - 2);
787
+            $pdf->SetXY($this->marge_gauche, $posy);
788
+            $titre = $outputlangs->transnoentities("PaymentConditions").':';
789
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
790
+
791
+            $pdf->SetFont('','', $default_font_size - 2);
792
+            $pdf->SetXY($posxval, $posy);
793
+            $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);
794
+            $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
795
+            $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
796
+
797
+            $posy=$pdf->GetY()+3;
798
+        }
799
+
800
+        if (! empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE))
801
+        {
802
+            // Show payment mode
803
+            if ($object->mode_reglement_code
804
+            && $object->mode_reglement_code != 'CHQ'
805
+            && $object->mode_reglement_code != 'VIR')
806
+            {
807
+                $pdf->SetFont('','B', $default_font_size - 2);
808
+                $pdf->SetXY($this->marge_gauche, $posy-2);
809
+                $titre = $outputlangs->transnoentities("PaymentMode").':';
810
+                $pdf->MultiCell(80, 5, $titre, 0, 'L');
811
+                $pdf->SetFont('','', $default_font_size - 2);
812
+                $pdf->SetXY($posxval, $posy-2);
813
+                $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);
814
+                $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
815
+
816
+                $posy=$pdf->GetY()+2;
817
+            }
818
+
819
+            // Show payment mode CHQ
820
+            if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
821
+            {
822
+                // Si mode reglement non force ou si force a CHQ
823
+                if (! empty($conf->global->FACTURE_CHQ_NUMBER))
824
+                {
825
+                    $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
826
+
827
+                    if ($conf->global->FACTURE_CHQ_NUMBER > 0)
828
+                    {
829
+                        $account = new Account($this->db);
830
+                        $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
831
+
832
+                        $pdf->SetXY($this->marge_gauche, $posy);
833
+                        $pdf->SetFont('','B', $default_font_size - $diffsizetitle);
834
+                        $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
835
+                        $posy=$pdf->GetY()+1;
836
+
837
+                        if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
838
+                        {
839
+                            $pdf->SetXY($this->marge_gauche, $posy);
840
+                            $pdf->SetFont('','', $default_font_size - $diffsizetitle);
841
+                            $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
842
+                            $posy=$pdf->GetY()+2;
843
+                        }
844
+                    }
845
+                    if ($conf->global->FACTURE_CHQ_NUMBER == -1)
846
+                    {
847
+                        $pdf->SetXY($this->marge_gauche, $posy);
848
+                        $pdf->SetFont('','B', $default_font_size - $diffsizetitle);
849
+                        $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
850
+                        $posy=$pdf->GetY()+1;
851
+
852
+                        if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
853
+                        {
854
+                            $pdf->SetXY($this->marge_gauche, $posy);
855
+                            $pdf->SetFont('','', $default_font_size - $diffsizetitle);
856
+                            $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
857
+                            $posy=$pdf->GetY()+2;
858
+                        }
859
+                    }
860
+                }
861
+            }
862 862
 
863
-			// If payment mode not forced or forced to VIR, show payment with BAN
864
-			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
865
-			{
866
-				if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
867
-				{
868
-					$bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
869
-					$account = new Account($this->db);
870
-					$account->fetch($bankid);
863
+            // If payment mode not forced or forced to VIR, show payment with BAN
864
+            if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
865
+            {
866
+                if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
867
+                {
868
+                    $bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
869
+                    $account = new Account($this->db);
870
+                    $account->fetch($bankid);
871 871
 
872
-					$curx=$this->marge_gauche;
873
-					$cury=$posy;
872
+                    $curx=$this->marge_gauche;
873
+                    $cury=$posy;
874 874
 
875
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
875
+                    $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
876 876
 
877
-					$posy+=2;
878
-				}
879
-			}
880
-		}
877
+                    $posy+=2;
878
+                }
879
+            }
880
+        }
881 881
 
882
-		return $posy;
883
-	}
882
+        return $posy;
883
+    }
884 884
 
885 885
 
886 886
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
887
-	/**
888
-	 *	Show total to pay
889
-	 *
890
-	 *	@param	PDF			$pdf            Object PDF
891
-	 *	@param  Facture		$object         Object invoice
892
-	 *	@param  int			$deja_regle     Montant deja regle
893
-	 *	@param	int			$posy			Position depart
894
-	 *	@param	Translate	$outputlangs	Objet langs
895
-	 *	@return int							Position pour suite
896
-	 */
897
-	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
898
-	{
887
+    /**
888
+     *	Show total to pay
889
+     *
890
+     *	@param	PDF			$pdf            Object PDF
891
+     *	@param  Facture		$object         Object invoice
892
+     *	@param  int			$deja_regle     Montant deja regle
893
+     *	@param	int			$posy			Position depart
894
+     *	@param	Translate	$outputlangs	Objet langs
895
+     *	@return int							Position pour suite
896
+     */
897
+    function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
898
+    {
899 899
         // phpcs:enable
900
-		global $conf,$mysoc;
901
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
902
-
903
-		$tab2_top = $posy;
904
-		$tab2_hl = 4;
905
-		$pdf->SetFont('','', $default_font_size - 1);
906
-
907
-		// Tableau total
908
-		$col1x = 120; $col2x = 170;
909
-		if ($this->page_largeur < 210) // To work with US executive format
910
-		{
911
-			$col2x-=20;
912
-		}
913
-		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
914
-
915
-		$useborder=0;
916
-		$index = 0;
917
-
918
-		// Total HT
919
-		$pdf->SetFillColor(255,255,255);
920
-		$pdf->SetXY($col1x, $tab2_top + 0);
921
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
922
-
923
-		$pdf->SetXY($col2x, $tab2_top + 0);
924
-		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
925
-
926
-		// Show VAT by rates and total
927
-		$pdf->SetFillColor(248,248,248);
928
-
929
-		$this->atleastoneratenotnull=0;
930
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
931
-		{
932
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
933
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
934
-			{
935
-				// Nothing to do
936
-			}
937
-			else
938
-			{
939
-				//Local tax 1 before VAT
940
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
941
-				//{
942
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
943
-					{
944
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
945
-
946
-						foreach( $localtax_rate as $tvakey => $tvaval )
947
-						{
948
-							if ($tvakey!=0)    // On affiche pas taux 0
949
-							{
950
-								//$this->atleastoneratenotnull++;
951
-
952
-								$index++;
953
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
954
-
955
-								$tvacompl='';
956
-								if (preg_match('/\*/',$tvakey))
957
-								{
958
-									$tvakey=str_replace('*','',$tvakey);
959
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
960
-								}
961
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
962
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
963
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
964
-
965
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
966
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
967
-							}
968
-						}
969
-					}
970
-	      		//}
971
-				//Local tax 2 before VAT
972
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
973
-				//{
974
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
975
-					{
976
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
977
-
978
-						foreach( $localtax_rate as $tvakey => $tvaval )
979
-						{
980
-							if ($tvakey!=0)    // On affiche pas taux 0
981
-							{
982
-								//$this->atleastoneratenotnull++;
983
-
984
-
985
-
986
-								$index++;
987
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
988
-
989
-								$tvacompl='';
990
-								if (preg_match('/\*/',$tvakey))
991
-								{
992
-									$tvakey=str_replace('*','',$tvakey);
993
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
994
-								}
995
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
996
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
997
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
998
-
999
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1000
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1001
-							}
1002
-						}
1003
-					}
1004
-				//}
1005
-				// VAT
1006
-				foreach($this->tva as $tvakey => $tvaval)
1007
-				{
1008
-					if ($tvakey > 0)    // On affiche pas taux 0
1009
-					{
1010
-						$this->atleastoneratenotnull++;
1011
-
1012
-						$index++;
1013
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1014
-
1015
-						$tvacompl='';
1016
-						if (preg_match('/\*/',$tvakey))
1017
-						{
1018
-							$tvakey=str_replace('*','',$tvakey);
1019
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1020
-						}
1021
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1022
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1023
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1024
-
1025
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1026
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1027
-					}
1028
-				}
1029
-
1030
-				//Local tax 1 after VAT
1031
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1032
-				//{
1033
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1034
-					{
1035
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1036
-
1037
-						foreach( $localtax_rate as $tvakey => $tvaval )
1038
-						{
1039
-							if ($tvakey != 0)    // On affiche pas taux 0
1040
-							{
1041
-								//$this->atleastoneratenotnull++;
1042
-
1043
-								$index++;
1044
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1045
-
1046
-								$tvacompl='';
1047
-								if (preg_match('/\*/',$tvakey))
1048
-								{
1049
-									$tvakey=str_replace('*','',$tvakey);
1050
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1051
-								}
1052
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1053
-
1054
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1055
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1056
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1057
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1058
-							}
1059
-						}
1060
-					}
1061
-	      		//}
1062
-				//Local tax 2 after VAT
1063
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1064
-				//{
1065
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1066
-					{
1067
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1068
-
1069
-						foreach( $localtax_rate as $tvakey => $tvaval )
1070
-						{
1071
-						    // retrieve global local tax
1072
-							if ($tvakey != 0)    // On affiche pas taux 0
1073
-							{
1074
-								//$this->atleastoneratenotnull++;
1075
-
1076
-								$index++;
1077
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1078
-
1079
-								$tvacompl='';
1080
-								if (preg_match('/\*/',$tvakey))
1081
-								{
1082
-									$tvakey=str_replace('*','',$tvakey);
1083
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1084
-								}
1085
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1086
-
1087
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1088
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1089
-
1090
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1091
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1092
-							}
1093
-						}
1094
-					}
1095
-				//}
1096
-
1097
-				// Total TTC
1098
-				$index++;
1099
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1100
-				$pdf->SetTextColor(0,0,60);
1101
-				$pdf->SetFillColor(224,224,224);
1102
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1103
-
1104
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105
-				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1106
-			}
1107
-		}
1108
-
1109
-		$pdf->SetTextColor(0,0,0);
900
+        global $conf,$mysoc;
901
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
902
+
903
+        $tab2_top = $posy;
904
+        $tab2_hl = 4;
905
+        $pdf->SetFont('','', $default_font_size - 1);
906
+
907
+        // Tableau total
908
+        $col1x = 120; $col2x = 170;
909
+        if ($this->page_largeur < 210) // To work with US executive format
910
+        {
911
+            $col2x-=20;
912
+        }
913
+        $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
914
+
915
+        $useborder=0;
916
+        $index = 0;
917
+
918
+        // Total HT
919
+        $pdf->SetFillColor(255,255,255);
920
+        $pdf->SetXY($col1x, $tab2_top + 0);
921
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
922
+
923
+        $pdf->SetXY($col2x, $tab2_top + 0);
924
+        $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
925
+
926
+        // Show VAT by rates and total
927
+        $pdf->SetFillColor(248,248,248);
928
+
929
+        $this->atleastoneratenotnull=0;
930
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
931
+        {
932
+            $tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
933
+            if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
934
+            {
935
+                // Nothing to do
936
+            }
937
+            else
938
+            {
939
+                //Local tax 1 before VAT
940
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
941
+                //{
942
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
943
+                    {
944
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
945
+
946
+                        foreach( $localtax_rate as $tvakey => $tvaval )
947
+                        {
948
+                            if ($tvakey!=0)    // On affiche pas taux 0
949
+                            {
950
+                                //$this->atleastoneratenotnull++;
951
+
952
+                                $index++;
953
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
954
+
955
+                                $tvacompl='';
956
+                                if (preg_match('/\*/',$tvakey))
957
+                                {
958
+                                    $tvakey=str_replace('*','',$tvakey);
959
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
960
+                                }
961
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
962
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
963
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
964
+
965
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
966
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
967
+                            }
968
+                        }
969
+                    }
970
+                    //}
971
+                //Local tax 2 before VAT
972
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
973
+                //{
974
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
975
+                    {
976
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
977
+
978
+                        foreach( $localtax_rate as $tvakey => $tvaval )
979
+                        {
980
+                            if ($tvakey!=0)    // On affiche pas taux 0
981
+                            {
982
+                                //$this->atleastoneratenotnull++;
983
+
984
+
985
+
986
+                                $index++;
987
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
988
+
989
+                                $tvacompl='';
990
+                                if (preg_match('/\*/',$tvakey))
991
+                                {
992
+                                    $tvakey=str_replace('*','',$tvakey);
993
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
994
+                                }
995
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
996
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
997
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
998
+
999
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1000
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1001
+                            }
1002
+                        }
1003
+                    }
1004
+                //}
1005
+                // VAT
1006
+                foreach($this->tva as $tvakey => $tvaval)
1007
+                {
1008
+                    if ($tvakey > 0)    // On affiche pas taux 0
1009
+                    {
1010
+                        $this->atleastoneratenotnull++;
1011
+
1012
+                        $index++;
1013
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1014
+
1015
+                        $tvacompl='';
1016
+                        if (preg_match('/\*/',$tvakey))
1017
+                        {
1018
+                            $tvakey=str_replace('*','',$tvakey);
1019
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1020
+                        }
1021
+                        $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1022
+                        $totalvat.=vatrate($tvakey,1).$tvacompl;
1023
+                        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1024
+
1025
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1026
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1027
+                    }
1028
+                }
1110 1029
 
1111
-		/*
1030
+                //Local tax 1 after VAT
1031
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1032
+                //{
1033
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1034
+                    {
1035
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1036
+
1037
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1038
+                        {
1039
+                            if ($tvakey != 0)    // On affiche pas taux 0
1040
+                            {
1041
+                                //$this->atleastoneratenotnull++;
1042
+
1043
+                                $index++;
1044
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1045
+
1046
+                                $tvacompl='';
1047
+                                if (preg_match('/\*/',$tvakey))
1048
+                                {
1049
+                                    $tvakey=str_replace('*','',$tvakey);
1050
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1051
+                                }
1052
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1053
+
1054
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1055
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1056
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1057
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1058
+                            }
1059
+                        }
1060
+                    }
1061
+                    //}
1062
+                //Local tax 2 after VAT
1063
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1064
+                //{
1065
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1066
+                    {
1067
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1068
+
1069
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1070
+                        {
1071
+                            // retrieve global local tax
1072
+                            if ($tvakey != 0)    // On affiche pas taux 0
1073
+                            {
1074
+                                //$this->atleastoneratenotnull++;
1075
+
1076
+                                $index++;
1077
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1078
+
1079
+                                $tvacompl='';
1080
+                                if (preg_match('/\*/',$tvakey))
1081
+                                {
1082
+                                    $tvakey=str_replace('*','',$tvakey);
1083
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1084
+                                }
1085
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1086
+
1087
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1088
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1089
+
1090
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1091
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1092
+                            }
1093
+                        }
1094
+                    }
1095
+                //}
1096
+
1097
+                // Total TTC
1098
+                $index++;
1099
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1100
+                $pdf->SetTextColor(0,0,60);
1101
+                $pdf->SetFillColor(224,224,224);
1102
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1103
+
1104
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105
+                $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1106
+            }
1107
+        }
1108
+
1109
+        $pdf->SetTextColor(0,0,0);
1110
+
1111
+        /*
1112 1112
 		$resteapayer = $object->total_ttc - $deja_regle;
1113 1113
 		if (! empty($object->paye)) $resteapayer=0;
1114 1114
 		*/
1115 1115
 
1116
-		if ($deja_regle > 0)
1117
-		{
1118
-			$index++;
1116
+        if ($deja_regle > 0)
1117
+        {
1118
+            $index++;
1119 1119
 
1120
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1121
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1120
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1121
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1122 1122
 
1123
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1124
-			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1123
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1124
+            $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1125 1125
 
1126
-			/*
1126
+            /*
1127 1127
 			if ($object->close_code == 'discount_vat')
1128 1128
 			{
1129 1129
 				$index++;
@@ -1139,216 +1139,216 @@  discard block
 block discarded – undo
1139 1139
 			}
1140 1140
 			*/
1141 1141
 
1142
-			$index++;
1143
-			$pdf->SetTextColor(0,0,60);
1144
-			$pdf->SetFillColor(224,224,224);
1145
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1146
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1142
+            $index++;
1143
+            $pdf->SetTextColor(0,0,60);
1144
+            $pdf->SetFillColor(224,224,224);
1145
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1146
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1147 1147
 
1148
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149
-			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1148
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149
+            $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1150 1150
 
1151
-			$pdf->SetFont('','', $default_font_size - 1);
1152
-			$pdf->SetTextColor(0,0,0);
1153
-		}
1154
-
1155
-		$index++;
1156
-		return ($tab2_top + ($tab2_hl * $index));
1157
-	}
1158
-
1159
-	/**
1160
-	 *   Show table for lines
1161
-	 *
1162
-	 *   @param		PDF			$pdf     		Object PDF
1163
-	 *   @param		string		$tab_top		Top position of table
1164
-	 *   @param		string		$tab_height		Height of table (rectangle)
1165
-	 *   @param		int			$nexY			Y (not used)
1166
-	 *   @param		Translate	$outputlangs	Langs object
1167
-	 *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1168
-	 *   @param		int			$hidebottom		Hide bottom bar of array
1169
-	 *   @param		string		$currency		Currency code
1170
-	 *   @return	void
1171
-	 */
1172
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1173
-	{
1174
-		global $conf;
1175
-
1176
-		// Force to disable hidetop and hidebottom
1177
-		$hidebottom=0;
1178
-		if ($hidetop) $hidetop=-1;
1179
-
1180
-		$currency = !empty($currency) ? $currency : $conf->currency;
1181
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1182
-
1183
-		// Amount in (at tab_top - 1)
1184
-		$pdf->SetTextColor(0,0,0);
1185
-		$pdf->SetFont('','',$default_font_size - 2);
1186
-
1187
-		if (empty($hidetop))
1188
-		{
1189
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1190
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1191
-			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1151
+            $pdf->SetFont('','', $default_font_size - 1);
1152
+            $pdf->SetTextColor(0,0,0);
1153
+        }
1192 1154
 
1193
-			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1194
-			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));
1195
-		}
1155
+        $index++;
1156
+        return ($tab2_top + ($tab2_hl * $index));
1157
+    }
1196 1158
 
1197
-		$pdf->SetDrawColor(128,128,128);
1198
-		$pdf->SetFont('','',$default_font_size - 1);
1199
-
1200
-		// Output Rect
1201
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
1159
+    /**
1160
+     *   Show table for lines
1161
+     *
1162
+     *   @param		PDF			$pdf     		Object PDF
1163
+     *   @param		string		$tab_top		Top position of table
1164
+     *   @param		string		$tab_height		Height of table (rectangle)
1165
+     *   @param		int			$nexY			Y (not used)
1166
+     *   @param		Translate	$outputlangs	Langs object
1167
+     *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1168
+     *   @param		int			$hidebottom		Hide bottom bar of array
1169
+     *   @param		string		$currency		Currency code
1170
+     *   @return	void
1171
+     */
1172
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1173
+    {
1174
+        global $conf;
1175
+
1176
+        // Force to disable hidetop and hidebottom
1177
+        $hidebottom=0;
1178
+        if ($hidetop) $hidetop=-1;
1179
+
1180
+        $currency = !empty($currency) ? $currency : $conf->currency;
1181
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1182
+
1183
+        // Amount in (at tab_top - 1)
1184
+        $pdf->SetTextColor(0,0,0);
1185
+        $pdf->SetFont('','',$default_font_size - 2);
1186
+
1187
+        if (empty($hidetop))
1188
+        {
1189
+            $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1190
+            $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1191
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1192
+
1193
+            //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1194
+            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));
1195
+        }
1196
+
1197
+        $pdf->SetDrawColor(128,128,128);
1198
+        $pdf->SetFont('','',$default_font_size - 1);
1199
+
1200
+        // Output Rect
1201
+        $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
1202
+
1203
+        if (empty($hidetop))
1204
+        {
1205
+            $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
1206
+
1207
+            $pdf->SetXY($this->posxdesc-1, $tab_top+1);
1208
+            $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1209
+        }
1210
+
1211
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1212
+        {
1213
+            $pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
1214
+            //$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height);
1215
+            if (empty($hidetop))
1216
+            {
1217
+                $pdf->SetXY($this->posxtva-5, $tab_top+1);
1218
+                $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1219
+            }
1220
+        }
1221
+
1222
+        $pdf->line($this->posxup-3, $tab_top, $this->posxup-3, $tab_top + $tab_height);
1223
+        if (empty($hidetop))
1224
+        {
1225
+            $pdf->SetXY($this->posxup-1, $tab_top+1);
1226
+            $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1227
+        }
1228
+
1229
+        $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1230
+        if (empty($hidetop))
1231
+        {
1232
+            $pdf->SetXY($this->posxqty-1, $tab_top+1);
1233
+            if($conf->global->PRODUCT_USE_UNITS)
1234
+            {
1235
+                $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1236
+            }
1237
+            else
1238
+            {
1239
+                $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1240
+            }
1241
+        }
1242
+
1243
+        if($conf->global->PRODUCT_USE_UNITS) {
1244
+            $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1245
+            if (empty($hidetop)) {
1246
+                $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1247
+                $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1248
+                    'C');
1249
+            }
1250
+        }
1251
+
1252
+        $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1253
+        if (empty($hidetop))
1254
+        {
1255
+            if ($this->atleastonediscount)
1256
+            {
1257
+                $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1258
+                $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1259
+            }
1260
+        }
1261
+        if ($this->atleastonediscount)
1262
+        {
1263
+            $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1264
+        }
1265
+        if (empty($hidetop))
1266
+        {
1267
+            $pdf->SetXY($this->postotalht-1, $tab_top+1);
1268
+            $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1269
+        }
1270
+    }
1202 1271
 
1203
-		if (empty($hidetop))
1204
-		{
1205
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
1272
+    /**
1273
+     *  Show top header of page.
1274
+     *
1275
+     *  @param	PDF			$pdf     		Object PDF
1276
+     *  @param  Object		$object     	Object to show
1277
+     *  @param  int	    	$showaddress    0=no, 1=yes
1278
+     *  @param  Translate	$outputlangs	Object lang for output
1279
+     *  @return	void
1280
+     */
1281
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1282
+    {
1283
+        global $conf, $langs;
1206 1284
 
1207
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1208
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1209
-		}
1285
+        // Load traductions files requiredby by page
1286
+        $outputlangs->loadLangs(array("main", "bills", "supplier_proposal", "companies"));
1210 1287
 
1211
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1212
-		{
1213
-			$pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
1214
-			//$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height);
1215
-			if (empty($hidetop))
1216
-			{
1217
-				$pdf->SetXY($this->posxtva-5, $tab_top+1);
1218
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1219
-			}
1220
-		}
1288
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1221 1289
 
1222
-		$pdf->line($this->posxup-3, $tab_top, $this->posxup-3, $tab_top + $tab_height);
1223
-		if (empty($hidetop))
1224
-		{
1225
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1226
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1227
-		}
1290
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1228 1291
 
1229
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1230
-		if (empty($hidetop))
1231
-		{
1232
-		    $pdf->SetXY($this->posxqty-1, $tab_top+1);
1233
-		    if($conf->global->PRODUCT_USE_UNITS)
1234
-		    {
1235
-		        $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1236
-		    }
1237
-		    else
1238
-		    {
1239
-		        $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1240
-		    }
1241
-		}
1242
-
1243
-		if($conf->global->PRODUCT_USE_UNITS) {
1244
-		    $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1245
-		    if (empty($hidetop)) {
1246
-		        $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1247
-		        $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1248
-		            'C');
1249
-		    }
1250
-		}
1251
-
1252
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1253
-		if (empty($hidetop))
1254
-		{
1255
-			if ($this->atleastonediscount)
1256
-			{
1257
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1258
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1259
-			}
1260
-		}
1261
-		if ($this->atleastonediscount)
1262
-		{
1263
-			$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1264
-		}
1265
-		if (empty($hidetop))
1266
-		{
1267
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1268
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1269
-		}
1270
-	}
1271
-
1272
-	/**
1273
-	 *  Show top header of page.
1274
-	 *
1275
-	 *  @param	PDF			$pdf     		Object PDF
1276
-	 *  @param  Object		$object     	Object to show
1277
-	 *  @param  int	    	$showaddress    0=no, 1=yes
1278
-	 *  @param  Translate	$outputlangs	Object lang for output
1279
-	 *  @return	void
1280
-	 */
1281
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1282
-	{
1283
-		global $conf, $langs;
1284
-
1285
-		// Load traductions files requiredby by page
1286
-		$outputlangs->loadLangs(array("main", "bills", "supplier_proposal", "companies"));
1287
-
1288
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1289
-
1290
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1291
-
1292
-		//  Show Draft Watermark
1293
-		if($object->statut==0 && (! empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)) )
1294
-		{
1292
+        //  Show Draft Watermark
1293
+        if($object->statut==0 && (! empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)) )
1294
+        {
1295 1295
             pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
1296
-		}
1297
-
1298
-		$pdf->SetTextColor(0,0,60);
1299
-		$pdf->SetFont('','B', $default_font_size + 3);
1300
-
1301
-		$posy=$this->marge_haute;
1302
-		$posx=$this->page_largeur-$this->marge_droite-100;
1303
-
1304
-		$pdf->SetXY($this->marge_gauche,$posy);
1305
-
1306
-		// Logo
1307
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1308
-		if ($this->emetteur->logo)
1309
-		{
1310
-			if (is_readable($logo))
1311
-			{
1312
-			    $height=pdf_getHeightForLogo($logo);
1313
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1314
-			}
1315
-			else
1316
-			{
1317
-				$pdf->SetTextColor(200,0,0);
1318
-				$pdf->SetFont('','B',$default_font_size - 2);
1319
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1320
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1321
-			}
1322
-		}
1323
-		else
1324
-		{
1325
-			$text=$this->emetteur->name;
1326
-			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1327
-		}
1328
-
1329
-		$pdf->SetFont('','B',$default_font_size + 3);
1330
-		$pdf->SetXY($posx,$posy);
1331
-		$pdf->SetTextColor(0,0,60);
1332
-		$title=$outputlangs->transnoentities("CommercialAsk");
1333
-		$pdf->MultiCell(100, 4, $title, '', 'R');
1334
-
1335
-		$pdf->SetFont('','B',$default_font_size);
1336
-
1337
-		$posy+=5;
1338
-		$pdf->SetXY($posx,$posy);
1339
-		$pdf->SetTextColor(0,0,60);
1340
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1341
-
1342
-		$posy+=1;
1343
-		$pdf->SetFont('','', $default_font_size - 2);
1344
-
1345
-		if ($object->ref_client)
1346
-		{
1347
-			$posy+=4;
1348
-			$pdf->SetXY($posx,$posy);
1349
-			$pdf->SetTextColor(0,0,60);
1350
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1351
-		}
1296
+        }
1297
+
1298
+        $pdf->SetTextColor(0,0,60);
1299
+        $pdf->SetFont('','B', $default_font_size + 3);
1300
+
1301
+        $posy=$this->marge_haute;
1302
+        $posx=$this->page_largeur-$this->marge_droite-100;
1303
+
1304
+        $pdf->SetXY($this->marge_gauche,$posy);
1305
+
1306
+        // Logo
1307
+        $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1308
+        if ($this->emetteur->logo)
1309
+        {
1310
+            if (is_readable($logo))
1311
+            {
1312
+                $height=pdf_getHeightForLogo($logo);
1313
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1314
+            }
1315
+            else
1316
+            {
1317
+                $pdf->SetTextColor(200,0,0);
1318
+                $pdf->SetFont('','B',$default_font_size - 2);
1319
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1320
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1321
+            }
1322
+        }
1323
+        else
1324
+        {
1325
+            $text=$this->emetteur->name;
1326
+            $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1327
+        }
1328
+
1329
+        $pdf->SetFont('','B',$default_font_size + 3);
1330
+        $pdf->SetXY($posx,$posy);
1331
+        $pdf->SetTextColor(0,0,60);
1332
+        $title=$outputlangs->transnoentities("CommercialAsk");
1333
+        $pdf->MultiCell(100, 4, $title, '', 'R');
1334
+
1335
+        $pdf->SetFont('','B',$default_font_size);
1336
+
1337
+        $posy+=5;
1338
+        $pdf->SetXY($posx,$posy);
1339
+        $pdf->SetTextColor(0,0,60);
1340
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1341
+
1342
+        $posy+=1;
1343
+        $pdf->SetFont('','', $default_font_size - 2);
1344
+
1345
+        if ($object->ref_client)
1346
+        {
1347
+            $posy+=4;
1348
+            $pdf->SetXY($posx,$posy);
1349
+            $pdf->SetTextColor(0,0,60);
1350
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1351
+        }
1352 1352
 /* PHFAVRE
1353 1353
 		$posy+=4;
1354 1354
 		$pdf->SetXY($posx,$posy);
@@ -1356,149 +1356,149 @@  discard block
 block discarded – undo
1356 1356
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierProposalDate")." : " . dol_print_date($object->date_livraison,"day",false,$outputlangs,true), '', 'R');
1357 1357
 */
1358 1358
 
1359
-		if ($object->thirdparty->code_fournisseur)
1360
-		{
1361
-			$posy+=4;
1362
-			$pdf->SetXY($posx,$posy);
1363
-			$pdf->SetTextColor(0,0,60);
1364
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1365
-		}
1366
-
1367
-		// Get contact
1368
-		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1369
-		{
1370
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1371
-		    if (count($arrayidcontact) > 0)
1372
-		    {
1373
-		        $usertmp=new User($this->db);
1374
-		        $usertmp->fetch($arrayidcontact[0]);
1359
+        if ($object->thirdparty->code_fournisseur)
1360
+        {
1361
+            $posy+=4;
1362
+            $pdf->SetXY($posx,$posy);
1363
+            $pdf->SetTextColor(0,0,60);
1364
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1365
+        }
1366
+
1367
+        // Get contact
1368
+        if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1369
+        {
1370
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1371
+            if (count($arrayidcontact) > 0)
1372
+            {
1373
+                $usertmp=new User($this->db);
1374
+                $usertmp->fetch($arrayidcontact[0]);
1375 1375
                 $posy+=4;
1376 1376
                 $pdf->SetXY($posx,$posy);
1377
-		        $pdf->SetTextColor(0,0,60);
1378
-		        $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1379
-		    }
1380
-		}
1381
-
1382
-		$posy+=2;
1383
-
1384
-		$top_shift = 0;
1385
-		// Show list of linked objects
1386
-		$current_y = $pdf->getY();
1387
-		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1388
-		if ($current_y < $pdf->getY())
1389
-		{
1390
-			$top_shift = $pdf->getY() - $current_y;
1391
-		}
1392
-
1393
-		if ($showaddress)
1394
-		{
1395
-			// Sender properties
1396
-			$carac_emetteur='';
1397
-		 	// Add internal contact of proposal if defined
1398
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1399
-		 	if (count($arrayidcontact) > 0)
1400
-		 	{
1401
-		 		$object->fetch_user($arrayidcontact[0]);
1402
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1403
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1404
-		 	}
1405
-
1406
-		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1407
-
1408
-			// Show sender
1409
-			$posy=42+$top_shift;
1410
-		 	$posx=$this->marge_gauche;
1411
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1412
-			$hautcadre=40;
1413
-
1414
-			// Show sender frame
1415
-			$pdf->SetTextColor(0,0,0);
1416
-			$pdf->SetFont('','', $default_font_size - 2);
1417
-			$pdf->SetXY($posx,$posy-5);
1418
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1419
-			$pdf->SetXY($posx,$posy);
1420
-			$pdf->SetFillColor(230,230,230);
1421
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1422
-			$pdf->SetTextColor(0,0,60);
1423
-
1424
-			// Show sender name
1425
-			$pdf->SetXY($posx+2,$posy+3);
1426
-			$pdf->SetFont('','B', $default_font_size);
1427
-			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1428
-			$posy=$pdf->getY();
1429
-
1430
-			// Show sender information
1431
-			$pdf->SetXY($posx+2,$posy);
1432
-			$pdf->SetFont('','', $default_font_size - 1);
1433
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1434
-
1435
-
1436
-			// If CUSTOMER contact defined, we use it
1437
-			$usecontact=false;
1438
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1439
-			if (count($arrayidcontact) > 0)
1440
-			{
1441
-				$usecontact=true;
1442
-				$result=$object->fetch_contact($arrayidcontact[0]);
1443
-			}
1444
-
1445
-			// Recipient name
1446
-			if (! empty($usecontact))
1447
-			{
1448
-				// On peut utiliser le nom de la societe du contact
1449
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1450
-				else $socname = $object->thirdparty->name;
1451
-				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1452
-			}
1453
-			else
1454
-			{
1455
-				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1456
-			}
1457
-
1458
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1377
+                $pdf->SetTextColor(0,0,60);
1378
+                $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1379
+            }
1380
+        }
1381
+
1382
+        $posy+=2;
1383
+
1384
+        $top_shift = 0;
1385
+        // Show list of linked objects
1386
+        $current_y = $pdf->getY();
1387
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1388
+        if ($current_y < $pdf->getY())
1389
+        {
1390
+            $top_shift = $pdf->getY() - $current_y;
1391
+        }
1392
+
1393
+        if ($showaddress)
1394
+        {
1395
+            // Sender properties
1396
+            $carac_emetteur='';
1397
+                // Add internal contact of proposal if defined
1398
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1399
+                if (count($arrayidcontact) > 0)
1400
+                {
1401
+                    $object->fetch_user($arrayidcontact[0]);
1402
+                    $labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1403
+                    $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1404
+                }
1459 1405
 
1460
-			// Show recipient
1461
-			$widthrecbox=100;
1462
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1463
-			$posy=42+$top_shift;
1464
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1465
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1406
+                $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1407
+
1408
+            // Show sender
1409
+            $posy=42+$top_shift;
1410
+                $posx=$this->marge_gauche;
1411
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1412
+            $hautcadre=40;
1413
+
1414
+            // Show sender frame
1415
+            $pdf->SetTextColor(0,0,0);
1416
+            $pdf->SetFont('','', $default_font_size - 2);
1417
+            $pdf->SetXY($posx,$posy-5);
1418
+            $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1419
+            $pdf->SetXY($posx,$posy);
1420
+            $pdf->SetFillColor(230,230,230);
1421
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1422
+            $pdf->SetTextColor(0,0,60);
1423
+
1424
+            // Show sender name
1425
+            $pdf->SetXY($posx+2,$posy+3);
1426
+            $pdf->SetFont('','B', $default_font_size);
1427
+            $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1428
+            $posy=$pdf->getY();
1429
+
1430
+            // Show sender information
1431
+            $pdf->SetXY($posx+2,$posy);
1432
+            $pdf->SetFont('','', $default_font_size - 1);
1433
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1434
+
1435
+
1436
+            // If CUSTOMER contact defined, we use it
1437
+            $usecontact=false;
1438
+            $arrayidcontact=$object->getIdContact('external','CUSTOMER');
1439
+            if (count($arrayidcontact) > 0)
1440
+            {
1441
+                $usecontact=true;
1442
+                $result=$object->fetch_contact($arrayidcontact[0]);
1443
+            }
1444
+
1445
+            // Recipient name
1446
+            if (! empty($usecontact))
1447
+            {
1448
+                // On peut utiliser le nom de la societe du contact
1449
+                if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1450
+                else $socname = $object->thirdparty->name;
1451
+                $carac_client_name=$outputlangs->convToOutputCharset($socname);
1452
+            }
1453
+            else
1454
+            {
1455
+                $carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1456
+            }
1457
+
1458
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1459
+
1460
+            // Show recipient
1461
+            $widthrecbox=100;
1462
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1463
+            $posy=42+$top_shift;
1464
+            $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1465
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1466
+
1467
+            // Show recipient frame
1468
+            $pdf->SetTextColor(0,0,0);
1469
+            $pdf->SetFont('','', $default_font_size - 2);
1470
+            $pdf->SetXY($posx+2,$posy-5);
1471
+            $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1472
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1473
+
1474
+            // Show recipient name
1475
+            $pdf->SetXY($posx+2,$posy+3);
1476
+            $pdf->SetFont('','B', $default_font_size);
1477
+            $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1478
+
1479
+            // Show recipient information
1480
+            $pdf->SetFont('','', $default_font_size - 1);
1481
+            $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
1482
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1483
+        }
1484
+
1485
+        $pdf->SetTextColor(0,0,0);
1486
+        return $top_shift;
1487
+    }
1466 1488
 
1467
-			// Show recipient frame
1468
-			$pdf->SetTextColor(0,0,0);
1469
-			$pdf->SetFont('','', $default_font_size - 2);
1470
-			$pdf->SetXY($posx+2,$posy-5);
1471
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1472
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1473
-
1474
-			// Show recipient name
1475
-			$pdf->SetXY($posx+2,$posy+3);
1476
-			$pdf->SetFont('','B', $default_font_size);
1477
-			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1478
-
1479
-			// Show recipient information
1480
-			$pdf->SetFont('','', $default_font_size - 1);
1481
-			$pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
1482
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1483
-		}
1484
-
1485
-		$pdf->SetTextColor(0,0,0);
1486
-		return $top_shift;
1487
-	}
1488
-
1489
-	/**
1490
-	 *   	Show footer of page. Need this->emetteur object
1489
+    /**
1490
+     *   	Show footer of page. Need this->emetteur object
1491 1491
      *
1492
-	 *   	@param	PDF			$pdf     			PDF
1493
-	 * 		@param	Object		$object				Object to show
1494
-	 *      @param	Translate	$outputlangs		Object lang for output
1495
-	 *      @param	int			$hidefreetext		1=Hide free text
1496
-	 *      @return	int								Return height of bottom margin including footer text
1497
-	 */
1498
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1499
-	{
1500
-		global $conf;
1501
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1502
-		return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1503
-	}
1492
+     *   	@param	PDF			$pdf     			PDF
1493
+     * 		@param	Object		$object				Object to show
1494
+     *      @param	Translate	$outputlangs		Object lang for output
1495
+     *      @param	int			$hidefreetext		1=Hide free text
1496
+     *      @return	int								Return height of bottom margin including footer text
1497
+     */
1498
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1499
+    {
1500
+        global $conf;
1501
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1502
+        return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1503
+    }
1504 1504
 }
Please login to merge, or discard this patch.
Spacing   +411 added lines, -411 removed lines patch added patch discarded remove patch
@@ -130,67 +130,67 @@  discard block
 block discarded – undo
130 130
 
131 131
 		// Dimension page pour format A4
132 132
 		$this->type = 'pdf';
133
-		$formatarray=pdf_getFormat();
133
+		$formatarray = pdf_getFormat();
134 134
 		$this->page_largeur = $formatarray['width'];
135 135
 		$this->page_hauteur = $formatarray['height'];
136
-		$this->format = array($this->page_largeur,$this->page_hauteur);
137
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
138
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
139
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
140
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
141
-
142
-		$this->option_logo = 1;                    // Affiche logo
143
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
144
-		$this->option_modereg = 1;                 // Affiche mode reglement
145
-		$this->option_condreg = 1;                 // Affiche conditions reglement
146
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
147
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
148
-		$this->option_escompte = 1;                // Affiche si il y a eu escompte
149
-		$this->option_credit_note = 1;             // Support credit notes
150
-		$this->option_freetext = 1;				   // Support add of a personalised text
151
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
152
-
153
-		$this->franchise=!$mysoc->tva_assuj;
136
+		$this->format = array($this->page_largeur, $this->page_hauteur);
137
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
138
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
139
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
140
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
141
+
142
+		$this->option_logo = 1; // Affiche logo
143
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
144
+		$this->option_modereg = 1; // Affiche mode reglement
145
+		$this->option_condreg = 1; // Affiche conditions reglement
146
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
147
+		$this->option_multilang = 1; // Dispo en plusieurs langues
148
+		$this->option_escompte = 1; // Affiche si il y a eu escompte
149
+		$this->option_credit_note = 1; // Support credit notes
150
+		$this->option_freetext = 1; // Support add of a personalised text
151
+		$this->option_draft_watermark = 1; //Support add of a watermark on drafts
152
+
153
+		$this->franchise = !$mysoc->tva_assuj;
154 154
 
155 155
 		// Get source company
156
-		$this->emetteur=$mysoc;
157
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
156
+		$this->emetteur = $mysoc;
157
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
158 158
 
159 159
 		// Define position of columns
160
-		$this->posxdesc=$this->marge_gauche+1;
161
-		$this->posxdiscount=162;
162
-		$this->postotalht=174;
160
+		$this->posxdesc = $this->marge_gauche + 1;
161
+		$this->posxdiscount = 162;
162
+		$this->postotalht = 174;
163 163
 
164 164
 		if ($conf->global->PRODUCT_USE_UNITS)
165 165
 		{
166
-		    $this->posxtva=101;
167
-		    $this->posxup=118;
168
-		    $this->posxqty=135;
169
-		    $this->posxunit=151;
166
+		    $this->posxtva = 101;
167
+		    $this->posxup = 118;
168
+		    $this->posxqty = 135;
169
+		    $this->posxunit = 151;
170 170
 		} else {
171
-		    $this->posxtva=102;
172
-		    $this->posxup=126;
173
-		    $this->posxqty=145;
171
+		    $this->posxtva = 102;
172
+		    $this->posxup = 126;
173
+		    $this->posxqty = 145;
174 174
 		}
175 175
 
176
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
177
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
176
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup = $this->posxtva;
177
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
178 178
 		if ($this->page_largeur < 210) // To work with US executive format
179 179
 		{
180
-			$this->posxpicture-=20;
181
-			$this->posxtva-=20;
182
-			$this->posxup-=20;
183
-			$this->posxqty-=20;
184
-			$this->posxunit-=20;
185
-			$this->posxdiscount-=20;
186
-			$this->postotalht-=20;
180
+			$this->posxpicture -= 20;
181
+			$this->posxtva -= 20;
182
+			$this->posxup -= 20;
183
+			$this->posxqty -= 20;
184
+			$this->posxunit -= 20;
185
+			$this->posxdiscount -= 20;
186
+			$this->postotalht -= 20;
187 187
 		}
188 188
 
189
-		$this->tva=array();
190
-		$this->localtax1=array();
191
-		$this->localtax2=array();
192
-		$this->atleastoneratenotnull=0;
193
-		$this->atleastonediscount=0;
189
+		$this->tva = array();
190
+		$this->localtax1 = array();
191
+		$this->localtax2 = array();
192
+		$this->atleastoneratenotnull = 0;
193
+		$this->atleastonediscount = 0;
194 194
 	}
195 195
 
196 196
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
      *  @param		int			$hideref			Do not show ref
206 206
      *  @return     int             				1=OK, 0=KO
207 207
 	 */
208
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
208
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
209 209
 	{
210 210
         // phpcs:enable
211
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
211
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
212 212
 
213
-		if (! is_object($outputlangs)) $outputlangs=$langs;
213
+		if (!is_object($outputlangs)) $outputlangs = $langs;
214 214
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
215
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
215
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
216 216
 
217 217
 		// Load traductions files requiredby by page
218 218
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal"));
@@ -220,40 +220,40 @@  discard block
 block discarded – undo
220 220
 		$nblignes = count($object->lines);
221 221
 
222 222
 		// Loop on each lines to detect if there is at least one image to show
223
-		$realpatharray=array();
224
-		if (! empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
223
+		$realpatharray = array();
224
+		if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE))
225 225
 		{
226
-			for ($i = 0 ; $i < $nblignes ; $i++)
226
+			for ($i = 0; $i < $nblignes; $i++)
227 227
 			{
228 228
 				if (empty($object->lines[$i]->fk_product)) continue;
229 229
 
230 230
 				$objphoto = new Product($this->db);
231 231
 				$objphoto->fetch($object->lines[$i]->fk_product);
232 232
 
233
-				if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
233
+				if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
234 234
 				{
235
-					$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
235
+					$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
236 236
 					$dir = $conf->product->dir_output.'/'.$pdir;
237 237
 				}
238 238
 				else
239 239
 				{
240
-					$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
240
+					$pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
241 241
 					$dir = $conf->product->dir_output.'/'.$pdir;
242 242
 				}
243 243
 
244
-				$realpath='';
245
-				foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
244
+				$realpath = '';
245
+				foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
246 246
 				{
247
-					$filename=$obj['photo'];
247
+					$filename = $obj['photo'];
248 248
 					//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
249 249
 					$realpath = $dir.$filename;
250 250
 					break;
251 251
 				}
252 252
 
253
-				if ($realpath) $realpatharray[$i]=$realpath;
253
+				if ($realpath) $realpatharray[$i] = $realpath;
254 254
 			}
255 255
 		}
256
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
256
+		if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
257 257
 
258 258
 		if ($conf->supplier_proposal->dir_output)
259 259
 		{
@@ -265,20 +265,20 @@  discard block
 block discarded – undo
265 265
 			if ($object->specimen)
266 266
 			{
267 267
 				$dir = $conf->supplier_proposal->dir_output;
268
-				$file = $dir . "/SPECIMEN.pdf";
268
+				$file = $dir."/SPECIMEN.pdf";
269 269
 			}
270 270
 			else
271 271
 			{
272 272
 				$objectref = dol_sanitizeFileName($object->ref);
273
-				$dir = $conf->supplier_proposal->dir_output . "/" . $objectref;
274
-				$file = $dir . "/" . $objectref . ".pdf";
273
+				$dir = $conf->supplier_proposal->dir_output."/".$objectref;
274
+				$file = $dir."/".$objectref.".pdf";
275 275
 			}
276 276
 
277
-			if (! file_exists($dir))
277
+			if (!file_exists($dir))
278 278
 			{
279 279
 				if (dol_mkdir($dir) < 0)
280 280
 				{
281
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
281
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
282 282
 					return 0;
283 283
 				}
284 284
 			}
@@ -286,24 +286,24 @@  discard block
 block discarded – undo
286 286
 			if (file_exists($dir))
287 287
 			{
288 288
 				// Add pdfgeneration hook
289
-				if (! is_object($hookmanager))
289
+				if (!is_object($hookmanager))
290 290
 				{
291 291
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
292
-					$hookmanager=new HookManager($this->db);
292
+					$hookmanager = new HookManager($this->db);
293 293
 				}
294 294
 				$hookmanager->initHooks(array('pdfgeneration'));
295
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
295
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
296 296
 				global $action;
297
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
297
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
298 298
 
299 299
 				// Create pdf instance
300
-                $pdf=pdf_getInstance($this->format);
301
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
302
-                $heightforinfotot = 50;	// Height reserved to output the info and total part
303
-		        $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
304
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
305
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
306
-                $pdf->SetAutoPageBreak(1,0);
300
+                $pdf = pdf_getInstance($this->format);
301
+                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
302
+                $heightforinfotot = 50; // Height reserved to output the info and total part
303
+		        $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
304
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
305
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
306
+                $pdf->SetAutoPageBreak(1, 0);
307 307
 
308 308
                 if (class_exists('TCPDF'))
309 309
                 {
@@ -312,27 +312,27 @@  discard block
 block discarded – undo
312 312
                 }
313 313
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
314 314
                 // Set path to the background PDF File
315
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
315
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
316 316
                 {
317 317
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
318 318
                     $tplidx = $pdf->importPage(1);
319 319
                 }
320 320
 
321 321
 				$pdf->Open();
322
-				$pagenb=0;
323
-				$pdf->SetDrawColor(128,128,128);
322
+				$pagenb = 0;
323
+				$pdf->SetDrawColor(128, 128, 128);
324 324
 
325 325
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
326 326
 				$pdf->SetSubject($outputlangs->transnoentities("CommercialAsk"));
327 327
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
328 328
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
329 329
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
330
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
330
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
331 331
 
332
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
332
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
333 333
 
334 334
 				// Positionne $this->atleastonediscount si on a au moins une remise
335
-				for ($i = 0 ; $i < $nblignes ; $i++)
335
+				for ($i = 0; $i < $nblignes; $i++)
336 336
 				{
337 337
 					if ($object->lines[$i]->remise_percent)
338 338
 					{
@@ -341,57 +341,57 @@  discard block
 block discarded – undo
341 341
 				}
342 342
 				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
343 343
 				{
344
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
345
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
346
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
347
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
348
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
344
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
345
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
346
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
347
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
348
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
349 349
 					//$this->postotalht;
350 350
 				}
351 351
 
352 352
 				// New page
353 353
 				$pdf->AddPage();
354
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
354
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
355 355
 				$pagenb++;
356 356
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
357
-				$pdf->SetFont('','', $default_font_size - 1);
358
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
359
-				$pdf->SetTextColor(0,0,0);
357
+				$pdf->SetFont('', '', $default_font_size - 1);
358
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
359
+				$pdf->SetTextColor(0, 0, 0);
360 360
 
361
-				$tab_top = 90+$top_shift;
362
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
361
+				$tab_top = 90 + $top_shift;
362
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
363 363
 
364 364
 				// Affiche notes
365
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
366
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
365
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
366
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
367 367
 				{
368 368
 					// Get first sale rep
369 369
 					if (is_object($object->thirdparty))
370 370
 					{
371
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
372
-						$salerepobj=new User($this->db);
371
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
372
+						$salerepobj = new User($this->db);
373 373
 						$salerepobj->fetch($salereparray[0]['id']);
374
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
374
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
375 375
 					}
376 376
 				}
377 377
 				if ($notetoshow)
378 378
 				{
379 379
 					$tab_top -= 2;
380 380
 
381
-                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
381
+                    $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
382 382
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
383 383
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
384 384
 
385
-					$pdf->SetFont('','', $default_font_size - 1);
386
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
385
+					$pdf->SetFont('', '', $default_font_size - 1);
386
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
387 387
 					$nexY = $pdf->GetY();
388
-					$height_note=$nexY-$tab_top;
388
+					$height_note = $nexY - $tab_top;
389 389
 
390 390
 					// Rect prend une longueur en 3eme param
391
-					$pdf->SetDrawColor(192,192,192);
392
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
391
+					$pdf->SetDrawColor(192, 192, 192);
392
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
393 393
 
394
-					$tab_top = $nexY+6;
394
+					$tab_top = $nexY + 6;
395 395
 				}
396 396
 
397 397
 				$iniY = $tab_top + 7;
@@ -399,105 +399,105 @@  discard block
 block discarded – undo
399 399
 				$nexY = $tab_top + 7;
400 400
 
401 401
 				// Loop on each lines
402
-				for ($i = 0 ; $i < $nblignes ; $i++)
402
+				for ($i = 0; $i < $nblignes; $i++)
403 403
 				{
404 404
 					$curY = $nexY;
405
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
406
-					$pdf->SetTextColor(0,0,0);
405
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
406
+					$pdf->SetTextColor(0, 0, 0);
407 407
 
408 408
 					// Define size of image if we need it
409
-					$imglinesize=array();
410
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
409
+					$imglinesize = array();
410
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
411 411
 
412 412
 					$pdf->setTopMargin($tab_top_newpage);
413
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
414
-					$pageposbefore=$pdf->getPage();
413
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
414
+					$pageposbefore = $pdf->getPage();
415 415
 
416
-					$showpricebeforepagebreak=1;
417
-					$posYAfterImage=0;
418
-					$posYAfterDescription=0;
416
+					$showpricebeforepagebreak = 1;
417
+					$posYAfterImage = 0;
418
+					$posYAfterDescription = 0;
419 419
 
420 420
 					// We start with Photo of product line
421
-					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
421
+					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
422 422
 					{
423
-						$pdf->AddPage('','',true);
424
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
423
+						$pdf->AddPage('', '', true);
424
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
425 425
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
426
-						$pdf->setPage($pageposbefore+1);
426
+						$pdf->setPage($pageposbefore + 1);
427 427
 
428 428
 						$curY = $tab_top_newpage;
429
-						$showpricebeforepagebreak=0;
429
+						$showpricebeforepagebreak = 0;
430 430
 					}
431 431
 
432 432
 					if (!empty($imglinesize['width']) && !empty($imglinesize['height']))
433 433
 					{
434
-						$curX = $this->posxpicture-1;
435
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
434
+						$curX = $this->posxpicture - 1;
435
+						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
436 436
 						// $pdf->Image does not increase value return by getY, so we save it manually
437
-						$posYAfterImage=$curY+$imglinesize['height'];
437
+						$posYAfterImage = $curY + $imglinesize['height'];
438 438
 					}
439 439
 
440 440
 					// Description of product line
441
-					$curX = $this->posxdesc-1;
441
+					$curX = $this->posxdesc - 1;
442 442
 
443 443
 					$pdf->startTransaction();
444 444
 					if ($posYAfterImage > 0)
445 445
 					{
446
-						$descWidth = $this->posxpicture-$curX;
446
+						$descWidth = $this->posxpicture - $curX;
447 447
 					}
448 448
 					else
449 449
 					{
450
-						$descWidth = $this->posxtva-$curX;
450
+						$descWidth = $this->posxtva - $curX;
451 451
 					}
452
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
452
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
453 453
 
454
-					$pageposafter=$pdf->getPage();
454
+					$pageposafter = $pdf->getPage();
455 455
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
456 456
 					{
457 457
 						$pdf->rollbackTransaction(true);
458
-						$pageposafter=$pageposbefore;
458
+						$pageposafter = $pageposbefore;
459 459
 						//print $pageposafter.'-'.$pageposbefore;exit;
460
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
461
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc);
460
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
461
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc);
462 462
 
463
-						$pageposafter=$pdf->getPage();
464
-						$posyafter=$pdf->GetY();
463
+						$pageposafter = $pdf->getPage();
464
+						$posyafter = $pdf->GetY();
465 465
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
466
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
466
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
467 467
 						{
468
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
468
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
469 469
 							{
470
-								$pdf->AddPage('','',true);
471
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
470
+								$pdf->AddPage('', '', true);
471
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
472 472
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
473
-								$pdf->setPage($pageposafter+1);
473
+								$pdf->setPage($pageposafter + 1);
474 474
 							}
475 475
 						}
476 476
 						else
477 477
 						{
478 478
 							// We found a page break
479
-							$showpricebeforepagebreak=0;
479
+							$showpricebeforepagebreak = 0;
480 480
 						}
481 481
 					}
482 482
 					else	// No pagebreak
483 483
 					{
484 484
 						$pdf->commitTransaction();
485 485
 					}
486
-					$posYAfterDescription=$pdf->GetY();
486
+					$posYAfterDescription = $pdf->GetY();
487 487
 
488 488
 					$nexY = $pdf->GetY();
489
-					$pageposafter=$pdf->getPage();
489
+					$pageposafter = $pdf->getPage();
490 490
 
491 491
 					$pdf->setPage($pageposbefore);
492 492
 					$pdf->setTopMargin($this->marge_haute);
493
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
493
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
494 494
 
495 495
 					// We suppose that a too long description or photo were moved completely on next page
496 496
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
497 497
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
498 498
 					}
499 499
 
500
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
500
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
501 501
 
502 502
 					// VAT Rate
503 503
 					/*
@@ -519,21 +519,21 @@  discard block
 block discarded – undo
519 519
 					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
520 520
 					$pdf->SetXY($this->posxqty, $curY);
521 521
 					// Enough for 6 chars
522
-					if($conf->global->PRODUCT_USE_UNITS)
522
+					if ($conf->global->PRODUCT_USE_UNITS)
523 523
 					{
524
-					    $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 3, $qty, 0, 'R');
524
+					    $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 3, $qty, 0, 'R');
525 525
 					}
526 526
 					else
527 527
 					{
528
-					    $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R');
528
+					    $pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 3, $qty, 0, 'R');
529 529
 					}
530 530
 
531 531
 					// Unit
532
-					if($conf->global->PRODUCT_USE_UNITS)
532
+					if ($conf->global->PRODUCT_USE_UNITS)
533 533
 					{
534 534
 					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
535 535
 					    $pdf->SetXY($this->posxunit, $curY);
536
-					    $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
536
+					    $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
537 537
 					}
538 538
 
539 539
 					// Discount on line
@@ -553,54 +553,54 @@  discard block
 block discarded – undo
553 553
                     */
554 554
 
555 555
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
556
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
557
-					else $tvaligne=$object->lines[$i]->total_tva;
556
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
557
+					else $tvaligne = $object->lines[$i]->total_tva;
558 558
 
559
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
560
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
561
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
562
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
563
-					$localtax1_type=$object->lines[$i]->localtax1_type;
564
-					$localtax2_type=$object->lines[$i]->localtax2_type;
559
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
560
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
561
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
562
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
563
+					$localtax1_type = $object->lines[$i]->localtax1_type;
564
+					$localtax2_type = $object->lines[$i]->localtax2_type;
565 565
 
566
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
567
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
568
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
566
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
567
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
568
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
569 569
 
570
-					$vatrate=(string) $object->lines[$i]->tva_tx;
570
+					$vatrate = (string) $object->lines[$i]->tva_tx;
571 571
 
572 572
 					// Retrieve type from database for backward compatibility with old records
573
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
574
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
573
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
574
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
575 575
 					{
576
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
576
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
577 577
 						$localtax1_type = $localtaxtmp_array[0];
578 578
 						$localtax2_type = $localtaxtmp_array[2];
579 579
 					}
580 580
 
581 581
 				    // retrieve global local tax
582 582
 					if ($localtax1_type && $localtax1ligne != 0)
583
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
583
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
584 584
 					if ($localtax2_type && $localtax2ligne != 0)
585
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
585
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
586 586
 
587
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
588
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
587
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
588
+					if (!isset($this->tva[$vatrate]))				$this->tva[$vatrate] = 0;
589 589
 					$this->tva[$vatrate] += $tvaligne;
590 590
 
591
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
591
+					if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
592 592
 
593 593
 					// Add line
594
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
594
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
595 595
 					{
596 596
 						$pdf->setPage($pageposafter);
597
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
597
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
598 598
 						//$pdf->SetDrawColor(190,190,200);
599
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
599
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
600 600
 						$pdf->SetLineStyle(array('dash'=>0));
601 601
 					}
602 602
 
603
-					$nexY+=2;    // Passe espace entre les lignes
603
+					$nexY += 2; // Passe espace entre les lignes
604 604
 
605 605
 					// Detect if some page were added automatically and output _tableau for past pages
606 606
 					while ($pagenb < $pageposafter)
@@ -614,13 +614,13 @@  discard block
 block discarded – undo
614 614
 						{
615 615
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
616 616
 						}
617
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
617
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
618 618
 						$pagenb++;
619 619
 						$pdf->setPage($pagenb);
620
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
620
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
621 621
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
622 622
 					}
623
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
623
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
624 624
 					{
625 625
 						if ($pagenb == 1)
626 626
 						{
@@ -630,10 +630,10 @@  discard block
 block discarded – undo
630 630
 						{
631 631
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
632 632
 						}
633
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
633
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
634 634
 						// New page
635 635
 						$pdf->AddPage();
636
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
636
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
637 637
 						$pagenb++;
638 638
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
639 639
 					}
@@ -643,16 +643,16 @@  discard block
 block discarded – undo
643 643
 				if ($pagenb == 1)
644 644
 				{
645 645
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
646
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
646
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
647 647
 				}
648 648
 				else
649 649
 				{
650 650
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
651
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
651
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
652 652
 				}
653 653
 
654 654
 				// Affiche zone infos
655
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
655
+				$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
656 656
 
657 657
 				// Affiche zone totaux
658 658
 				//$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
@@ -666,35 +666,35 @@  discard block
 block discarded – undo
666 666
 				*/
667 667
 
668 668
 				// Pied de page
669
-				$this->_pagefoot($pdf,$object,$outputlangs);
670
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
669
+				$this->_pagefoot($pdf, $object, $outputlangs);
670
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
671 671
 
672 672
 				$pdf->Close();
673 673
 
674
-				$pdf->Output($file,'F');
674
+				$pdf->Output($file, 'F');
675 675
 
676 676
 				//Add pdfgeneration hook
677 677
 				$hookmanager->initHooks(array('pdfgeneration'));
678
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
678
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
679 679
 				global $action;
680
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
680
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
681 681
 
682
-				if (! empty($conf->global->MAIN_UMASK))
682
+				if (!empty($conf->global->MAIN_UMASK))
683 683
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
684 684
 
685 685
 				$this->result = array('fullpath'=>$file);
686 686
 
687
-				return 1;   // Pas d'erreur
687
+				return 1; // Pas d'erreur
688 688
 			}
689 689
 			else
690 690
 			{
691
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
691
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
692 692
 				return 0;
693 693
 			}
694 694
 		}
695 695
 		else
696 696
 		{
697
-			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_PROPOSAL_OUTPUTDIR");
697
+			$this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_PROPOSAL_OUTPUTDIR");
698 698
 			return 0;
699 699
 		}
700 700
 	}
@@ -731,37 +731,37 @@  discard block
 block discarded – undo
731 731
 		global $conf;
732 732
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
733 733
 
734
-		$pdf->SetFont('','', $default_font_size - 1);
734
+		$pdf->SetFont('', '', $default_font_size - 1);
735 735
 
736
-		$posxval=52;
736
+		$posxval = 52;
737 737
 
738 738
         // Show shipping date
739
-        if (! empty($object->date_livraison))
739
+        if (!empty($object->date_livraison))
740 740
 		{
741 741
             $outputlangs->load("sendings");
742
-			$pdf->SetFont('','B', $default_font_size - 2);
742
+			$pdf->SetFont('', 'B', $default_font_size - 2);
743 743
 			$pdf->SetXY($this->marge_gauche, $posy);
744 744
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
745 745
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
746
-			$pdf->SetFont('','', $default_font_size - 2);
746
+			$pdf->SetFont('', '', $default_font_size - 2);
747 747
 			$pdf->SetXY($posxval, $posy);
748
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
748
+			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
749 749
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
750 750
 
751
-            $posy=$pdf->GetY()+1;
751
+            $posy = $pdf->GetY() + 1;
752 752
 		}
753 753
 		else {
754 754
 			$outputlangs->load("sendings");
755
-			$pdf->SetFont('','B', $default_font_size - 2);
755
+			$pdf->SetFont('', 'B', $default_font_size - 2);
756 756
 			$pdf->SetXY($this->marge_gauche, $posy);
757 757
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
758 758
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
759
-			$pdf->SetFont('','', $default_font_size - 2);
759
+			$pdf->SetFont('', '', $default_font_size - 2);
760 760
 			$pdf->SetXY($posxval, $posy);
761 761
 			//$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
762 762
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
763 763
 
764
-            $posy=$pdf->GetY()+1;
764
+            $posy = $pdf->GetY() + 1;
765 765
 		}
766 766
         /* PHFAVRE
767 767
 		elseif ($object->availability_code || $object->availability)    // Show availability conditions
@@ -783,46 +783,46 @@  discard block
 block discarded – undo
783 783
 		// Show payments conditions
784 784
 		if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
785 785
 		{
786
-			$pdf->SetFont('','B', $default_font_size - 2);
786
+			$pdf->SetFont('', 'B', $default_font_size - 2);
787 787
 			$pdf->SetXY($this->marge_gauche, $posy);
788 788
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
789 789
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
790 790
 
791
-			$pdf->SetFont('','', $default_font_size - 2);
791
+			$pdf->SetFont('', '', $default_font_size - 2);
792 792
 			$pdf->SetXY($posxval, $posy);
793
-			$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);
794
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
795
-			$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
793
+			$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);
794
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
795
+			$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
796 796
 
797
-			$posy=$pdf->GetY()+3;
797
+			$posy = $pdf->GetY() + 3;
798 798
 		}
799 799
 
800
-		if (! empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE))
800
+		if (!empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE))
801 801
 		{
802 802
 			// Show payment mode
803 803
 			if ($object->mode_reglement_code
804 804
 			&& $object->mode_reglement_code != 'CHQ'
805 805
 			&& $object->mode_reglement_code != 'VIR')
806 806
 			{
807
-				$pdf->SetFont('','B', $default_font_size - 2);
808
-				$pdf->SetXY($this->marge_gauche, $posy-2);
807
+				$pdf->SetFont('', 'B', $default_font_size - 2);
808
+				$pdf->SetXY($this->marge_gauche, $posy - 2);
809 809
 				$titre = $outputlangs->transnoentities("PaymentMode").':';
810 810
 				$pdf->MultiCell(80, 5, $titre, 0, 'L');
811
-				$pdf->SetFont('','', $default_font_size - 2);
812
-				$pdf->SetXY($posxval, $posy-2);
813
-				$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);
814
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
811
+				$pdf->SetFont('', '', $default_font_size - 2);
812
+				$pdf->SetXY($posxval, $posy - 2);
813
+				$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);
814
+				$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
815 815
 
816
-				$posy=$pdf->GetY()+2;
816
+				$posy = $pdf->GetY() + 2;
817 817
 			}
818 818
 
819 819
 			// Show payment mode CHQ
820 820
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
821 821
 			{
822 822
 				// Si mode reglement non force ou si force a CHQ
823
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
823
+				if (!empty($conf->global->FACTURE_CHQ_NUMBER))
824 824
 				{
825
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
825
+					$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
826 826
 
827 827
 					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
828 828
 					{
@@ -830,31 +830,31 @@  discard block
 block discarded – undo
830 830
 						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
831 831
 
832 832
 						$pdf->SetXY($this->marge_gauche, $posy);
833
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
834
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
835
-						$posy=$pdf->GetY()+1;
833
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
834
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
835
+						$posy = $pdf->GetY() + 1;
836 836
 
837 837
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
838 838
 			            {
839 839
 							$pdf->SetXY($this->marge_gauche, $posy);
840
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
840
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
841 841
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
842
-							$posy=$pdf->GetY()+2;
842
+							$posy = $pdf->GetY() + 2;
843 843
 			            }
844 844
 					}
845 845
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
846 846
 					{
847 847
 						$pdf->SetXY($this->marge_gauche, $posy);
848
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
849
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
850
-						$posy=$pdf->GetY()+1;
848
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
849
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
850
+						$posy = $pdf->GetY() + 1;
851 851
 
852 852
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
853 853
 			            {
854 854
 							$pdf->SetXY($this->marge_gauche, $posy);
855
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
855
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
856 856
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
857
-							$posy=$pdf->GetY()+2;
857
+							$posy = $pdf->GetY() + 2;
858 858
 			            }
859 859
 					}
860 860
 				}
@@ -863,18 +863,18 @@  discard block
 block discarded – undo
863 863
 			// If payment mode not forced or forced to VIR, show payment with BAN
864 864
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
865 865
 			{
866
-				if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
866
+				if (!empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
867 867
 				{
868
-					$bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank);
868
+					$bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank);
869 869
 					$account = new Account($this->db);
870 870
 					$account->fetch($bankid);
871 871
 
872
-					$curx=$this->marge_gauche;
873
-					$cury=$posy;
872
+					$curx = $this->marge_gauche;
873
+					$cury = $posy;
874 874
 
875
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
875
+					$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
876 876
 
877
-					$posy+=2;
877
+					$posy += 2;
878 878
 				}
879 879
 			}
880 880
 		}
@@ -897,40 +897,40 @@  discard block
 block discarded – undo
897 897
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
898 898
 	{
899 899
         // phpcs:enable
900
-		global $conf,$mysoc;
900
+		global $conf, $mysoc;
901 901
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
902 902
 
903 903
 		$tab2_top = $posy;
904 904
 		$tab2_hl = 4;
905
-		$pdf->SetFont('','', $default_font_size - 1);
905
+		$pdf->SetFont('', '', $default_font_size - 1);
906 906
 
907 907
 		// Tableau total
908 908
 		$col1x = 120; $col2x = 170;
909 909
 		if ($this->page_largeur < 210) // To work with US executive format
910 910
 		{
911
-			$col2x-=20;
911
+			$col2x -= 20;
912 912
 		}
913 913
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
914 914
 
915
-		$useborder=0;
915
+		$useborder = 0;
916 916
 		$index = 0;
917 917
 
918 918
 		// Total HT
919
-		$pdf->SetFillColor(255,255,255);
919
+		$pdf->SetFillColor(255, 255, 255);
920 920
 		$pdf->SetXY($col1x, $tab2_top + 0);
921
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
921
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
922 922
 
923 923
 		$pdf->SetXY($col2x, $tab2_top + 0);
924
-		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
924
+		$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
925 925
 
926 926
 		// Show VAT by rates and total
927
-		$pdf->SetFillColor(248,248,248);
927
+		$pdf->SetFillColor(248, 248, 248);
928 928
 
929
-		$this->atleastoneratenotnull=0;
929
+		$this->atleastoneratenotnull = 0;
930 930
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
931 931
 		{
932
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
933
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
932
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
933
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
934 934
 			{
935 935
 				// Nothing to do
936 936
 			}
@@ -939,28 +939,28 @@  discard block
 block discarded – undo
939 939
 				//Local tax 1 before VAT
940 940
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
941 941
 				//{
942
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
942
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
943 943
 					{
944
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
944
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
945 945
 
946
-						foreach( $localtax_rate as $tvakey => $tvaval )
946
+						foreach ($localtax_rate as $tvakey => $tvaval)
947 947
 						{
948
-							if ($tvakey!=0)    // On affiche pas taux 0
948
+							if ($tvakey != 0)    // On affiche pas taux 0
949 949
 							{
950 950
 								//$this->atleastoneratenotnull++;
951 951
 
952 952
 								$index++;
953 953
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
954 954
 
955
-								$tvacompl='';
956
-								if (preg_match('/\*/',$tvakey))
955
+								$tvacompl = '';
956
+								if (preg_match('/\*/', $tvakey))
957 957
 								{
958
-									$tvakey=str_replace('*','',$tvakey);
958
+									$tvakey = str_replace('*', '', $tvakey);
959 959
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
960 960
 								}
961
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
962
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
963
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
961
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
962
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
963
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
964 964
 
965 965
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
966 966
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -971,13 +971,13 @@  discard block
 block discarded – undo
971 971
 				//Local tax 2 before VAT
972 972
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
973 973
 				//{
974
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
974
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
975 975
 					{
976
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
976
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
977 977
 
978
-						foreach( $localtax_rate as $tvakey => $tvaval )
978
+						foreach ($localtax_rate as $tvakey => $tvaval)
979 979
 						{
980
-							if ($tvakey!=0)    // On affiche pas taux 0
980
+							if ($tvakey != 0)    // On affiche pas taux 0
981 981
 							{
982 982
 								//$this->atleastoneratenotnull++;
983 983
 
@@ -986,15 +986,15 @@  discard block
 block discarded – undo
986 986
 								$index++;
987 987
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
988 988
 
989
-								$tvacompl='';
990
-								if (preg_match('/\*/',$tvakey))
989
+								$tvacompl = '';
990
+								if (preg_match('/\*/', $tvakey))
991 991
 								{
992
-									$tvakey=str_replace('*','',$tvakey);
992
+									$tvakey = str_replace('*', '', $tvakey);
993 993
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
994 994
 								}
995 995
 								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
996
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
997
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
996
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
997
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
998 998
 
999 999
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1000 1000
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 					}
1004 1004
 				//}
1005 1005
 				// VAT
1006
-				foreach($this->tva as $tvakey => $tvaval)
1006
+				foreach ($this->tva as $tvakey => $tvaval)
1007 1007
 				{
1008 1008
 					if ($tvakey > 0)    // On affiche pas taux 0
1009 1009
 					{
@@ -1012,15 +1012,15 @@  discard block
 block discarded – undo
1012 1012
 						$index++;
1013 1013
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1014 1014
 
1015
-						$tvacompl='';
1016
-						if (preg_match('/\*/',$tvakey))
1015
+						$tvacompl = '';
1016
+						if (preg_match('/\*/', $tvakey))
1017 1017
 						{
1018
-							$tvakey=str_replace('*','',$tvakey);
1018
+							$tvakey = str_replace('*', '', $tvakey);
1019 1019
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1020 1020
 						}
1021
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1022
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1023
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1021
+						$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
1022
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
1023
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1024 1024
 
1025 1025
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1026 1026
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1030,11 +1030,11 @@  discard block
 block discarded – undo
1030 1030
 				//Local tax 1 after VAT
1031 1031
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1032 1032
 				//{
1033
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1033
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1034 1034
 					{
1035
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1035
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1036 1036
 
1037
-						foreach( $localtax_rate as $tvakey => $tvaval )
1037
+						foreach ($localtax_rate as $tvakey => $tvaval)
1038 1038
 						{
1039 1039
 							if ($tvakey != 0)    // On affiche pas taux 0
1040 1040
 							{
@@ -1043,16 +1043,16 @@  discard block
 block discarded – undo
1043 1043
 								$index++;
1044 1044
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1045 1045
 
1046
-								$tvacompl='';
1047
-								if (preg_match('/\*/',$tvakey))
1046
+								$tvacompl = '';
1047
+								if (preg_match('/\*/', $tvakey))
1048 1048
 								{
1049
-									$tvakey=str_replace('*','',$tvakey);
1049
+									$tvakey = str_replace('*', '', $tvakey);
1050 1050
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1051 1051
 								}
1052
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1052
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1053 1053
 
1054
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1055
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1054
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1055
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1056 1056
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1057 1057
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1058 1058
 							}
@@ -1062,11 +1062,11 @@  discard block
 block discarded – undo
1062 1062
 				//Local tax 2 after VAT
1063 1063
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1064 1064
 				//{
1065
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1065
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1066 1066
 					{
1067
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1067
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1068 1068
 
1069
-						foreach( $localtax_rate as $tvakey => $tvaval )
1069
+						foreach ($localtax_rate as $tvakey => $tvaval)
1070 1070
 						{
1071 1071
 						    // retrieve global local tax
1072 1072
 							if ($tvakey != 0)    // On affiche pas taux 0
@@ -1076,16 +1076,16 @@  discard block
 block discarded – undo
1076 1076
 								$index++;
1077 1077
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1078 1078
 
1079
-								$tvacompl='';
1080
-								if (preg_match('/\*/',$tvakey))
1079
+								$tvacompl = '';
1080
+								if (preg_match('/\*/', $tvakey))
1081 1081
 								{
1082
-									$tvakey=str_replace('*','',$tvakey);
1082
+									$tvakey = str_replace('*', '', $tvakey);
1083 1083
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1084 1084
 								}
1085
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1085
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1086 1086
 
1087
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1088
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1087
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1088
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1089 1089
 
1090 1090
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1091 1091
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1097,16 +1097,16 @@  discard block
 block discarded – undo
1097 1097
 				// Total TTC
1098 1098
 				$index++;
1099 1099
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1100
-				$pdf->SetTextColor(0,0,60);
1101
-				$pdf->SetFillColor(224,224,224);
1102
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1100
+				$pdf->SetTextColor(0, 0, 60);
1101
+				$pdf->SetFillColor(224, 224, 224);
1102
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1103 1103
 
1104 1104
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105 1105
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1106 1106
 			}
1107 1107
 		}
1108 1108
 
1109
-		$pdf->SetTextColor(0,0,0);
1109
+		$pdf->SetTextColor(0, 0, 0);
1110 1110
 
1111 1111
 		/*
1112 1112
 		$resteapayer = $object->total_ttc - $deja_regle;
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 			$index++;
1119 1119
 
1120 1120
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1121
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1121
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1122 1122
 
1123 1123
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1124 1124
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
@@ -1140,16 +1140,16 @@  discard block
 block discarded – undo
1140 1140
 			*/
1141 1141
 
1142 1142
 			$index++;
1143
-			$pdf->SetTextColor(0,0,60);
1144
-			$pdf->SetFillColor(224,224,224);
1143
+			$pdf->SetTextColor(0, 0, 60);
1144
+			$pdf->SetFillColor(224, 224, 224);
1145 1145
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1146
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1146
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1147 1147
 
1148 1148
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1149 1149
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1150 1150
 
1151
-			$pdf->SetFont('','', $default_font_size - 1);
1152
-			$pdf->SetTextColor(0,0,0);
1151
+			$pdf->SetFont('', '', $default_font_size - 1);
1152
+			$pdf->SetTextColor(0, 0, 0);
1153 1153
 		}
1154 1154
 
1155 1155
 		$index++;
@@ -1169,43 +1169,43 @@  discard block
 block discarded – undo
1169 1169
 	 *   @param		string		$currency		Currency code
1170 1170
 	 *   @return	void
1171 1171
 	 */
1172
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1172
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1173 1173
 	{
1174 1174
 		global $conf;
1175 1175
 
1176 1176
 		// Force to disable hidetop and hidebottom
1177
-		$hidebottom=0;
1178
-		if ($hidetop) $hidetop=-1;
1177
+		$hidebottom = 0;
1178
+		if ($hidetop) $hidetop = -1;
1179 1179
 
1180 1180
 		$currency = !empty($currency) ? $currency : $conf->currency;
1181 1181
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1182 1182
 
1183 1183
 		// Amount in (at tab_top - 1)
1184
-		$pdf->SetTextColor(0,0,0);
1185
-		$pdf->SetFont('','',$default_font_size - 2);
1184
+		$pdf->SetTextColor(0, 0, 0);
1185
+		$pdf->SetFont('', '', $default_font_size - 2);
1186 1186
 
1187 1187
 		if (empty($hidetop))
1188 1188
 		{
1189
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1190
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1189
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1190
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1191 1191
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1192 1192
 
1193 1193
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1194
-			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));
1194
+			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));
1195 1195
 		}
1196 1196
 
1197
-		$pdf->SetDrawColor(128,128,128);
1198
-		$pdf->SetFont('','',$default_font_size - 1);
1197
+		$pdf->SetDrawColor(128, 128, 128);
1198
+		$pdf->SetFont('', '', $default_font_size - 1);
1199 1199
 
1200 1200
 		// Output Rect
1201
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
1201
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
1202 1202
 
1203 1203
 		if (empty($hidetop))
1204 1204
 		{
1205
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
1205
+			$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line prend une position y en 2eme param et 4eme param
1206 1206
 
1207
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1208
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1207
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1208
+			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1209 1209
 		}
1210 1210
 
1211 1211
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
@@ -1214,33 +1214,33 @@  discard block
 block discarded – undo
1214 1214
 			//$pdf->line($this->posxtva-2, $tab_top, $this->posxtva-2, $tab_top + $tab_height);
1215 1215
 			if (empty($hidetop))
1216 1216
 			{
1217
-				$pdf->SetXY($this->posxtva-5, $tab_top+1);
1218
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1217
+				$pdf->SetXY($this->posxtva - 5, $tab_top + 1);
1218
+				$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1219 1219
 			}
1220 1220
 		}
1221 1221
 
1222
-		$pdf->line($this->posxup-3, $tab_top, $this->posxup-3, $tab_top + $tab_height);
1222
+		$pdf->line($this->posxup - 3, $tab_top, $this->posxup - 3, $tab_top + $tab_height);
1223 1223
 		if (empty($hidetop))
1224 1224
 		{
1225
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1226
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1225
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
1226
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1227 1227
 		}
1228 1228
 
1229
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1229
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1230 1230
 		if (empty($hidetop))
1231 1231
 		{
1232
-		    $pdf->SetXY($this->posxqty-1, $tab_top+1);
1233
-		    if($conf->global->PRODUCT_USE_UNITS)
1232
+		    $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1233
+		    if ($conf->global->PRODUCT_USE_UNITS)
1234 1234
 		    {
1235
-		        $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1235
+		        $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1236 1236
 		    }
1237 1237
 		    else
1238 1238
 		    {
1239
-		        $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1239
+		        $pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1240 1240
 		    }
1241 1241
 		}
1242 1242
 
1243
-		if($conf->global->PRODUCT_USE_UNITS) {
1243
+		if ($conf->global->PRODUCT_USE_UNITS) {
1244 1244
 		    $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1245 1245
 		    if (empty($hidetop)) {
1246 1246
 		        $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -1249,13 +1249,13 @@  discard block
 block discarded – undo
1249 1249
 		    }
1250 1250
 		}
1251 1251
 
1252
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1252
+		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1253 1253
 		if (empty($hidetop))
1254 1254
 		{
1255 1255
 			if ($this->atleastonediscount)
1256 1256
 			{
1257
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1258
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1257
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1258
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1259 1259
 			}
1260 1260
 		}
1261 1261
 		if ($this->atleastonediscount)
@@ -1264,8 +1264,8 @@  discard block
 block discarded – undo
1264 1264
 		}
1265 1265
 		if (empty($hidetop))
1266 1266
 		{
1267
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1268
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1267
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1268
+			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1269 1269
 		}
1270 1270
 	}
1271 1271
 
@@ -1287,67 +1287,67 @@  discard block
 block discarded – undo
1287 1287
 
1288 1288
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1289 1289
 
1290
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1290
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1291 1291
 
1292 1292
 		//  Show Draft Watermark
1293
-		if($object->statut==0 && (! empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)) )
1293
+		if ($object->statut == 0 && (!empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)))
1294 1294
 		{
1295
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
1295
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
1296 1296
 		}
1297 1297
 
1298
-		$pdf->SetTextColor(0,0,60);
1299
-		$pdf->SetFont('','B', $default_font_size + 3);
1298
+		$pdf->SetTextColor(0, 0, 60);
1299
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1300 1300
 
1301
-		$posy=$this->marge_haute;
1302
-		$posx=$this->page_largeur-$this->marge_droite-100;
1301
+		$posy = $this->marge_haute;
1302
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1303 1303
 
1304
-		$pdf->SetXY($this->marge_gauche,$posy);
1304
+		$pdf->SetXY($this->marge_gauche, $posy);
1305 1305
 
1306 1306
 		// Logo
1307
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1307
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1308 1308
 		if ($this->emetteur->logo)
1309 1309
 		{
1310 1310
 			if (is_readable($logo))
1311 1311
 			{
1312
-			    $height=pdf_getHeightForLogo($logo);
1313
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1312
+			    $height = pdf_getHeightForLogo($logo);
1313
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1314 1314
 			}
1315 1315
 			else
1316 1316
 			{
1317
-				$pdf->SetTextColor(200,0,0);
1318
-				$pdf->SetFont('','B',$default_font_size - 2);
1319
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1317
+				$pdf->SetTextColor(200, 0, 0);
1318
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1319
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1320 1320
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1321 1321
 			}
1322 1322
 		}
1323 1323
 		else
1324 1324
 		{
1325
-			$text=$this->emetteur->name;
1325
+			$text = $this->emetteur->name;
1326 1326
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1327 1327
 		}
1328 1328
 
1329
-		$pdf->SetFont('','B',$default_font_size + 3);
1330
-		$pdf->SetXY($posx,$posy);
1331
-		$pdf->SetTextColor(0,0,60);
1332
-		$title=$outputlangs->transnoentities("CommercialAsk");
1329
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1330
+		$pdf->SetXY($posx, $posy);
1331
+		$pdf->SetTextColor(0, 0, 60);
1332
+		$title = $outputlangs->transnoentities("CommercialAsk");
1333 1333
 		$pdf->MultiCell(100, 4, $title, '', 'R');
1334 1334
 
1335
-		$pdf->SetFont('','B',$default_font_size);
1335
+		$pdf->SetFont('', 'B', $default_font_size);
1336 1336
 
1337
-		$posy+=5;
1338
-		$pdf->SetXY($posx,$posy);
1339
-		$pdf->SetTextColor(0,0,60);
1340
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1337
+		$posy += 5;
1338
+		$pdf->SetXY($posx, $posy);
1339
+		$pdf->SetTextColor(0, 0, 60);
1340
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1341 1341
 
1342
-		$posy+=1;
1343
-		$pdf->SetFont('','', $default_font_size - 2);
1342
+		$posy += 1;
1343
+		$pdf->SetFont('', '', $default_font_size - 2);
1344 1344
 
1345 1345
 		if ($object->ref_client)
1346 1346
 		{
1347
-			$posy+=4;
1348
-			$pdf->SetXY($posx,$posy);
1349
-			$pdf->SetTextColor(0,0,60);
1350
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1347
+			$posy += 4;
1348
+			$pdf->SetXY($posx, $posy);
1349
+			$pdf->SetTextColor(0, 0, 60);
1350
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1351 1351
 		}
1352 1352
 /* PHFAVRE
1353 1353
 		$posy+=4;
@@ -1358,28 +1358,28 @@  discard block
 block discarded – undo
1358 1358
 
1359 1359
 		if ($object->thirdparty->code_fournisseur)
1360 1360
 		{
1361
-			$posy+=4;
1362
-			$pdf->SetXY($posx,$posy);
1363
-			$pdf->SetTextColor(0,0,60);
1364
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1361
+			$posy += 4;
1362
+			$pdf->SetXY($posx, $posy);
1363
+			$pdf->SetTextColor(0, 0, 60);
1364
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1365 1365
 		}
1366 1366
 
1367 1367
 		// Get contact
1368 1368
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1369 1369
 		{
1370
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1370
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1371 1371
 		    if (count($arrayidcontact) > 0)
1372 1372
 		    {
1373
-		        $usertmp=new User($this->db);
1373
+		        $usertmp = new User($this->db);
1374 1374
 		        $usertmp->fetch($arrayidcontact[0]);
1375
-                $posy+=4;
1376
-                $pdf->SetXY($posx,$posy);
1377
-		        $pdf->SetTextColor(0,0,60);
1375
+                $posy += 4;
1376
+                $pdf->SetXY($posx, $posy);
1377
+		        $pdf->SetTextColor(0, 0, 60);
1378 1378
 		        $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
1379 1379
 		    }
1380 1380
 		}
1381 1381
 
1382
-		$posy+=2;
1382
+		$posy += 2;
1383 1383
 
1384 1384
 		$top_shift = 0;
1385 1385
 		// Show list of linked objects
@@ -1393,96 +1393,96 @@  discard block
 block discarded – undo
1393 1393
 		if ($showaddress)
1394 1394
 		{
1395 1395
 			// Sender properties
1396
-			$carac_emetteur='';
1396
+			$carac_emetteur = '';
1397 1397
 		 	// Add internal contact of proposal if defined
1398
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1398
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1399 1399
 		 	if (count($arrayidcontact) > 0)
1400 1400
 		 	{
1401 1401
 		 		$object->fetch_user($arrayidcontact[0]);
1402
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1403
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1402
+		 		$labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1403
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1404 1404
 		 	}
1405 1405
 
1406 1406
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1407 1407
 
1408 1408
 			// Show sender
1409
-			$posy=42+$top_shift;
1410
-		 	$posx=$this->marge_gauche;
1411
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1412
-			$hautcadre=40;
1409
+			$posy = 42 + $top_shift;
1410
+		 	$posx = $this->marge_gauche;
1411
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1412
+			$hautcadre = 40;
1413 1413
 
1414 1414
 			// Show sender frame
1415
-			$pdf->SetTextColor(0,0,0);
1416
-			$pdf->SetFont('','', $default_font_size - 2);
1417
-			$pdf->SetXY($posx,$posy-5);
1418
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1419
-			$pdf->SetXY($posx,$posy);
1420
-			$pdf->SetFillColor(230,230,230);
1415
+			$pdf->SetTextColor(0, 0, 0);
1416
+			$pdf->SetFont('', '', $default_font_size - 2);
1417
+			$pdf->SetXY($posx, $posy - 5);
1418
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1419
+			$pdf->SetXY($posx, $posy);
1420
+			$pdf->SetFillColor(230, 230, 230);
1421 1421
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1422
-			$pdf->SetTextColor(0,0,60);
1422
+			$pdf->SetTextColor(0, 0, 60);
1423 1423
 
1424 1424
 			// Show sender name
1425
-			$pdf->SetXY($posx+2,$posy+3);
1426
-			$pdf->SetFont('','B', $default_font_size);
1425
+			$pdf->SetXY($posx + 2, $posy + 3);
1426
+			$pdf->SetFont('', 'B', $default_font_size);
1427 1427
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1428
-			$posy=$pdf->getY();
1428
+			$posy = $pdf->getY();
1429 1429
 
1430 1430
 			// Show sender information
1431
-			$pdf->SetXY($posx+2,$posy);
1432
-			$pdf->SetFont('','', $default_font_size - 1);
1431
+			$pdf->SetXY($posx + 2, $posy);
1432
+			$pdf->SetFont('', '', $default_font_size - 1);
1433 1433
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1434 1434
 
1435 1435
 
1436 1436
 			// If CUSTOMER contact defined, we use it
1437
-			$usecontact=false;
1438
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1437
+			$usecontact = false;
1438
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1439 1439
 			if (count($arrayidcontact) > 0)
1440 1440
 			{
1441
-				$usecontact=true;
1442
-				$result=$object->fetch_contact($arrayidcontact[0]);
1441
+				$usecontact = true;
1442
+				$result = $object->fetch_contact($arrayidcontact[0]);
1443 1443
 			}
1444 1444
 
1445 1445
 			// Recipient name
1446
-			if (! empty($usecontact))
1446
+			if (!empty($usecontact))
1447 1447
 			{
1448 1448
 				// On peut utiliser le nom de la societe du contact
1449
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1449
+				if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1450 1450
 				else $socname = $object->thirdparty->name;
1451
-				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1451
+				$carac_client_name = $outputlangs->convToOutputCharset($socname);
1452 1452
 			}
1453 1453
 			else
1454 1454
 			{
1455
-				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1455
+				$carac_client_name = $outputlangs->convToOutputCharset($object->thirdparty->name);
1456 1456
 			}
1457 1457
 
1458
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1458
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1459 1459
 
1460 1460
 			// Show recipient
1461
-			$widthrecbox=100;
1462
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1463
-			$posy=42+$top_shift;
1464
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1465
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1461
+			$widthrecbox = 100;
1462
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1463
+			$posy = 42 + $top_shift;
1464
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1465
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1466 1466
 
1467 1467
 			// Show recipient frame
1468
-			$pdf->SetTextColor(0,0,0);
1469
-			$pdf->SetFont('','', $default_font_size - 2);
1470
-			$pdf->SetXY($posx+2,$posy-5);
1468
+			$pdf->SetTextColor(0, 0, 0);
1469
+			$pdf->SetFont('', '', $default_font_size - 2);
1470
+			$pdf->SetXY($posx + 2, $posy - 5);
1471 1471
 			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1472 1472
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1473 1473
 
1474 1474
 			// Show recipient name
1475
-			$pdf->SetXY($posx+2,$posy+3);
1476
-			$pdf->SetFont('','B', $default_font_size);
1475
+			$pdf->SetXY($posx + 2, $posy + 3);
1476
+			$pdf->SetFont('', 'B', $default_font_size);
1477 1477
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1478 1478
 
1479 1479
 			// Show recipient information
1480
-			$pdf->SetFont('','', $default_font_size - 1);
1481
-			$pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
1480
+			$pdf->SetFont('', '', $default_font_size - 1);
1481
+			$pdf->SetXY($posx + 2, $posy + 4 + (dol_nboflines_bis($carac_client_name, 50) * 4));
1482 1482
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1483 1483
 		}
1484 1484
 
1485
-		$pdf->SetTextColor(0,0,0);
1485
+		$pdf->SetTextColor(0, 0, 0);
1486 1486
 		return $top_shift;
1487 1487
 	}
1488 1488
 
@@ -1495,10 +1495,10 @@  discard block
 block discarded – undo
1495 1495
 	 *      @param	int			$hidefreetext		1=Hide free text
1496 1496
 	 *      @return	int								Return height of bottom margin including footer text
1497 1497
 	 */
1498
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1498
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1499 1499
 	{
1500 1500
 		global $conf;
1501
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1502
-		return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_PROPOSAL_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1501
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1502
+		return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1503 1503
 	}
1504 1504
 }
Please login to merge, or discard this patch.
Braces   +176 added lines, -90 removed lines patch added patch discarded remove patch
@@ -154,7 +154,10 @@  discard block
 block discarded – undo
154 154
 
155 155
 		// Get source company
156 156
 		$this->emetteur=$mysoc;
157
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
157
+		if (empty($this->emetteur->country_code)) {
158
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
159
+		}
160
+		// By default, if was not defined
158 161
 
159 162
 		// Define position of columns
160 163
 		$this->posxdesc=$this->marge_gauche+1;
@@ -173,11 +176,15 @@  discard block
 block discarded – undo
173 176
 		    $this->posxqty=145;
174 177
 		}
175 178
 
176
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup=$this->posxtva;
179
+		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
180
+		    $this->posxup=$this->posxtva;
181
+		}
177 182
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
178
-		if ($this->page_largeur < 210) // To work with US executive format
183
+		if ($this->page_largeur < 210) {
184
+		    // To work with US executive format
179 185
 		{
180 186
 			$this->posxpicture-=20;
187
+		}
181 188
 			$this->posxtva-=20;
182 189
 			$this->posxup-=20;
183 190
 			$this->posxqty-=20;
@@ -210,9 +217,13 @@  discard block
 block discarded – undo
210 217
         // phpcs:enable
211 218
 		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
212 219
 
213
-		if (! is_object($outputlangs)) $outputlangs=$langs;
220
+		if (! is_object($outputlangs)) {
221
+		    $outputlangs=$langs;
222
+		}
214 223
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
215
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
224
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
225
+		    $outputlangs->charset_output='ISO-8859-1';
226
+		}
216 227
 
217 228
 		// Load traductions files requiredby by page
218 229
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal"));
@@ -225,7 +236,9 @@  discard block
 block discarded – undo
225 236
 		{
226 237
 			for ($i = 0 ; $i < $nblignes ; $i++)
227 238
 			{
228
-				if (empty($object->lines[$i]->fk_product)) continue;
239
+				if (empty($object->lines[$i]->fk_product)) {
240
+				    continue;
241
+				}
229 242
 
230 243
 				$objphoto = new Product($this->db);
231 244
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -234,8 +247,7 @@  discard block
 block discarded – undo
234 247
 				{
235 248
 					$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
236 249
 					$dir = $conf->product->dir_output.'/'.$pdir;
237
-				}
238
-				else
250
+				} else
239 251
 				{
240 252
 					$pdir = get_exdir(0,2,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
241 253
 					$dir = $conf->product->dir_output.'/'.$pdir;
@@ -250,10 +262,14 @@  discard block
 block discarded – undo
250 262
 					break;
251 263
 				}
252 264
 
253
-				if ($realpath) $realpatharray[$i]=$realpath;
265
+				if ($realpath) {
266
+				    $realpatharray[$i]=$realpath;
267
+				}
254 268
 			}
255 269
 		}
256
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
270
+		if (count($realpatharray) == 0) {
271
+		    $this->posxpicture=$this->posxtva;
272
+		}
257 273
 
258 274
 		if ($conf->supplier_proposal->dir_output)
259 275
 		{
@@ -266,8 +282,7 @@  discard block
 block discarded – undo
266 282
 			{
267 283
 				$dir = $conf->supplier_proposal->dir_output;
268 284
 				$file = $dir . "/SPECIMEN.pdf";
269
-			}
270
-			else
285
+			} else
271 286
 			{
272 287
 				$objectref = dol_sanitizeFileName($object->ref);
273 288
 				$dir = $conf->supplier_proposal->dir_output . "/" . $objectref;
@@ -302,7 +317,9 @@  discard block
 block discarded – undo
302 317
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
303 318
 		        $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
304 319
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
305
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
320
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
321
+	                $heightforfooter+= 6;
322
+	            }
306 323
                 $pdf->SetAutoPageBreak(1,0);
307 324
 
308 325
                 if (class_exists('TCPDF'))
@@ -327,7 +344,9 @@  discard block
 block discarded – undo
327 344
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
328 345
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
329 346
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialAsk")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
330
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
347
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
348
+				    $pdf->SetCompression(false);
349
+				}
331 350
 
332 351
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
333 352
 
@@ -351,7 +370,9 @@  discard block
 block discarded – undo
351 370
 
352 371
 				// New page
353 372
 				$pdf->AddPage();
354
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
373
+				if (! empty($tplidx)) {
374
+				    $pdf->useTemplate($tplidx);
375
+				}
355 376
 				$pagenb++;
356 377
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
357 378
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -371,7 +392,9 @@  discard block
 block discarded – undo
371 392
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
372 393
 						$salerepobj=new User($this->db);
373 394
 						$salerepobj->fetch($salereparray[0]['id']);
374
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
395
+						if (! empty($salerepobj->signature)) {
396
+						    $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
397
+						}
375 398
 					}
376 399
 				}
377 400
 				if ($notetoshow)
@@ -407,7 +430,9 @@  discard block
 block discarded – undo
407 430
 
408 431
 					// Define size of image if we need it
409 432
 					$imglinesize=array();
410
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
433
+					if (! empty($realpatharray[$i])) {
434
+					    $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
435
+					}
411 436
 
412 437
 					$pdf->setTopMargin($tab_top_newpage);
413 438
 					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
@@ -418,11 +443,17 @@  discard block
 block discarded – undo
418 443
 					$posYAfterDescription=0;
419 444
 
420 445
 					// We start with Photo of product line
421
-					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
446
+					if (!empty($imglinesize['width']) && !empty($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) {
447
+					    // If photo too high, we moved completely on new page
422 448
 					{
423 449
 						$pdf->AddPage('','',true);
424
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
425
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
450
+					}
451
+						if (! empty($tplidx)) {
452
+						    $pdf->useTemplate($tplidx);
453
+						}
454
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
455
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
456
+						}
426 457
 						$pdf->setPage($pageposbefore+1);
427 458
 
428 459
 						$curY = $tab_top_newpage;
@@ -444,17 +475,18 @@  discard block
 block discarded – undo
444 475
 					if ($posYAfterImage > 0)
445 476
 					{
446 477
 						$descWidth = $this->posxpicture-$curX;
447
-					}
448
-					else
478
+					} else
449 479
 					{
450 480
 						$descWidth = $this->posxtva-$curX;
451 481
 					}
452 482
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$descWidth,3,$curX,$curY,$hideref,$hidedesc,1);
453 483
 
454 484
 					$pageposafter=$pdf->getPage();
455
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
485
+					if ($pageposafter > $pageposbefore) {
486
+					    // There is a pagebreak
456 487
 					{
457 488
 						$pdf->rollbackTransaction(true);
489
+					}
458 490
 						$pageposafter=$pageposbefore;
459 491
 						//print $pageposafter.'-'.$pageposbefore;exit;
460 492
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -463,23 +495,27 @@  discard block
 block discarded – undo
463 495
 						$pageposafter=$pdf->getPage();
464 496
 						$posyafter=$pdf->GetY();
465 497
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
466
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
498
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
499
+						    // There is no space left for total+free text
467 500
 						{
468 501
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
469 502
 							{
470 503
 								$pdf->AddPage('','',true);
471
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
472
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
504
+						}
505
+								if (! empty($tplidx)) {
506
+								    $pdf->useTemplate($tplidx);
507
+								}
508
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
509
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
510
+								}
473 511
 								$pdf->setPage($pageposafter+1);
474 512
 							}
475
-						}
476
-						else
513
+						} else
477 514
 						{
478 515
 							// We found a page break
479 516
 							$showpricebeforepagebreak=0;
480 517
 						}
481
-					}
482
-					else	// No pagebreak
518
+					} else	// No pagebreak
483 519
 					{
484 520
 						$pdf->commitTransaction();
485 521
 					}
@@ -522,8 +558,7 @@  discard block
 block discarded – undo
522 558
 					if($conf->global->PRODUCT_USE_UNITS)
523 559
 					{
524 560
 					    $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 3, $qty, 0, 'R');
525
-					}
526
-					else
561
+					} else
527 562
 					{
528 563
 					    $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R');
529 564
 					}
@@ -553,8 +588,11 @@  discard block
 block discarded – undo
553 588
                     */
554 589
 
555 590
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
556
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
557
-					else $tvaligne=$object->lines[$i]->total_tva;
591
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
592
+					    $tvaligne=$object->lines[$i]->multicurrency_total_tva;
593
+					} else {
594
+					    $tvaligne=$object->lines[$i]->total_tva;
595
+					}
558 596
 
559 597
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
560 598
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
@@ -563,32 +601,48 @@  discard block
 block discarded – undo
563 601
 					$localtax1_type=$object->lines[$i]->localtax1_type;
564 602
 					$localtax2_type=$object->lines[$i]->localtax2_type;
565 603
 
566
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
567
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
568
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
604
+					if ($object->remise_percent) {
605
+					    $tvaligne-=($tvaligne*$object->remise_percent)/100;
606
+					}
607
+					if ($object->remise_percent) {
608
+					    $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
609
+					}
610
+					if ($object->remise_percent) {
611
+					    $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
612
+					}
569 613
 
570 614
 					$vatrate=(string) $object->lines[$i]->tva_tx;
571 615
 
572 616
 					// Retrieve type from database for backward compatibility with old records
573 617
 					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
574
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
618
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
619
+					    // and there is local tax
575 620
 					{
576 621
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
622
+					}
577 623
 						$localtax1_type = $localtaxtmp_array[0];
578 624
 						$localtax2_type = $localtaxtmp_array[2];
579 625
 					}
580 626
 
581 627
 				    // retrieve global local tax
582
-					if ($localtax1_type && $localtax1ligne != 0)
583
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
584
-					if ($localtax2_type && $localtax2ligne != 0)
585
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
628
+					if ($localtax1_type && $localtax1ligne != 0) {
629
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
630
+					}
631
+					if ($localtax2_type && $localtax2ligne != 0) {
632
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
633
+					}
586 634
 
587
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
588
-					if (! isset($this->tva[$vatrate]))				$this->tva[$vatrate]=0;
635
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
636
+					    $vatrate.='*';
637
+					}
638
+					if (! isset($this->tva[$vatrate])) {
639
+					    $this->tva[$vatrate]=0;
640
+					}
589 641
 					$this->tva[$vatrate] += $tvaligne;
590 642
 
591
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
643
+					if ($posYAfterImage > $posYAfterDescription) {
644
+					    $nexY=$posYAfterImage;
645
+					}
592 646
 
593 647
 					// Add line
594 648
 					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
@@ -609,8 +663,7 @@  discard block
 block discarded – undo
609 663
 						if ($pagenb == 1)
610 664
 						{
611 665
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
612
-						}
613
-						else
666
+						} else
614 667
 						{
615 668
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
616 669
 						}
@@ -618,24 +671,29 @@  discard block
 block discarded – undo
618 671
 						$pagenb++;
619 672
 						$pdf->setPage($pagenb);
620 673
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
621
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
674
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
675
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
676
+						}
622 677
 					}
623 678
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
624 679
 					{
625 680
 						if ($pagenb == 1)
626 681
 						{
627 682
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
628
-						}
629
-						else
683
+						} else
630 684
 						{
631 685
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
632 686
 						}
633 687
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
634 688
 						// New page
635 689
 						$pdf->AddPage();
636
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
690
+						if (! empty($tplidx)) {
691
+						    $pdf->useTemplate($tplidx);
692
+						}
637 693
 						$pagenb++;
638
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
694
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
695
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
696
+						}
639 697
 					}
640 698
 				}
641 699
 
@@ -644,8 +702,7 @@  discard block
 block discarded – undo
644 702
 				{
645 703
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
646 704
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
647
-				}
648
-				else
705
+				} else
649 706
 				{
650 707
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
651 708
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -667,7 +724,9 @@  discard block
 block discarded – undo
667 724
 
668 725
 				// Pied de page
669 726
 				$this->_pagefoot($pdf,$object,$outputlangs);
670
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
727
+				if (method_exists($pdf,'AliasNbPages')) {
728
+				    $pdf->AliasNbPages();
729
+				}
671 730
 
672 731
 				$pdf->Close();
673 732
 
@@ -679,20 +738,19 @@  discard block
 block discarded – undo
679 738
 				global $action;
680 739
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
681 740
 
682
-				if (! empty($conf->global->MAIN_UMASK))
683
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
741
+				if (! empty($conf->global->MAIN_UMASK)) {
742
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
743
+				}
684 744
 
685 745
 				$this->result = array('fullpath'=>$file);
686 746
 
687 747
 				return 1;   // Pas d'erreur
688
-			}
689
-			else
748
+			} else
690 749
 			{
691 750
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
692 751
 				return 0;
693 752
 			}
694
-		}
695
-		else
753
+		} else
696 754
 		{
697 755
 			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_PROPOSAL_OUTPUTDIR");
698 756
 			return 0;
@@ -749,8 +807,7 @@  discard block
 block discarded – undo
749 807
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
750 808
 
751 809
             $posy=$pdf->GetY()+1;
752
-		}
753
-		else {
810
+		} else {
754 811
 			$outputlangs->load("sendings");
755 812
 			$pdf->SetFont('','B', $default_font_size - 2);
756 813
 			$pdf->SetXY($this->marge_gauche, $posy);
@@ -906,10 +963,12 @@  discard block
 block discarded – undo
906 963
 
907 964
 		// Tableau total
908 965
 		$col1x = 120; $col2x = 170;
909
-		if ($this->page_largeur < 210) // To work with US executive format
966
+		if ($this->page_largeur < 210) {
967
+		    // To work with US executive format
910 968
 		{
911 969
 			$col2x-=20;
912 970
 		}
971
+		}
913 972
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
914 973
 
915 974
 		$useborder=0;
@@ -933,23 +992,26 @@  discard block
 block discarded – undo
933 992
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
934 993
 			{
935 994
 				// Nothing to do
936
-			}
937
-			else
995
+			} else
938 996
 			{
939 997
 				//Local tax 1 before VAT
940 998
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
941 999
 				//{
942 1000
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
943 1001
 					{
944
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1002
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1003
+						    continue;
1004
+						}
945 1005
 
946 1006
 						foreach( $localtax_rate as $tvakey => $tvaval )
947 1007
 						{
948
-							if ($tvakey!=0)    // On affiche pas taux 0
1008
+							if ($tvakey!=0) {
1009
+							    // On affiche pas taux 0
949 1010
 							{
950 1011
 								//$this->atleastoneratenotnull++;
951 1012
 
952 1013
 								$index++;
1014
+							}
953 1015
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
954 1016
 
955 1017
 								$tvacompl='';
@@ -973,17 +1035,21 @@  discard block
 block discarded – undo
973 1035
 				//{
974 1036
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
975 1037
 					{
976
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1038
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1039
+						    continue;
1040
+						}
977 1041
 
978 1042
 						foreach( $localtax_rate as $tvakey => $tvaval )
979 1043
 						{
980
-							if ($tvakey!=0)    // On affiche pas taux 0
1044
+							if ($tvakey!=0) {
1045
+							    // On affiche pas taux 0
981 1046
 							{
982 1047
 								//$this->atleastoneratenotnull++;
983 1048
 
984 1049
 
985 1050
 
986 1051
 								$index++;
1052
+							}
987 1053
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
988 1054
 
989 1055
 								$tvacompl='';
@@ -1005,9 +1071,11 @@  discard block
 block discarded – undo
1005 1071
 				// VAT
1006 1072
 				foreach($this->tva as $tvakey => $tvaval)
1007 1073
 				{
1008
-					if ($tvakey > 0)    // On affiche pas taux 0
1074
+					if ($tvakey > 0) {
1075
+					    // On affiche pas taux 0
1009 1076
 					{
1010 1077
 						$this->atleastoneratenotnull++;
1078
+					}
1011 1079
 
1012 1080
 						$index++;
1013 1081
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1032,15 +1100,19 @@  discard block
 block discarded – undo
1032 1100
 				//{
1033 1101
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1034 1102
 					{
1035
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1103
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1104
+						    continue;
1105
+						}
1036 1106
 
1037 1107
 						foreach( $localtax_rate as $tvakey => $tvaval )
1038 1108
 						{
1039
-							if ($tvakey != 0)    // On affiche pas taux 0
1109
+							if ($tvakey != 0) {
1110
+							    // On affiche pas taux 0
1040 1111
 							{
1041 1112
 								//$this->atleastoneratenotnull++;
1042 1113
 
1043 1114
 								$index++;
1115
+							}
1044 1116
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1045 1117
 
1046 1118
 								$tvacompl='';
@@ -1064,16 +1136,20 @@  discard block
 block discarded – undo
1064 1136
 				//{
1065 1137
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1066 1138
 					{
1067
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1139
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1140
+						    continue;
1141
+						}
1068 1142
 
1069 1143
 						foreach( $localtax_rate as $tvakey => $tvaval )
1070 1144
 						{
1071 1145
 						    // retrieve global local tax
1072
-							if ($tvakey != 0)    // On affiche pas taux 0
1146
+							if ($tvakey != 0) {
1147
+							    // On affiche pas taux 0
1073 1148
 							{
1074 1149
 								//$this->atleastoneratenotnull++;
1075 1150
 
1076 1151
 								$index++;
1152
+							}
1077 1153
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1078 1154
 
1079 1155
 								$tvacompl='';
@@ -1175,7 +1251,9 @@  discard block
 block discarded – undo
1175 1251
 
1176 1252
 		// Force to disable hidetop and hidebottom
1177 1253
 		$hidebottom=0;
1178
-		if ($hidetop) $hidetop=-1;
1254
+		if ($hidetop) {
1255
+		    $hidetop=-1;
1256
+		}
1179 1257
 
1180 1258
 		$currency = !empty($currency) ? $currency : $conf->currency;
1181 1259
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1191,7 +1269,9 @@  discard block
 block discarded – undo
1191 1269
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1192 1270
 
1193 1271
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1194
-			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));
1272
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1273
+			    $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));
1274
+			}
1195 1275
 		}
1196 1276
 
1197 1277
 		$pdf->SetDrawColor(128,128,128);
@@ -1233,8 +1313,7 @@  discard block
 block discarded – undo
1233 1313
 		    if($conf->global->PRODUCT_USE_UNITS)
1234 1314
 		    {
1235 1315
 		        $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1236
-		    }
1237
-		    else
1316
+		    } else
1238 1317
 		    {
1239 1318
 		        $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1240 1319
 		    }
@@ -1311,16 +1390,14 @@  discard block
 block discarded – undo
1311 1390
 			{
1312 1391
 			    $height=pdf_getHeightForLogo($logo);
1313 1392
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1314
-			}
1315
-			else
1393
+			} else
1316 1394
 			{
1317 1395
 				$pdf->SetTextColor(200,0,0);
1318 1396
 				$pdf->SetFont('','B',$default_font_size - 2);
1319 1397
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1320 1398
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1321 1399
 			}
1322
-		}
1323
-		else
1400
+		} else
1324 1401
 		{
1325 1402
 			$text=$this->emetteur->name;
1326 1403
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1408,7 +1485,9 @@  discard block
 block discarded – undo
1408 1485
 			// Show sender
1409 1486
 			$posy=42+$top_shift;
1410 1487
 		 	$posx=$this->marge_gauche;
1411
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1488
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1489
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1490
+			}
1412 1491
 			$hautcadre=40;
1413 1492
 
1414 1493
 			// Show sender frame
@@ -1446,11 +1525,13 @@  discard block
 block discarded – undo
1446 1525
 			if (! empty($usecontact))
1447 1526
 			{
1448 1527
 				// On peut utiliser le nom de la societe du contact
1449
-				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
1450
-				else $socname = $object->thirdparty->name;
1528
+				if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1529
+				    $socname = $object->contact->socname;
1530
+				} else {
1531
+				    $socname = $object->thirdparty->name;
1532
+				}
1451 1533
 				$carac_client_name=$outputlangs->convToOutputCharset($socname);
1452
-			}
1453
-			else
1534
+			} else
1454 1535
 			{
1455 1536
 				$carac_client_name=$outputlangs->convToOutputCharset($object->thirdparty->name);
1456 1537
 			}
@@ -1459,10 +1540,15 @@  discard block
 block discarded – undo
1459 1540
 
1460 1541
 			// Show recipient
1461 1542
 			$widthrecbox=100;
1462
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1543
+			if ($this->page_largeur < 210) {
1544
+			    $widthrecbox=84;
1545
+			}
1546
+			// To work with US executive format
1463 1547
 			$posy=42+$top_shift;
1464 1548
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1465
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1549
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1550
+			    $posx=$this->marge_gauche;
1551
+			}
1466 1552
 
1467 1553
 			// Show recipient frame
1468 1554
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php 3 patches
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -31,30 +31,30 @@  discard block
 block discarded – undo
31 31
  */
32 32
 class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
33 33
 {
34
-	/**
34
+    /**
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
39 39
 
40
-	public $prefix='RQ';               // RQ = Request for quotation
40
+    public $prefix='RQ';               // RQ = Request for quotation
41 41
 
42
-	/**
43
-	 * @var string Error code (or message)
44
-	 */
45
-	public $error='';
42
+    /**
43
+     * @var string Error code (or message)
44
+     */
45
+    public $error='';
46 46
 
47
-	/**
48
-	 * @var string Nom du modele
49
-	 * @deprecated
50
-	 * @see name
51
-	 */
52
-	public $nom='Marbre';
47
+    /**
48
+     * @var string Nom du modele
49
+     * @deprecated
50
+     * @see name
51
+     */
52
+    public $nom='Marbre';
53 53
 
54
-	/**
55
-	 * @var string model name
56
-	 */
57
-	public $name='Marbre';
54
+    /**
55
+     * @var string model name
56
+     */
57
+    public $name='Marbre';
58 58
 
59 59
 
60 60
     /**
@@ -64,109 +64,109 @@  discard block
 block discarded – undo
64 64
      */
65 65
     function info()
66 66
     {
67
-    	global $langs;
68
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
67
+        global $langs;
68
+            return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
69
+    }
70
+
71
+
72
+    /**
73
+     *  Return an example of numbering module values
74
+     *
75
+     *  @return     string      Example
76
+     */
77
+    function getExample()
78
+    {
79
+        return $this->prefix."0501-0001";
69 80
     }
70 81
 
71 82
 
72
-	/**
73
-	 *  Return an example of numbering module values
74
-	 *
75
-	 *  @return     string      Example
76
-	 */
77
-	function getExample()
78
-	{
79
-		return $this->prefix."0501-0001";
80
-	}
81
-
82
-
83
-	/**
84
-	 *  Test si les numeros deje en vigueur dans la base ne provoquent pas de
85
-	 *  de conflits qui empechera cette numerotation de fonctionner.
86
-	 *
87
-	 *  @return     boolean     false si conflit, true si ok
88
-	 */
89
-	function canBeActivated()
90
-	{
91
-		global $conf,$langs,$db;
92
-
93
-		$pryymm=''; $max='';
94
-
95
-		$posindice=8;
96
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
97
-		$sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal";
98
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
99
-		$sql.= " AND entity = ".$conf->entity;
100
-
101
-		$resql=$db->query($sql);
102
-		if ($resql)
103
-		{
104
-			$row = $db->fetch_row($resql);
105
-			if ($row) { $pryymm = substr($row[0],0,6); $max=$row[0]; }
106
-		}
107
-
108
-		if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm))
109
-		{
110
-			return true;
111
-		}
112
-		else
113
-		{
114
-			$langs->load("errors");
115
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
116
-			return false;
117
-		}
118
-	}
119
-
120
-	/**
121
-	 *  Return next value
122
-	 *
123
-	 *  @param	Societe		$objsoc     Object third party
124
-	 * 	@param	Propal		$supplier_proposal		Object commercial proposal
125
-	 *  @return string      			Next value
126
-	 */
127
-	function getNextValue($objsoc,$supplier_proposal)
128
-	{
129
-		global $db,$conf;
130
-
131
-		// D'abord on recupere la valeur max
132
-		$posindice=8;
133
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
134
-		$sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal";
135
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
136
-		$sql.= " AND entity = ".$conf->entity;
137
-
138
-		$resql=$db->query($sql);
139
-		if ($resql)
140
-		{
141
-			$obj = $db->fetch_object($resql);
142
-			if ($obj) $max = intval($obj->max);
143
-			else $max=0;
144
-		}
145
-		else
146
-		{
147
-			dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
148
-			return -1;
149
-		}
150
-
151
-		$date = time();
152
-		$yymm = strftime("%y%m",$date);
153
-
154
-		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
155
-		else $num = sprintf("%04s",$max+1);
156
-
157
-		dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num);
158
-		return $this->prefix.$yymm."-".$num;
159
-	}
160
-
161
-	/**
162
-	 *  Return next free value
163
-	 *
164
-	 *  @param	Societe		$objsoc      	Object third party
165
-	 * 	@param	Object		$objforref		Object for number to search
166
-	 *  @return string      				Next free value
167
-	 */
168
-	function getNumRef($objsoc,$objforref)
169
-	{
170
-		return $this->getNextValue($objsoc,$objforref);
171
-	}
83
+    /**
84
+     *  Test si les numeros deje en vigueur dans la base ne provoquent pas de
85
+     *  de conflits qui empechera cette numerotation de fonctionner.
86
+     *
87
+     *  @return     boolean     false si conflit, true si ok
88
+     */
89
+    function canBeActivated()
90
+    {
91
+        global $conf,$langs,$db;
92
+
93
+        $pryymm=''; $max='';
94
+
95
+        $posindice=8;
96
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
97
+        $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal";
98
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
99
+        $sql.= " AND entity = ".$conf->entity;
100
+
101
+        $resql=$db->query($sql);
102
+        if ($resql)
103
+        {
104
+            $row = $db->fetch_row($resql);
105
+            if ($row) { $pryymm = substr($row[0],0,6); $max=$row[0]; }
106
+        }
107
+
108
+        if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm))
109
+        {
110
+            return true;
111
+        }
112
+        else
113
+        {
114
+            $langs->load("errors");
115
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
116
+            return false;
117
+        }
118
+    }
119
+
120
+    /**
121
+     *  Return next value
122
+     *
123
+     *  @param	Societe		$objsoc     Object third party
124
+     * 	@param	Propal		$supplier_proposal		Object commercial proposal
125
+     *  @return string      			Next value
126
+     */
127
+    function getNextValue($objsoc,$supplier_proposal)
128
+    {
129
+        global $db,$conf;
130
+
131
+        // D'abord on recupere la valeur max
132
+        $posindice=8;
133
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
134
+        $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal";
135
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
136
+        $sql.= " AND entity = ".$conf->entity;
137
+
138
+        $resql=$db->query($sql);
139
+        if ($resql)
140
+        {
141
+            $obj = $db->fetch_object($resql);
142
+            if ($obj) $max = intval($obj->max);
143
+            else $max=0;
144
+        }
145
+        else
146
+        {
147
+            dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
148
+            return -1;
149
+        }
150
+
151
+        $date = time();
152
+        $yymm = strftime("%y%m",$date);
153
+
154
+        if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
155
+        else $num = sprintf("%04s",$max+1);
156
+
157
+        dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num);
158
+        return $this->prefix.$yymm."-".$num;
159
+    }
160
+
161
+    /**
162
+     *  Return next free value
163
+     *
164
+     *  @param	Societe		$objsoc      	Object third party
165
+     * 	@param	Object		$objforref		Object for number to search
166
+     *  @return string      				Next free value
167
+     */
168
+    function getNumRef($objsoc,$objforref)
169
+    {
170
+        return $this->getNextValue($objsoc,$objforref);
171
+    }
172 172
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *		\brief      File of class to manage commercial proposal numbering rules Marbre
24 24
  */
25 25
 
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_proposal/modules_supplier_proposal.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php';
27 27
 
28 28
 
29 29
 /**
@@ -35,26 +35,26 @@  discard block
 block discarded – undo
35 35
      * Dolibarr version of the loaded document
36 36
      * @public string
37 37
      */
38
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
38
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
39 39
 
40
-	public $prefix='RQ';               // RQ = Request for quotation
40
+	public $prefix = 'RQ'; // RQ = Request for quotation
41 41
 
42 42
 	/**
43 43
 	 * @var string Error code (or message)
44 44
 	 */
45
-	public $error='';
45
+	public $error = '';
46 46
 
47 47
 	/**
48 48
 	 * @var string Nom du modele
49 49
 	 * @deprecated
50 50
 	 * @see name
51 51
 	 */
52
-	public $nom='Marbre';
52
+	public $nom = 'Marbre';
53 53
 
54 54
 	/**
55 55
 	 * @var string model name
56 56
 	 */
57
-	public $name='Marbre';
57
+	public $name = 'Marbre';
58 58
 
59 59
 
60 60
     /**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     function info()
66 66
     {
67 67
     	global $langs;
68
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
68
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
69 69
     }
70 70
 
71 71
 
@@ -88,31 +88,31 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	function canBeActivated()
90 90
 	{
91
-		global $conf,$langs,$db;
91
+		global $conf, $langs, $db;
92 92
 
93
-		$pryymm=''; $max='';
93
+		$pryymm = ''; $max = '';
94 94
 
95
-		$posindice=8;
95
+		$posindice = 8;
96 96
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
97
-		$sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal";
98
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
99
-		$sql.= " AND entity = ".$conf->entity;
97
+		$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal";
98
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
99
+		$sql .= " AND entity = ".$conf->entity;
100 100
 
101
-		$resql=$db->query($sql);
101
+		$resql = $db->query($sql);
102 102
 		if ($resql)
103 103
 		{
104 104
 			$row = $db->fetch_row($resql);
105
-			if ($row) { $pryymm = substr($row[0],0,6); $max=$row[0]; }
105
+			if ($row) { $pryymm = substr($row[0], 0, 6); $max = $row[0]; }
106 106
 		}
107 107
 
108
-		if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm))
108
+		if (!$pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $pryymm))
109 109
 		{
110 110
 			return true;
111 111
 		}
112 112
 		else
113 113
 		{
114 114
 			$langs->load("errors");
115
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
115
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
116 116
 			return false;
117 117
 		}
118 118
 	}
@@ -124,23 +124,23 @@  discard block
 block discarded – undo
124 124
 	 * 	@param	Propal		$supplier_proposal		Object commercial proposal
125 125
 	 *  @return string      			Next value
126 126
 	 */
127
-	function getNextValue($objsoc,$supplier_proposal)
127
+	function getNextValue($objsoc, $supplier_proposal)
128 128
 	{
129
-		global $db,$conf;
129
+		global $db, $conf;
130 130
 
131 131
 		// D'abord on recupere la valeur max
132
-		$posindice=8;
133
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
134
-		$sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal";
135
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
136
-		$sql.= " AND entity = ".$conf->entity;
132
+		$posindice = 8;
133
+		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
134
+		$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal";
135
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
136
+		$sql .= " AND entity = ".$conf->entity;
137 137
 
138
-		$resql=$db->query($sql);
138
+		$resql = $db->query($sql);
139 139
 		if ($resql)
140 140
 		{
141 141
 			$obj = $db->fetch_object($resql);
142 142
 			if ($obj) $max = intval($obj->max);
143
-			else $max=0;
143
+			else $max = 0;
144 144
 		}
145 145
 		else
146 146
 		{
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
 		}
150 150
 
151 151
 		$date = time();
152
-		$yymm = strftime("%y%m",$date);
152
+		$yymm = strftime("%y%m", $date);
153 153
 
154
-		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
155
-		else $num = sprintf("%04s",$max+1);
154
+		if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
155
+		else $num = sprintf("%04s", $max + 1);
156 156
 
157 157
 		dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num);
158 158
 		return $this->prefix.$yymm."-".$num;
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 	 * 	@param	Object		$objforref		Object for number to search
166 166
 	 *  @return string      				Next free value
167 167
 	 */
168
-	function getNumRef($objsoc,$objforref)
168
+	function getNumRef($objsoc, $objforref)
169 169
 	{
170
-		return $this->getNextValue($objsoc,$objforref);
170
+		return $this->getNextValue($objsoc, $objforref);
171 171
 	}
172 172
 }
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -108,8 +108,7 @@  discard block
 block discarded – undo
108 108
 		if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm))
109 109
 		{
110 110
 			return true;
111
-		}
112
-		else
111
+		} else
113 112
 		{
114 113
 			$langs->load("errors");
115 114
 			$this->error=$langs->trans('ErrorNumRefModel',$max);
@@ -139,10 +138,12 @@  discard block
 block discarded – undo
139 138
 		if ($resql)
140 139
 		{
141 140
 			$obj = $db->fetch_object($resql);
142
-			if ($obj) $max = intval($obj->max);
143
-			else $max=0;
144
-		}
145
-		else
141
+			if ($obj) {
142
+			    $max = intval($obj->max);
143
+			} else {
144
+			    $max=0;
145
+			}
146
+		} else
146 147
 		{
147 148
 			dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
148 149
 			return -1;
@@ -151,8 +152,13 @@  discard block
 block discarded – undo
151 152
 		$date = time();
152 153
 		$yymm = strftime("%y%m",$date);
153 154
 
154
-		if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
155
-		else $num = sprintf("%04s",$max+1);
155
+		if ($max >= (pow(10, 4) - 1)) {
156
+		    $num=$max+1;
157
+		}
158
+		// If counter > 9999, we do not format on 4 chars, we take number as it is
159
+		else {
160
+		    $num = sprintf("%04s",$max+1);
161
+		}
156 162
 
157 163
 		dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num);
158 164
 		return $this->prefix.$yymm."-".$num;
Please login to merge, or discard this patch.
htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -33,28 +33,28 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal
35 35
 {
36
-	/**
36
+    /**
37 37
      * Dolibarr version of the loaded document
38 38
      * @public string
39 39
      */
40
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
40
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
41 41
 
42
-	/**
42
+    /**
43 43
      * @var string Error code (or message)
44 44
      */
45 45
     public $error = '';
46 46
 
47
-	/**
48
-	 * @var string Nom du modele
49
-	 * @deprecated
50
-	 * @see name
51
-	 */
52
-	public $nom='Saphir';
47
+    /**
48
+     * @var string Nom du modele
49
+     * @deprecated
50
+     * @see name
51
+     */
52
+    public $nom='Saphir';
53 53
 
54
-	/**
55
-	 * @var string model name
56
-	 */
57
-	public $name='Saphir';
54
+    /**
55
+     * @var string model name
56
+     */
57
+    public $name='Saphir';
58 58
 
59 59
 
60 60
     /**
@@ -62,39 +62,39 @@  discard block
 block discarded – undo
62 62
      *
63 63
      *  @return     string      Texte descripif
64 64
      */
65
-	function info()
65
+    function info()
66 66
     {
67
-    	global $conf, $langs;
67
+        global $conf, $langs;
68 68
 
69
-		$langs->load("bills");
69
+        $langs->load("bills");
70 70
 
71
-		$form = new Form($this->db);
71
+        $form = new Form($this->db);
72 72
 
73
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
77
-		$texte.= '<input type="hidden" name="maskconstsupplier_proposal" value="SUPPLIER_PROPOSAL_SAPHIR_MASK">';
78
-		$texte.= '<table class="nobordernopadding" width="100%">';
73
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
+        $texte.= '<input type="hidden" name="action" value="updateMask">';
77
+        $texte.= '<input type="hidden" name="maskconstsupplier_proposal" value="SUPPLIER_PROPOSAL_SAPHIR_MASK">';
78
+        $texte.= '<table class="nobordernopadding" width="100%">';
79 79
 
80
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes2");
82
-		$tooltip.=$langs->trans("GenericMaskCodes3");
83
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
84
-		$tooltip.=$langs->trans("GenericMaskCodes5");
80
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
81
+        $tooltip.=$langs->trans("GenericMaskCodes2");
82
+        $tooltip.=$langs->trans("GenericMaskCodes3");
83
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
84
+        $tooltip.=$langs->trans("GenericMaskCodes5");
85 85
 
86
-		// Parametrage du prefix
87
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplier_proposal" value="'.$conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
86
+        // Parametrage du prefix
87
+        $texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplier_proposal" value="'.$conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
89 89
 
90
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
90
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
91 91
 
92
-		$texte.= '</tr>';
92
+        $texte.= '</tr>';
93 93
 
94
-		$texte.= '</table>';
95
-		$texte.= '</form>';
94
+        $texte.= '</table>';
95
+        $texte.= '</form>';
96 96
 
97
-		return $texte;
97
+        return $texte;
98 98
     }
99 99
 
100 100
     /**
@@ -104,46 +104,46 @@  discard block
 block discarded – undo
104 104
      */
105 105
     function getExample()
106 106
     {
107
-     	global $conf,$langs,$mysoc;
108
-
109
-    	$old_code_client=$mysoc->code_client;
110
-    	$mysoc->code_client='CCCCCCCCCC';
111
-     	$numExample = $this->getNextValue($mysoc,'');
112
-		$mysoc->code_client=$old_code_client;
113
-
114
-		if (! $numExample)
115
-		{
116
-			$numExample = 'NotConfigured';
117
-		}
118
-		return $numExample;
107
+            global $conf,$langs,$mysoc;
108
+
109
+        $old_code_client=$mysoc->code_client;
110
+        $mysoc->code_client='CCCCCCCCCC';
111
+            $numExample = $this->getNextValue($mysoc,'');
112
+        $mysoc->code_client=$old_code_client;
113
+
114
+        if (! $numExample)
115
+        {
116
+            $numExample = 'NotConfigured';
117
+        }
118
+        return $numExample;
119 119
     }
120 120
 
121
-	/**
122
-	 *  Return next value
123
-	 *
124
-	 *  @param	Societe		$objsoc     		Object third party
125
-	 * 	@param	Propal		$supplier_proposal	Object supplier_proposal
126
-	 *  @return string      					Value if OK, 0 if KO
127
-	 */
128
-	function getNextValue($objsoc,$supplier_proposal)
129
-	{
130
-		global $db,$conf;
131
-
132
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
133
-
134
-		// On defini critere recherche compteur
135
-		$mask=$conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK;
136
-
137
-		if (! $mask)
138
-		{
139
-			$this->error='NotConfigured';
140
-			return 0;
141
-		}
142
-
143
-		$date=$supplier_proposal->datep;
144
-		$customercode=$objsoc->code_client;
145
-		$numFinal=get_next_value($db,$mask,'supplier_proposal','ref','',$customercode,$date);
146
-
147
-		return  $numFinal;
148
-	}
121
+    /**
122
+     *  Return next value
123
+     *
124
+     *  @param	Societe		$objsoc     		Object third party
125
+     * 	@param	Propal		$supplier_proposal	Object supplier_proposal
126
+     *  @return string      					Value if OK, 0 if KO
127
+     */
128
+    function getNextValue($objsoc,$supplier_proposal)
129
+    {
130
+        global $db,$conf;
131
+
132
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
133
+
134
+        // On defini critere recherche compteur
135
+        $mask=$conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK;
136
+
137
+        if (! $mask)
138
+        {
139
+            $this->error='NotConfigured';
140
+            return 0;
141
+        }
142
+
143
+        $date=$supplier_proposal->datep;
144
+        $customercode=$objsoc->code_client;
145
+        $numFinal=get_next_value($db,$mask,'supplier_proposal','ref','',$customercode,$date);
146
+
147
+        return  $numFinal;
148
+    }
149 149
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * \brief      File that contains the numbering module rules Saphir
26 26
  */
27 27
 
28
-require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_proposal/modules_supplier_proposal.php';
28
+require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_proposal/modules_supplier_proposal.php';
29 29
 
30 30
 
31 31
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      * Dolibarr version of the loaded document
38 38
      * @public string
39 39
      */
40
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
40
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
41 41
 
42 42
 	/**
43 43
      * @var string Error code (or message)
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
 	 * @deprecated
50 50
 	 * @see name
51 51
 	 */
52
-	public $nom='Saphir';
52
+	public $nom = 'Saphir';
53 53
 
54 54
 	/**
55 55
 	 * @var string model name
56 56
 	 */
57
-	public $name='Saphir';
57
+	public $name = 'Saphir';
58 58
 
59 59
 
60 60
     /**
@@ -71,28 +71,28 @@  discard block
 block discarded – undo
71 71
 		$form = new Form($this->db);
72 72
 
73 73
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
74
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
77
-		$texte.= '<input type="hidden" name="maskconstsupplier_proposal" value="SUPPLIER_PROPOSAL_SAPHIR_MASK">';
78
-		$texte.= '<table class="nobordernopadding" width="100%">';
79
-
80
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
81
-		$tooltip.=$langs->trans("GenericMaskCodes2");
82
-		$tooltip.=$langs->trans("GenericMaskCodes3");
83
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("CommRequest"),$langs->transnoentities("CommRequest"));
84
-		$tooltip.=$langs->trans("GenericMaskCodes5");
74
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
75
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
76
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
77
+		$texte .= '<input type="hidden" name="maskconstsupplier_proposal" value="SUPPLIER_PROPOSAL_SAPHIR_MASK">';
78
+		$texte .= '<table class="nobordernopadding" width="100%">';
79
+
80
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("CommRequest"), $langs->transnoentities("CommRequest"));
81
+		$tooltip .= $langs->trans("GenericMaskCodes2");
82
+		$tooltip .= $langs->trans("GenericMaskCodes3");
83
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("CommRequest"), $langs->transnoentities("CommRequest"));
84
+		$tooltip .= $langs->trans("GenericMaskCodes5");
85 85
 
86 86
 		// Parametrage du prefix
87
-		$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
88
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplier_proposal" value="'.$conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
87
+		$texte .= '<tr><td>'.$langs->trans("Mask").':</td>';
88
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masksupplier_proposal" value="'.$conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK.'">', $tooltip, 1, 1).'</td>';
89 89
 
90
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
90
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
91 91
 
92
-		$texte.= '</tr>';
92
+		$texte .= '</tr>';
93 93
 
94
-		$texte.= '</table>';
95
-		$texte.= '</form>';
94
+		$texte .= '</table>';
95
+		$texte .= '</form>';
96 96
 
97 97
 		return $texte;
98 98
     }
@@ -104,14 +104,14 @@  discard block
 block discarded – undo
104 104
      */
105 105
     function getExample()
106 106
     {
107
-     	global $conf,$langs,$mysoc;
107
+     	global $conf, $langs, $mysoc;
108 108
 
109
-    	$old_code_client=$mysoc->code_client;
110
-    	$mysoc->code_client='CCCCCCCCCC';
111
-     	$numExample = $this->getNextValue($mysoc,'');
112
-		$mysoc->code_client=$old_code_client;
109
+    	$old_code_client = $mysoc->code_client;
110
+    	$mysoc->code_client = 'CCCCCCCCCC';
111
+     	$numExample = $this->getNextValue($mysoc, '');
112
+		$mysoc->code_client = $old_code_client;
113 113
 
114
-		if (! $numExample)
114
+		if (!$numExample)
115 115
 		{
116 116
 			$numExample = 'NotConfigured';
117 117
 		}
@@ -125,24 +125,24 @@  discard block
 block discarded – undo
125 125
 	 * 	@param	Propal		$supplier_proposal	Object supplier_proposal
126 126
 	 *  @return string      					Value if OK, 0 if KO
127 127
 	 */
128
-	function getNextValue($objsoc,$supplier_proposal)
128
+	function getNextValue($objsoc, $supplier_proposal)
129 129
 	{
130
-		global $db,$conf;
130
+		global $db, $conf;
131 131
 
132
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
132
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
133 133
 
134 134
 		// On defini critere recherche compteur
135
-		$mask=$conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK;
135
+		$mask = $conf->global->SUPPLIER_PROPOSAL_SAPHIR_MASK;
136 136
 
137
-		if (! $mask)
137
+		if (!$mask)
138 138
 		{
139
-			$this->error='NotConfigured';
139
+			$this->error = 'NotConfigured';
140 140
 			return 0;
141 141
 		}
142 142
 
143
-		$date=$supplier_proposal->datep;
144
-		$customercode=$objsoc->code_client;
145
-		$numFinal=get_next_value($db,$mask,'supplier_proposal','ref','',$customercode,$date);
143
+		$date = $supplier_proposal->datep;
144
+		$customercode = $objsoc->code_client;
145
+		$numFinal = get_next_value($db, $mask, 'supplier_proposal', 'ref', '', $customercode, $date);
146 146
 
147 147
 		return  $numFinal;
148 148
 	}
Please login to merge, or discard this patch.
htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php 3 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
  */
37 37
 abstract class ModelePDFSupplierProposal extends CommonDocGenerator
38 38
 {
39
-	/**
40
-	 * @var string Error code (or message)
41
-	 */
42
-	public $error='';
39
+    /**
40
+     * @var string Error code (or message)
41
+     */
42
+    public $error='';
43 43
 
44 44
 
45 45
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
      *  @param	DoliDB	$db     			Database handler
50 50
      *  @param  integer	$maxfilenamelength  Max length of value to show
51 51
      *  @return	array						List of templates
52
-	 */
53
-	static function liste_modeles($db,$maxfilenamelength=0)
54
-	{
52
+     */
53
+    static function liste_modeles($db,$maxfilenamelength=0)
54
+    {
55 55
         // phpcs:enable
56
-		global $conf;
56
+        global $conf;
57 57
 
58
-		$type='supplier_proposal';
59
-		$liste=array();
58
+        $type='supplier_proposal';
59
+        $liste=array();
60 60
 
61
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
62
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
61
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
62
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
63 63
 
64
-		return $liste;
65
-	}
64
+        return $liste;
65
+    }
66 66
 }
67 67
 
68 68
 
@@ -71,83 +71,83 @@  discard block
 block discarded – undo
71 71
  */
72 72
 abstract class ModeleNumRefSupplierProposal
73 73
 {
74
-	/**
75
-	 * @var string Error code (or message)
76
-	 */
77
-	public $error='';
78
-
79
-	/**
80
-	 * Return if a module can be used or not
81
-	 *
82
-	 * @return	boolean     true if module can be used
83
-	 */
84
-	function isEnabled()
85
-	{
86
-		return true;
87
-	}
88
-
89
-	/**
90
-	 *  Renvoi la description par defaut du modele de numerotation
91
-	 *
92
-	 * 	@return     string      Texte descripif
93
-	 */
94
-	function info()
95
-	{
96
-		global $langs;
97
-		$langs->load("supplier_proposal");
98
-		return $langs->trans("NoDescription");
99
-	}
100
-
101
-	/**
102
-	 * 	Renvoi un exemple de numerotation
103
-	 *
104
-	 *  @return     string      Example
105
-	 */
106
-	function getExample()
107
-	{
108
-		global $langs;
109
-		$langs->load("supplier_proposal");
110
-		return $langs->trans("NoExample");
111
-	}
112
-
113
-	/**
114
-	 *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
115
-	 *  de conflits qui empechera cette numerotation de fonctionner.
116
-	 *
117
-	 *  @return     boolean     false si conflit, true si ok
118
-	 */
119
-	function canBeActivated()
120
-	{
121
-		return true;
122
-	}
123
-
124
-	/**
125
-	 * 	Renvoi prochaine valeur attribuee
126
-	 *
127
-	 *	@param		Societe		$objsoc     Object third party
128
-	 *	@param		Propal		$propal		Object commercial proposal
129
-	 *	@return     string      Valeur
130
-	 */
131
-	function getNextValue($objsoc,$propal)
132
-	{
133
-		global $langs;
134
-		return $langs->trans("NotAvailable");
135
-	}
136
-
137
-	/**
138
-	 *  Renvoi version du module numerotation
139
-	 *
140
-	 *  @return     string      Valeur
141
-	 */
142
-	function getVersion()
143
-	{
144
-		global $langs;
145
-		$langs->load("admin");
146
-
147
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
148
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
149
-		if ($this->version == 'dolibarr') return DOL_VERSION;
150
-		if ($this->version) return $this->version;
151
-		return $langs->trans("NotAvailable");
152
-	}
74
+    /**
75
+     * @var string Error code (or message)
76
+     */
77
+    public $error='';
78
+
79
+    /**
80
+     * Return if a module can be used or not
81
+     *
82
+     * @return	boolean     true if module can be used
83
+     */
84
+    function isEnabled()
85
+    {
86
+        return true;
87
+    }
88
+
89
+    /**
90
+     *  Renvoi la description par defaut du modele de numerotation
91
+     *
92
+     * 	@return     string      Texte descripif
93
+     */
94
+    function info()
95
+    {
96
+        global $langs;
97
+        $langs->load("supplier_proposal");
98
+        return $langs->trans("NoDescription");
99
+    }
100
+
101
+    /**
102
+     * 	Renvoi un exemple de numerotation
103
+     *
104
+     *  @return     string      Example
105
+     */
106
+    function getExample()
107
+    {
108
+        global $langs;
109
+        $langs->load("supplier_proposal");
110
+        return $langs->trans("NoExample");
111
+    }
112
+
113
+    /**
114
+     *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
115
+     *  de conflits qui empechera cette numerotation de fonctionner.
116
+     *
117
+     *  @return     boolean     false si conflit, true si ok
118
+     */
119
+    function canBeActivated()
120
+    {
121
+        return true;
122
+    }
123
+
124
+    /**
125
+     * 	Renvoi prochaine valeur attribuee
126
+     *
127
+     *	@param		Societe		$objsoc     Object third party
128
+     *	@param		Propal		$propal		Object commercial proposal
129
+     *	@return     string      Valeur
130
+     */
131
+    function getNextValue($objsoc,$propal)
132
+    {
133
+        global $langs;
134
+        return $langs->trans("NotAvailable");
135
+    }
136
+
137
+    /**
138
+     *  Renvoi version du module numerotation
139
+     *
140
+     *  @return     string      Valeur
141
+     */
142
+    function getVersion()
143
+    {
144
+        global $langs;
145
+        $langs->load("admin");
146
+
147
+        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
148
+        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
149
+        if ($this->version == 'dolibarr') return DOL_VERSION;
150
+        if ($this->version) return $this->version;
151
+        return $langs->trans("NotAvailable");
152
+    }
153 153
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  */
29 29
 
30 30
 require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
31
-require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';   // Requis car utilise dans les classes qui heritent
31
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent
32 32
 
33 33
 
34 34
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * @var string Error code (or message)
41 41
 	 */
42
-	public $error='';
42
+	public $error = '';
43 43
 
44 44
 
45 45
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
      *  @param  integer	$maxfilenamelength  Max length of value to show
51 51
      *  @return	array						List of templates
52 52
 	 */
53
-	static function liste_modeles($db,$maxfilenamelength=0)
53
+	static function liste_modeles($db, $maxfilenamelength = 0)
54 54
 	{
55 55
         // phpcs:enable
56 56
 		global $conf;
57 57
 
58
-		$type='supplier_proposal';
59
-		$liste=array();
58
+		$type = 'supplier_proposal';
59
+		$liste = array();
60 60
 
61 61
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
62
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
62
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
63 63
 
64 64
 		return $liste;
65 65
 	}
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	/**
75 75
 	 * @var string Error code (or message)
76 76
 	 */
77
-	public $error='';
77
+	public $error = '';
78 78
 
79 79
 	/**
80 80
 	 * Return if a module can be used or not
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 *	@param		Propal		$propal		Object commercial proposal
129 129
 	 *	@return     string      Valeur
130 130
 	 */
131
-	function getNextValue($objsoc,$propal)
131
+	function getNextValue($objsoc, $propal)
132 132
 	{
133 133
 		global $langs;
134 134
 		return $langs->trans("NotAvailable");
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -142,10 +142,18 @@
 block discarded – undo
142 142
 		global $langs;
143 143
 		$langs->load("admin");
144 144
 
145
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
146
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
147
-		if ($this->version == 'dolibarr') return DOL_VERSION;
148
-		if ($this->version) return $this->version;
145
+		if ($this->version == 'development') {
146
+		    return $langs->trans("VersionDevelopment");
147
+		}
148
+		if ($this->version == 'experimental') {
149
+		    return $langs->trans("VersionExperimental");
150
+		}
151
+		if ($this->version == 'dolibarr') {
152
+		    return DOL_VERSION;
153
+		}
154
+		if ($this->version) {
155
+		    return $this->version;
156
+		}
149 157
 		return $langs->trans("NotAvailable");
150 158
 	}
151 159
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modSyslog.class.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -32,73 +32,73 @@
 block discarded – undo
32 32
 class modSyslog extends DolibarrModules
33 33
 {
34 34
 
35
-	/**
36
-	 *   Constructor. Define names, constants, directories, boxes, permissions
37
-	 *
38
-	 *   @param      DoliDB		$db      Database handler
39
-	 */
40
-	function __construct($db)
41
-	{
42
-		$this->db = $db;
43
-		$this->numero = 42;
35
+    /**
36
+     *   Constructor. Define names, constants, directories, boxes, permissions
37
+     *
38
+     *   @param      DoliDB		$db      Database handler
39
+     */
40
+    function __construct($db)
41
+    {
42
+        $this->db = $db;
43
+        $this->numero = 42;
44 44
 
45
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
46
-		// It is used to group modules in module setup page
47
-		$this->family = "base";
48
-		// Module position in the family on 2 digits ('01', '10', '20', ...)
49
-		$this->module_position = '50';
50
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
51
-		$this->name = preg_replace('/^mod/i','',get_class($this));
52
-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->description = "Activate debug logs (syslog)";
54
-		// Can be enabled / disabled only in the main company
55
-		$this->core_enabled = 1;
56
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
-		$this->version = 'dolibarr';
58
-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
59
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		// Name of image file used for this module.
61
-		$this->picto='technic';
45
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
46
+        // It is used to group modules in module setup page
47
+        $this->family = "base";
48
+        // Module position in the family on 2 digits ('01', '10', '20', ...)
49
+        $this->module_position = '50';
50
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
51
+        $this->name = preg_replace('/^mod/i','',get_class($this));
52
+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
53
+        $this->description = "Activate debug logs (syslog)";
54
+        // Can be enabled / disabled only in the main company
55
+        $this->core_enabled = 1;
56
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
+        $this->version = 'dolibarr';
58
+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
59
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
+        // Name of image file used for this module.
61
+        $this->picto='technic';
62 62
 
63
-		// Data directories to create when module is enabled
64
-		$this->dirs = array();
63
+        // Data directories to create when module is enabled
64
+        $this->dirs = array();
65 65
 
66
-		// Config pages
67
-		$this->config_page_url = array("syslog.php");
66
+        // Config pages
67
+        $this->config_page_url = array("syslog.php");
68 68
 
69
-		// Dependencies
70
-		$this->hidden = false;			// A condition to hide module
71
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
72
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
73
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
74
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
69
+        // Dependencies
70
+        $this->hidden = false;			// A condition to hide module
71
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
72
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
73
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
74
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
75 75
 
76
-		// Constants
77
-		$this->const = array();
76
+        // Constants
77
+        $this->const = array();
78 78
 
79
-		// Boxes
80
-		$this->boxes = array();
79
+        // Boxes
80
+        $this->boxes = array();
81 81
 
82
-		// Permissions
83
-		$this->rights = array();
84
-		$this->rights_class = 'syslog';
82
+        // Permissions
83
+        $this->rights = array();
84
+        $this->rights_class = 'syslog';
85 85
 
86
-		// Cronjobs
87
-		$this->cronjobs = array(
88
-			0 => array(
89
-				'label' => 'CompressSyslogs',
90
-				'jobtype' => 'method',
91
-				'class' => 'core/class/utils.class.php',
92
-				'objectname' => 'Utils',
93
-				'method' => 'compressSyslogs',
94
-				'parameters' => '',
95
-				'comment' => 'Compress and archive log files. Warning: batch must be run with same account than your web server to avoid to get log files with different owner than required by web server. Another solution is to set web server Operating System group as the group of directory documents and set GROUP permission "rws" on this directory so log files will always have the group and permissions of the web server Operating System group',
96
-				'frequency' => 1,
97
-				'unitfrequency' => 3600 * 24,
98
-				'priority' => 50,
99
-				'status' => 0,
100
-				'test' => true
101
-			)
102
-		);
103
-	}
86
+        // Cronjobs
87
+        $this->cronjobs = array(
88
+            0 => array(
89
+                'label' => 'CompressSyslogs',
90
+                'jobtype' => 'method',
91
+                'class' => 'core/class/utils.class.php',
92
+                'objectname' => 'Utils',
93
+                'method' => 'compressSyslogs',
94
+                'parameters' => '',
95
+                'comment' => 'Compress and archive log files. Warning: batch must be run with same account than your web server to avoid to get log files with different owner than required by web server. Another solution is to set web server Operating System group as the group of directory documents and set GROUP permission "rws" on this directory so log files will always have the group and permissions of the web server Operating System group',
96
+                'frequency' => 1,
97
+                'unitfrequency' => 3600 * 24,
98
+                'priority' => 50,
99
+                'status' => 0,
100
+                'test' => true
101
+            )
102
+        );
103
+    }
104 104
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *	\brief      Fichier de description et activation du module de syslog
25 25
  */
26 26
 
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 /**
30 30
  *	Class to enable/disable module Logs
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		// Module position in the family on 2 digits ('01', '10', '20', ...)
49 49
 		$this->module_position = '50';
50 50
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
51
-		$this->name = preg_replace('/^mod/i','',get_class($this));
51
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
52 52
 		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
53 53
 		$this->description = "Activate debug logs (syslog)";
54 54
 		// Can be enabled / disabled only in the main company
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60 60
 		// Name of image file used for this module.
61
-		$this->picto='technic';
61
+		$this->picto = 'technic';
62 62
 
63 63
 		// Data directories to create when module is enabled
64 64
 		$this->dirs = array();
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 		$this->config_page_url = array("syslog.php");
68 68
 
69 69
 		// Dependencies
70
-		$this->hidden = false;			// A condition to hide module
71
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
72
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
73
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
74
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
70
+		$this->hidden = false; // A condition to hide module
71
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
72
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
73
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
74
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
75 75
 
76 76
 		// Constants
77 77
 		$this->const = array();
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php 3 patches
Indentation   +607 added lines, -607 removed lines patch added patch discarded remove patch
@@ -38,465 +38,465 @@  discard block
 block discarded – undo
38 38
  */
39 39
 class pdf_soleil extends ModelePDFFicheinter
40 40
 {
41
-	 /**
42
-     * @var DoliDb Database handler
43
-     */
41
+        /**
42
+         * @var DoliDb Database handler
43
+         */
44 44
     public $db;
45 45
 
46
-	/**
46
+    /**
47 47
      * @var string model name
48 48
      */
49 49
     public $name;
50 50
 
51
-	/**
51
+    /**
52 52
      * @var string model description (short text)
53 53
      */
54 54
     public $description;
55 55
 
56
-	/**
56
+    /**
57 57
      * @var string document type
58 58
      */
59 59
     public $type;
60 60
 
61 61
     /**
62 62
      * @var array() Minimum version of PHP required by module.
63
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
63
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
64 64
      */
65
-	public $phpmin = array(5, 4);
65
+    public $phpmin = array(5, 4);
66 66
 
67
-	/**
67
+    /**
68 68
      * Dolibarr version of the loaded document
69 69
      * @public string
70 70
      */
71
-	public $version = 'dolibarr';
71
+    public $version = 'dolibarr';
72 72
 
73
-	/**
73
+    /**
74 74
      * @var int page_largeur
75 75
      */
76 76
     public $page_largeur;
77 77
 
78
-	/**
78
+    /**
79 79
      * @var int page_hauteur
80 80
      */
81 81
     public $page_hauteur;
82 82
 
83
-	/**
83
+    /**
84 84
      * @var array format
85 85
      */
86 86
     public $format;
87 87
 
88
-	/**
88
+    /**
89 89
      * @var int marge_gauche
90 90
      */
91
-	public $marge_gauche;
91
+    public $marge_gauche;
92 92
 
93
-	/**
93
+    /**
94 94
      * @var int marge_droite
95 95
      */
96
-	public $marge_droite;
96
+    public $marge_droite;
97 97
 
98
-	/**
98
+    /**
99 99
      * @var int marge_haute
100 100
      */
101
-	public $marge_haute;
101
+    public $marge_haute;
102 102
 
103
-	/**
103
+    /**
104 104
      * @var int marge_basse
105 105
      */
106
-	public $marge_basse;
107
-
108
-	/**
109
-	 * Issuer
110
-	 * @var Company object that emits
111
-	 */
112
-	public $emetteur;
113
-
114
-	/**
115
-	 *	Constructor
116
-	 *
117
-	 *  @param		DoliDB		$db      Database handler
118
-	 */
119
-	function __construct($db)
120
-	{
121
-		global $conf,$langs,$mysoc;
122
-
123
-		$this->db = $db;
124
-		$this->name = 'soleil';
125
-		$this->description = $langs->trans("DocumentModelStandardPDF");
126
-
127
-		// Dimension page pour format A4
128
-		$this->type = 'pdf';
129
-		$formatarray=pdf_getFormat();
130
-		$this->page_largeur = $formatarray['width'];
131
-		$this->page_hauteur = $formatarray['height'];
132
-		$this->format = array($this->page_largeur,$this->page_hauteur);
133
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
134
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
135
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
136
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
137
-
138
-		$this->option_logo = 1;                    // Affiche logo
139
-		$this->option_tva = 0;                     // Gere option tva FACTURE_TVAOPTION
140
-		$this->option_modereg = 0;                 // Affiche mode reglement
141
-		$this->option_condreg = 0;                 // Affiche conditions reglement
142
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
143
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
144
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
145
-
146
-		// Get source company
147
-		$this->emetteur=$mysoc;
148
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if not defined
149
-
150
-		// Define position of columns
151
-		$this->posxdesc=$this->marge_gauche+1;
152
-	}
153
-
154
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
155
-	/**
156
-	 *  Function to build pdf onto disk
157
-	 *
158
-	 *  @param		Object			$object				Object to generate
159
-	 *  @param		Translate		$outputlangs		Lang output object
160
-	 *  @param		string			$srctemplatepath	Full path of source filename for generator using a template file
161
-	 *  @param		int				$hidedetails		Do not show line details
162
-	 *  @param		int				$hidedesc			Do not show desc
163
-	 *  @param		int				$hideref			Do not show ref
164
-	 *  @return		int									1=OK, 0=KO
165
-	 */
166
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
167
-	{
168
-        // phpcs:enable
169
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
106
+    public $marge_basse;
170 107
 
171
-		if (! is_object($outputlangs)) $outputlangs=$langs;
172
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
173
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
108
+    /**
109
+     * Issuer
110
+     * @var Company object that emits
111
+     */
112
+    public $emetteur;
174 113
 
175
-		// Load traductions files requiredby by page
176
-		$outputlangs->loadLangs(array("main", "interventions", "dict", "companies"));
114
+    /**
115
+     *	Constructor
116
+     *
117
+     *  @param		DoliDB		$db      Database handler
118
+     */
119
+    function __construct($db)
120
+    {
121
+        global $conf,$langs,$mysoc;
122
+
123
+        $this->db = $db;
124
+        $this->name = 'soleil';
125
+        $this->description = $langs->trans("DocumentModelStandardPDF");
126
+
127
+        // Dimension page pour format A4
128
+        $this->type = 'pdf';
129
+        $formatarray=pdf_getFormat();
130
+        $this->page_largeur = $formatarray['width'];
131
+        $this->page_hauteur = $formatarray['height'];
132
+        $this->format = array($this->page_largeur,$this->page_hauteur);
133
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
134
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
135
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
136
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
137
+
138
+        $this->option_logo = 1;                    // Affiche logo
139
+        $this->option_tva = 0;                     // Gere option tva FACTURE_TVAOPTION
140
+        $this->option_modereg = 0;                 // Affiche mode reglement
141
+        $this->option_condreg = 0;                 // Affiche conditions reglement
142
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
143
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
144
+        $this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
145
+
146
+        // Get source company
147
+        $this->emetteur=$mysoc;
148
+        if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if not defined
149
+
150
+        // Define position of columns
151
+        $this->posxdesc=$this->marge_gauche+1;
152
+    }
177 153
 
178
-		if ($conf->ficheinter->dir_output)
179
-		{
180
-			$object->fetch_thirdparty();
181
-
182
-		    // Definition of $dir and $file
183
-			if ($object->specimen)
184
-			{
185
-				$dir = $conf->ficheinter->dir_output;
186
-				$file = $dir . "/SPECIMEN.pdf";
187
-			}
188
-			else
189
-			{
190
-				$objectref = dol_sanitizeFileName($object->ref);
191
-				$dir = $conf->ficheinter->dir_output . "/" . $objectref;
192
-				$file = $dir . "/" . $objectref . ".pdf";
193
-			}
194
-
195
-			if (! file_exists($dir))
196
-			{
197
-				if (dol_mkdir($dir) < 0)
198
-				{
199
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
200
-					return 0;
201
-				}
202
-			}
203
-
204
-			if (file_exists($dir))
205
-			{
206
-				// Add pdfgeneration hook
207
-				if (! is_object($hookmanager))
208
-				{
209
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
210
-					$hookmanager=new HookManager($this->db);
211
-				}
212
-
213
-				$hookmanager->initHooks(array('pdfgeneration'));
214
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
215
-				global $action;
216
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
217
-
218
-				$nblignes = count($object->lines);
219
-
220
-				// Create pdf instance
221
-				$pdf=pdf_getInstance($this->format);
222
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
223
-				$heightforinfotot = 50;	// Height reserved to output the info and total part
224
-				$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
225
-				$heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
226
-				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
227
-				$pdf->SetAutoPageBreak(1,0);
228
-
229
-				if (class_exists('TCPDF'))
230
-				{
231
-					$pdf->setPrintHeader(false);
232
-					$pdf->setPrintFooter(false);
233
-				}
234
-				$pdf->SetFont(pdf_getPDFFont($outputlangs));
235
-				// Set path to the background PDF File
236
-				if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
237
-				{
238
-					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
239
-					$tplidx = $pdf->importPage(1);
240
-				}
241
-
242
-				$pdf->Open();
243
-				$pagenb=0;
244
-				$pdf->SetDrawColor(128,128,128);
245
-
246
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
247
-				$pdf->SetSubject($outputlangs->transnoentities("InterventionCard"));
248
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
249
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
250
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("InterventionCard"));
251
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
252
-
253
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
254
-
255
-				// New page
256
-				$pdf->AddPage();
257
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
258
-				$pagenb++;
259
-				$this->_pagehead($pdf, $object, 1, $outputlangs);
260
-				$pdf->SetFont('','', $default_font_size - 1);
261
-				$pdf->SetTextColor(0,0,0);
262
-
263
-				$tab_top = 90;
264
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
265
-				$tab_height = 130;
266
-				$tab_height_newpage = 150;
267
-
268
-				// Affiche notes
269
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
270
-				if ($notetoshow)
271
-				{
272
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
273
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
274
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
275
-
276
-					$tab_top = 88;
277
-
278
-					$pdf->SetFont('','', $default_font_size - 1);
279
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
280
-					$nexY = $pdf->GetY();
281
-					$height_note=$nexY-$tab_top;
282
-
283
-					// Rect prend une longueur en 3eme param
284
-					$pdf->SetDrawColor(192,192,192);
285
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
286
-
287
-					$tab_height = $tab_height - $height_note;
288
-					$tab_top = $nexY+6;
289
-				}
290
-				else
291
-				{
292
-					$height_note=0;
293
-				}
294
-
295
-				$iniY = $tab_top + 7;
296
-				$curY = $tab_top + 7;
297
-				$nexY = $tab_top + 7;
298
-
299
-				$pdf->SetXY($this->marge_gauche, $tab_top);
300
-				$pdf->MultiCell(190,5,$outputlangs->transnoentities("Description"),0,'L',0);
301
-				$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur-$this->marge_droite, $tab_top + 5);
302
-
303
-				$pdf->SetFont('', '', $default_font_size - 1);
304
-
305
-				$pdf->SetXY($this->marge_gauche, $tab_top + 5);
306
-				$text=$object->description;
307
-				if ($object->duration > 0)
308
-				{
309
-				    $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
310
-				    $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
311
-				}
312
-				$desc=dol_htmlentitiesbr($text,1);
313
-				//print $outputlangs->convToOutputCharset($desc); exit;
314
-
315
-				$pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
316
-				$nexY = $pdf->GetY();
317
-
318
-				$pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
319
-
320
-				$nblines = count($object->lines);
321
-
322
-				// Loop on each lines
323
-				for ($i = 0; $i < $nblines; $i++)
324
-				{
325
-					$objectligne = $object->lines[$i];
326
-
327
-					$valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id);
328
-					if ($valide > 0 || $object->specimen)
329
-					{
330
-						$curY = $nexY;
331
-						$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
332
-						$pdf->SetTextColor(0,0,0);
333
-
334
-						$pdf->setTopMargin($tab_top_newpage);
335
-						$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
336
-						$pageposbefore=$pdf->getPage();
337
-
338
-						// Description of product line
339
-						$curX = $this->posxdesc-1;
340
-
341
-						// Description of product line
154
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
155
+    /**
156
+     *  Function to build pdf onto disk
157
+     *
158
+     *  @param		Object			$object				Object to generate
159
+     *  @param		Translate		$outputlangs		Lang output object
160
+     *  @param		string			$srctemplatepath	Full path of source filename for generator using a template file
161
+     *  @param		int				$hidedetails		Do not show line details
162
+     *  @param		int				$hidedesc			Do not show desc
163
+     *  @param		int				$hideref			Do not show ref
164
+     *  @return		int									1=OK, 0=KO
165
+     */
166
+    function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
167
+    {
168
+        // phpcs:enable
169
+        global $user,$langs,$conf,$mysoc,$db,$hookmanager;
170
+
171
+        if (! is_object($outputlangs)) $outputlangs=$langs;
172
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
173
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
174
+
175
+        // Load traductions files requiredby by page
176
+        $outputlangs->loadLangs(array("main", "interventions", "dict", "companies"));
177
+
178
+        if ($conf->ficheinter->dir_output)
179
+        {
180
+            $object->fetch_thirdparty();
181
+
182
+            // Definition of $dir and $file
183
+            if ($object->specimen)
184
+            {
185
+                $dir = $conf->ficheinter->dir_output;
186
+                $file = $dir . "/SPECIMEN.pdf";
187
+            }
188
+            else
189
+            {
190
+                $objectref = dol_sanitizeFileName($object->ref);
191
+                $dir = $conf->ficheinter->dir_output . "/" . $objectref;
192
+                $file = $dir . "/" . $objectref . ".pdf";
193
+            }
194
+
195
+            if (! file_exists($dir))
196
+            {
197
+                if (dol_mkdir($dir) < 0)
198
+                {
199
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
200
+                    return 0;
201
+                }
202
+            }
203
+
204
+            if (file_exists($dir))
205
+            {
206
+                // Add pdfgeneration hook
207
+                if (! is_object($hookmanager))
208
+                {
209
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
210
+                    $hookmanager=new HookManager($this->db);
211
+                }
212
+
213
+                $hookmanager->initHooks(array('pdfgeneration'));
214
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
215
+                global $action;
216
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
217
+
218
+                $nblignes = count($object->lines);
219
+
220
+                // Create pdf instance
221
+                $pdf=pdf_getInstance($this->format);
222
+                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
223
+                $heightforinfotot = 50;	// Height reserved to output the info and total part
224
+                $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
225
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
226
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
227
+                $pdf->SetAutoPageBreak(1,0);
228
+
229
+                if (class_exists('TCPDF'))
230
+                {
231
+                    $pdf->setPrintHeader(false);
232
+                    $pdf->setPrintFooter(false);
233
+                }
234
+                $pdf->SetFont(pdf_getPDFFont($outputlangs));
235
+                // Set path to the background PDF File
236
+                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
237
+                {
238
+                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
239
+                    $tplidx = $pdf->importPage(1);
240
+                }
241
+
242
+                $pdf->Open();
243
+                $pagenb=0;
244
+                $pdf->SetDrawColor(128,128,128);
245
+
246
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
247
+                $pdf->SetSubject($outputlangs->transnoentities("InterventionCard"));
248
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
249
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
250
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("InterventionCard"));
251
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
252
+
253
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
254
+
255
+                // New page
256
+                $pdf->AddPage();
257
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
258
+                $pagenb++;
259
+                $this->_pagehead($pdf, $object, 1, $outputlangs);
260
+                $pdf->SetFont('','', $default_font_size - 1);
261
+                $pdf->SetTextColor(0,0,0);
262
+
263
+                $tab_top = 90;
264
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
265
+                $tab_height = 130;
266
+                $tab_height_newpage = 150;
267
+
268
+                // Affiche notes
269
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
270
+                if ($notetoshow)
271
+                {
272
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
273
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
274
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
275
+
276
+                    $tab_top = 88;
277
+
278
+                    $pdf->SetFont('','', $default_font_size - 1);
279
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
280
+                    $nexY = $pdf->GetY();
281
+                    $height_note=$nexY-$tab_top;
282
+
283
+                    // Rect prend une longueur en 3eme param
284
+                    $pdf->SetDrawColor(192,192,192);
285
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
286
+
287
+                    $tab_height = $tab_height - $height_note;
288
+                    $tab_top = $nexY+6;
289
+                }
290
+                else
291
+                {
292
+                    $height_note=0;
293
+                }
294
+
295
+                $iniY = $tab_top + 7;
296
+                $curY = $tab_top + 7;
297
+                $nexY = $tab_top + 7;
298
+
299
+                $pdf->SetXY($this->marge_gauche, $tab_top);
300
+                $pdf->MultiCell(190,5,$outputlangs->transnoentities("Description"),0,'L',0);
301
+                $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur-$this->marge_droite, $tab_top + 5);
302
+
303
+                $pdf->SetFont('', '', $default_font_size - 1);
304
+
305
+                $pdf->SetXY($this->marge_gauche, $tab_top + 5);
306
+                $text=$object->description;
307
+                if ($object->duration > 0)
308
+                {
309
+                    $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
310
+                    $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
311
+                }
312
+                $desc=dol_htmlentitiesbr($text,1);
313
+                //print $outputlangs->convToOutputCharset($desc); exit;
314
+
315
+                $pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
316
+                $nexY = $pdf->GetY();
317
+
318
+                $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
319
+
320
+                $nblines = count($object->lines);
321
+
322
+                // Loop on each lines
323
+                for ($i = 0; $i < $nblines; $i++)
324
+                {
325
+                    $objectligne = $object->lines[$i];
326
+
327
+                    $valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id);
328
+                    if ($valide > 0 || $object->specimen)
329
+                    {
330
+                        $curY = $nexY;
331
+                        $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
332
+                        $pdf->SetTextColor(0,0,0);
333
+
334
+                        $pdf->setTopMargin($tab_top_newpage);
335
+                        $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
336
+                        $pageposbefore=$pdf->getPage();
337
+
338
+                        // Description of product line
339
+                        $curX = $this->posxdesc-1;
340
+
341
+                        // Description of product line
342 342
                                                 if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR))
343 343
                                                 {
344
-						        $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true);
344
+                                $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true);
345 345
                                                 }
346 346
                                                 else
347 347
                                                 {
348 348
                                                         $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'day',false,$outputlangs,true);
349 349
                                                 }
350 350
 
351
-						if ($objectligne->duration > 0)
352
-						{
353
-							$txt.=" - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration);
354
-						}
355
-						$txt='<strong>'.dol_htmlentitiesbr($txt,1,$outputlangs->charset_output).'</strong>';
356
-						$desc=dol_htmlentitiesbr($objectligne->desc,1);
357
-
358
-						$pdf->startTransaction();
359
-						$pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt,$desc), 0, 1, 0);
360
-						$pageposafter=$pdf->getPage();
361
-						if ($pageposafter > $pageposbefore)	// There is a pagebreak
362
-						{
363
-							$pdf->rollbackTransaction(true);
364
-							$pageposafter=$pageposbefore;
365
-							//print $pageposafter.'-'.$pageposbefore;exit;
366
-							$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
367
-							$pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0);
368
-							$pageposafter=$pdf->getPage();
369
-							$posyafter=$pdf->GetY();
370
-							//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
371
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
372
-							{
373
-								if ($i == ($nblines-1))	// No more lines, and no space left to show total, so we create a new page
374
-								{
375
-									$pdf->AddPage('','',true);
376
-									if (! empty($tplidx)) $pdf->useTemplate($tplidx);
377
-									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
378
-									$pdf->setPage($pageposafter+1);
379
-								}
380
-							}
381
-						}
382
-						else	// No pagebreak
383
-						{
384
-							$pdf->commitTransaction();
385
-						}
386
-
387
-						$nexY = $pdf->GetY();
388
-						$pageposafter=$pdf->getPage();
389
-						$pdf->setPage($pageposbefore);
390
-						$pdf->setTopMargin($this->marge_haute);
391
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
392
-
393
-						// We suppose that a too long description is moved completely on next page
394
-						if ($pageposafter > $pageposbefore) {
395
-							$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
396
-						}
397
-
398
-						$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
399
-
400
-						// Detect if some page were added automatically and output _tableau for past pages
401
-						while ($pagenb < $pageposafter)
402
-						{
403
-							$pdf->setPage($pagenb);
404
-							if ($pagenb == 1)
405
-							{
406
-								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
407
-							}
408
-							else
409
-							{
410
-								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
411
-							}
412
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
413
-							$pagenb++;
414
-							$pdf->setPage($pagenb);
415
-							$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
416
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
417
-						}
418
-						if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
419
-						{
420
-							if ($pagenb == 1)
421
-							{
422
-								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
423
-							}
424
-							else
425
-							{
426
-								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
427
-							}
428
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
429
-							// New page
430
-							$pdf->AddPage();
431
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
432
-							$pagenb++;
433
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
434
-						}
435
-					}
436
-				}
437
-
438
-				// Show square
439
-				if ($pagenb == 1)
440
-				{
441
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
442
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
443
-				}
444
-				else
445
-				{
446
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
447
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
448
-				}
449
-
450
-				$this->_pagefoot($pdf,$object,$outputlangs);
451
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
452
-
453
-				$pdf->Close();
454
-				$pdf->Output($file,'F');
455
-
456
-				// Add pdfgeneration hook
457
-				$hookmanager->initHooks(array('pdfgeneration'));
458
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
459
-				global $action;
460
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
461
-
462
-				if (! empty($conf->global->MAIN_UMASK))
463
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
464
-
465
-				$this->result = array('fullpath'=>$file);
466
-
467
-				return 1;
468
-			}
469
-			else
470
-			{
471
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
472
-				return 0;
473
-			}
474
-		}
475
-		else
476
-		{
477
-			$this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR");
478
-			return 0;
479
-		}
480
-	}
481
-
482
-	/**
483
-	 *   Show table for lines
484
-	 *
485
-	 *   @param		PDF			$pdf     		Object PDF
486
-	 *   @param		string		$tab_top		Top position of table
487
-	 *   @param		string		$tab_height		Height of table (rectangle)
488
-	 *   @param		int			$nexY			Y
489
-	 *   @param		Translate	$outputlangs	Langs object
490
-	 *   @param		int			$hidetop		Hide top bar of array
491
-	 *   @param		int			$hidebottom		Hide bottom bar of array
492
-	 *   @return	void
493
-	 */
494
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
495
-	{
496
-		global $conf;
497
-
498
-
499
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
351
+                        if ($objectligne->duration > 0)
352
+                        {
353
+                            $txt.=" - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration);
354
+                        }
355
+                        $txt='<strong>'.dol_htmlentitiesbr($txt,1,$outputlangs->charset_output).'</strong>';
356
+                        $desc=dol_htmlentitiesbr($objectligne->desc,1);
357
+
358
+                        $pdf->startTransaction();
359
+                        $pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt,$desc), 0, 1, 0);
360
+                        $pageposafter=$pdf->getPage();
361
+                        if ($pageposafter > $pageposbefore)	// There is a pagebreak
362
+                        {
363
+                            $pdf->rollbackTransaction(true);
364
+                            $pageposafter=$pageposbefore;
365
+                            //print $pageposafter.'-'.$pageposbefore;exit;
366
+                            $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
367
+                            $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0);
368
+                            $pageposafter=$pdf->getPage();
369
+                            $posyafter=$pdf->GetY();
370
+                            //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
371
+                            if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
372
+                            {
373
+                                if ($i == ($nblines-1))	// No more lines, and no space left to show total, so we create a new page
374
+                                {
375
+                                    $pdf->AddPage('','',true);
376
+                                    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
377
+                                    if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
378
+                                    $pdf->setPage($pageposafter+1);
379
+                                }
380
+                            }
381
+                        }
382
+                        else	// No pagebreak
383
+                        {
384
+                            $pdf->commitTransaction();
385
+                        }
386
+
387
+                        $nexY = $pdf->GetY();
388
+                        $pageposafter=$pdf->getPage();
389
+                        $pdf->setPage($pageposbefore);
390
+                        $pdf->setTopMargin($this->marge_haute);
391
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
392
+
393
+                        // We suppose that a too long description is moved completely on next page
394
+                        if ($pageposafter > $pageposbefore) {
395
+                            $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
396
+                        }
397
+
398
+                        $pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
399
+
400
+                        // Detect if some page were added automatically and output _tableau for past pages
401
+                        while ($pagenb < $pageposafter)
402
+                        {
403
+                            $pdf->setPage($pagenb);
404
+                            if ($pagenb == 1)
405
+                            {
406
+                                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
407
+                            }
408
+                            else
409
+                            {
410
+                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
411
+                            }
412
+                            $this->_pagefoot($pdf,$object,$outputlangs,1);
413
+                            $pagenb++;
414
+                            $pdf->setPage($pagenb);
415
+                            $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
416
+                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
417
+                        }
418
+                        if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
419
+                        {
420
+                            if ($pagenb == 1)
421
+                            {
422
+                                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
423
+                            }
424
+                            else
425
+                            {
426
+                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
427
+                            }
428
+                            $this->_pagefoot($pdf,$object,$outputlangs,1);
429
+                            // New page
430
+                            $pdf->AddPage();
431
+                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
432
+                            $pagenb++;
433
+                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
434
+                        }
435
+                    }
436
+                }
437
+
438
+                // Show square
439
+                if ($pagenb == 1)
440
+                {
441
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
442
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
443
+                }
444
+                else
445
+                {
446
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
447
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
448
+                }
449
+
450
+                $this->_pagefoot($pdf,$object,$outputlangs);
451
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
452
+
453
+                $pdf->Close();
454
+                $pdf->Output($file,'F');
455
+
456
+                // Add pdfgeneration hook
457
+                $hookmanager->initHooks(array('pdfgeneration'));
458
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
459
+                global $action;
460
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
461
+
462
+                if (! empty($conf->global->MAIN_UMASK))
463
+                @chmod($file, octdec($conf->global->MAIN_UMASK));
464
+
465
+                $this->result = array('fullpath'=>$file);
466
+
467
+                return 1;
468
+            }
469
+            else
470
+            {
471
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
472
+                return 0;
473
+            }
474
+        }
475
+        else
476
+        {
477
+            $this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR");
478
+            return 0;
479
+        }
480
+    }
481
+
482
+    /**
483
+     *   Show table for lines
484
+     *
485
+     *   @param		PDF			$pdf     		Object PDF
486
+     *   @param		string		$tab_top		Top position of table
487
+     *   @param		string		$tab_height		Height of table (rectangle)
488
+     *   @param		int			$nexY			Y
489
+     *   @param		Translate	$outputlangs	Langs object
490
+     *   @param		int			$hidetop		Hide top bar of array
491
+     *   @param		int			$hidebottom		Hide bottom bar of array
492
+     *   @return	void
493
+     */
494
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
495
+    {
496
+        global $conf;
497
+
498
+
499
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
500 500
 /*
501 501
 		$pdf->SetXY($this->marge_gauche, $tab_top);
502 502
 		$pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
@@ -523,214 +523,214 @@  discard block
 block discarded – undo
523 523
 		$pdf->MultiCell(0, 3, '');		// Set interline to 3. Then writeMultiCell must use 3 also.
524 524
 */
525 525
 
526
-		// Output Rect
527
-		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+1, 0, 0);	// Rect prend une longueur en 3eme param et 4eme param
528
-
529
-		if (empty($hidebottom))
530
-		{
531
-			$pdf->SetXY(20,230);
532
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0);
533
-
534
-			$pdf->SetXY(20,235);
535
-			$pdf->MultiCell(80,25, '', 1);
536
-
537
-			$pdf->SetXY(110,230);
538
-			$pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0);
539
-
540
-			$pdf->SetXY(110,235);
541
-			$pdf->MultiCell(80,25, '', 1);
542
-		}
543
-	}
544
-
545
-	/**
546
-	 *  Show top header of page.
547
-	 *
548
-	 *  @param	PDF			$pdf     		Object PDF
549
-	 *  @param  Object		$object     	Object to show
550
-	 *  @param  int	    	$showaddress    0=no, 1=yes
551
-	 *  @param  Translate	$outputlangs	Object lang for output
552
-	 *  @return	void
553
-	 */
554
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
555
-	{
556
-		global $conf,$langs;
557
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
558
-
559
-		// Load traductions files requiredby by page
560
-		$outputlangs->loadLangs(array("main", "dict", "companies", "interventions"));
561
-
562
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
563
-
564
-		//Affiche le filigrane brouillon - Print Draft Watermark
565
-		if($object->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) )
566
-		{
567
-			pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FICHINTER_DRAFT_WATERMARK);
568
-		}
569
-
570
-		//Prepare la suite
571
-		$pdf->SetTextColor(0,0,60);
572
-		$pdf->SetFont('','B', $default_font_size + 3);
573
-
574
-		$posx=$this->page_largeur-$this->marge_droite-100;
575
-		$posy=$this->marge_haute;
576
-
577
-		$pdf->SetXY($this->marge_gauche,$posy);
526
+        // Output Rect
527
+        $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+1, 0, 0);	// Rect prend une longueur en 3eme param et 4eme param
578 528
 
579
-		// Logo
580
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
581
-		if ($this->emetteur->logo)
582
-		{
583
-			if (is_readable($logo))
584
-			{
585
-			    $height=pdf_getHeightForLogo($logo);
586
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
587
-			}
588
-			else
589
-			{
590
-				$pdf->SetTextColor(200,0,0);
591
-				$pdf->SetFont('','B',$default_font_size - 2);
592
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
593
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
594
-			}
595
-		}
596
-		else
597
-		{
598
-			$text=$this->emetteur->name;
599
-			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
600
-		}
529
+        if (empty($hidebottom))
530
+        {
531
+            $pdf->SetXY(20,230);
532
+            $pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0);
601 533
 
602
-		$pdf->SetFont('','B',$default_font_size + 3);
603
-		$pdf->SetXY($posx,$posy);
604
-		$pdf->SetTextColor(0,0,60);
605
-		$title=$outputlangs->transnoentities("InterventionCard");
606
-		$pdf->MultiCell(100, 4, $title, '', 'R');
534
+            $pdf->SetXY(20,235);
535
+            $pdf->MultiCell(80,25, '', 1);
607 536
 
608
-		$pdf->SetFont('','B',$default_font_size + 2);
537
+            $pdf->SetXY(110,230);
538
+            $pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0);
609 539
 
610
-		$posy+=5;
611
-		$pdf->SetXY($posx,$posy);
612
-		$pdf->SetTextColor(0,0,60);
613
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
540
+            $pdf->SetXY(110,235);
541
+            $pdf->MultiCell(80,25, '', 1);
542
+        }
543
+    }
614 544
 
615
-		$posy+=1;
616
-		$pdf->SetFont('','', $default_font_size);
617
-
618
-		$posy+=4;
619
-		$pdf->SetXY($posx,$posy);
620
-		$pdf->SetTextColor(0,0,60);
621
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->datec,"day",false,$outputlangs,true), '', 'R');
622
-
623
-		if ($object->thirdparty->code_client)
624
-		{
625
-			$posy+=4;
626
-			$pdf->SetXY($posx,$posy);
627
-			$pdf->SetTextColor(0,0,60);
628
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
629
-		}
545
+    /**
546
+     *  Show top header of page.
547
+     *
548
+     *  @param	PDF			$pdf     		Object PDF
549
+     *  @param  Object		$object     	Object to show
550
+     *  @param  int	    	$showaddress    0=no, 1=yes
551
+     *  @param  Translate	$outputlangs	Object lang for output
552
+     *  @return	void
553
+     */
554
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
555
+    {
556
+        global $conf,$langs;
557
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
558
+
559
+        // Load traductions files requiredby by page
560
+        $outputlangs->loadLangs(array("main", "dict", "companies", "interventions"));
561
+
562
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
563
+
564
+        //Affiche le filigrane brouillon - Print Draft Watermark
565
+        if($object->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) )
566
+        {
567
+            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FICHINTER_DRAFT_WATERMARK);
568
+        }
569
+
570
+        //Prepare la suite
571
+        $pdf->SetTextColor(0,0,60);
572
+        $pdf->SetFont('','B', $default_font_size + 3);
573
+
574
+        $posx=$this->page_largeur-$this->marge_droite-100;
575
+        $posy=$this->marge_haute;
576
+
577
+        $pdf->SetXY($this->marge_gauche,$posy);
578
+
579
+        // Logo
580
+        $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
581
+        if ($this->emetteur->logo)
582
+        {
583
+            if (is_readable($logo))
584
+            {
585
+                $height=pdf_getHeightForLogo($logo);
586
+                $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
587
+            }
588
+            else
589
+            {
590
+                $pdf->SetTextColor(200,0,0);
591
+                $pdf->SetFont('','B',$default_font_size - 2);
592
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
593
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
594
+            }
595
+        }
596
+        else
597
+        {
598
+            $text=$this->emetteur->name;
599
+            $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
600
+        }
601
+
602
+        $pdf->SetFont('','B',$default_font_size + 3);
603
+        $pdf->SetXY($posx,$posy);
604
+        $pdf->SetTextColor(0,0,60);
605
+        $title=$outputlangs->transnoentities("InterventionCard");
606
+        $pdf->MultiCell(100, 4, $title, '', 'R');
607
+
608
+        $pdf->SetFont('','B',$default_font_size + 2);
609
+
610
+        $posy+=5;
611
+        $pdf->SetXY($posx,$posy);
612
+        $pdf->SetTextColor(0,0,60);
613
+        $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
614
+
615
+        $posy+=1;
616
+        $pdf->SetFont('','', $default_font_size);
617
+
618
+        $posy+=4;
619
+        $pdf->SetXY($posx,$posy);
620
+        $pdf->SetTextColor(0,0,60);
621
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->datec,"day",false,$outputlangs,true), '', 'R');
622
+
623
+        if ($object->thirdparty->code_client)
624
+        {
625
+            $posy+=4;
626
+            $pdf->SetXY($posx,$posy);
627
+            $pdf->SetTextColor(0,0,60);
628
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
629
+        }
630
+
631
+        if ($showaddress)
632
+        {
633
+            // Sender properties
634
+            $carac_emetteur='';
635
+            // Add internal contact of proposal if defined
636
+            $arrayidcontact=$object->getIdContact('internal','INTERREPFOLL');
637
+            if (count($arrayidcontact) > 0)
638
+            {
639
+                $object->fetch_user($arrayidcontact[0]);
640
+                $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
641
+            }
642
+
643
+            $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
644
+
645
+            // Show sender
646
+            $posy=42;
647
+            $posx=$this->marge_gauche;
648
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
649
+            $hautcadre=40;
650
+
651
+            // Show sender frame
652
+            $pdf->SetTextColor(0,0,0);
653
+            $pdf->SetFont('','', $default_font_size - 2);
654
+            $pdf->SetXY($posx,$posy-5);
655
+            $pdf->SetXY($posx,$posy);
656
+            $pdf->SetFillColor(230,230,230);
657
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
658
+
659
+            // Show sender name
660
+            $pdf->SetXY($posx+2,$posy+3);
661
+            $pdf->SetTextColor(0,0,60);
662
+            $pdf->SetFont('','B',$default_font_size);
663
+            $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
664
+            $posy=$pdf->getY();
665
+
666
+            // Show sender information
667
+            $pdf->SetFont('','', $default_font_size - 1);
668
+            $pdf->SetXY($posx+2,$posy);
669
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
670
+
671
+
672
+            // If CUSTOMER contact defined, we use it
673
+            $usecontact=false;
674
+            $arrayidcontact=$object->getIdContact('external','CUSTOMER');
675
+            if (count($arrayidcontact) > 0)
676
+            {
677
+                $usecontact=true;
678
+                $result=$object->fetch_contact($arrayidcontact[0]);
679
+            }
680
+
681
+            //Recipient name
682
+            // On peut utiliser le nom de la societe du contact
683
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
684
+                $thirdparty = $object->contact;
685
+            } else {
686
+                $thirdparty = $object->thirdparty;
687
+            }
688
+
689
+            $carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
690
+
691
+            $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target',$object);
692
+
693
+            // Show recipient
694
+            $widthrecbox=100;
695
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
696
+            $posy=42;
697
+            $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
698
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
699
+
700
+            // Show recipient frame
701
+            $pdf->SetTextColor(0,0,0);
702
+            $pdf->SetFont('','', $default_font_size - 2);
703
+            $pdf->SetXY($posx+2,$posy-5);
704
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
705
+            $pdf->SetTextColor(0,0,0);
706
+
707
+            // Show recipient name
708
+            $pdf->SetXY($posx+2,$posy+3);
709
+            $pdf->SetFont('','B', $default_font_size);
710
+            $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
711
+
712
+            $posy = $pdf->getY();
713
+
714
+            // Show recipient information
715
+            $pdf->SetFont('','', $default_font_size - 1);
716
+            $pdf->SetXY($posx+2,$posy);
717
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
718
+        }
719
+    }
630 720
 
631
-		if ($showaddress)
632
-		{
633
-			// Sender properties
634
-			$carac_emetteur='';
635
-			// Add internal contact of proposal if defined
636
-			$arrayidcontact=$object->getIdContact('internal','INTERREPFOLL');
637
-			if (count($arrayidcontact) > 0)
638
-			{
639
-				$object->fetch_user($arrayidcontact[0]);
640
-				$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
641
-			}
642
-
643
-			$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
644
-
645
-			// Show sender
646
-			$posy=42;
647
-			$posx=$this->marge_gauche;
648
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
649
-			$hautcadre=40;
650
-
651
-			// Show sender frame
652
-			$pdf->SetTextColor(0,0,0);
653
-			$pdf->SetFont('','', $default_font_size - 2);
654
-			$pdf->SetXY($posx,$posy-5);
655
-			$pdf->SetXY($posx,$posy);
656
-			$pdf->SetFillColor(230,230,230);
657
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
658
-
659
-			// Show sender name
660
-			$pdf->SetXY($posx+2,$posy+3);
661
-			$pdf->SetTextColor(0,0,60);
662
-			$pdf->SetFont('','B',$default_font_size);
663
-			$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
664
-			$posy=$pdf->getY();
665
-
666
-			// Show sender information
667
-			$pdf->SetFont('','', $default_font_size - 1);
668
-			$pdf->SetXY($posx+2,$posy);
669
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
670
-
671
-
672
-			// If CUSTOMER contact defined, we use it
673
-			$usecontact=false;
674
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
675
-			if (count($arrayidcontact) > 0)
676
-			{
677
-				$usecontact=true;
678
-				$result=$object->fetch_contact($arrayidcontact[0]);
679
-			}
680
-
681
-			//Recipient name
682
-			// On peut utiliser le nom de la societe du contact
683
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
684
-				$thirdparty = $object->contact;
685
-			} else {
686
-				$thirdparty = $object->thirdparty;
687
-			}
688
-
689
-			$carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
690
-
691
-			$carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target',$object);
692
-
693
-			// Show recipient
694
-			$widthrecbox=100;
695
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
696
-			$posy=42;
697
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
698
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
699
-
700
-			// Show recipient frame
701
-			$pdf->SetTextColor(0,0,0);
702
-			$pdf->SetFont('','', $default_font_size - 2);
703
-			$pdf->SetXY($posx+2,$posy-5);
704
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
705
-			$pdf->SetTextColor(0,0,0);
706
-
707
-			// Show recipient name
708
-			$pdf->SetXY($posx+2,$posy+3);
709
-			$pdf->SetFont('','B', $default_font_size);
710
-			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
711
-
712
-			$posy = $pdf->getY();
713
-
714
-			// Show recipient information
715
-			$pdf->SetFont('','', $default_font_size - 1);
716
-			$pdf->SetXY($posx+2,$posy);
717
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
718
-		}
719
-	}
720
-
721
-	/**
722
-	 *   	Show footer of page. Need this->emetteur object
723
-	 *
724
-	 *   	@param	PDF			$pdf     			PDF
725
-	 * 		@param	Object		$object				Object to show
726
-	 *      @param	Translate	$outputlangs		Object lang for output
727
-	 *      @param	int			$hidefreetext		1=Hide free text
728
-	 *      @return	integer
729
-	 */
730
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
731
-	{
732
-		global $conf;
733
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
734
-		return pdf_pagefoot($pdf,$outputlangs,'FICHINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
735
-	}
721
+    /**
722
+     *   	Show footer of page. Need this->emetteur object
723
+     *
724
+     *   	@param	PDF			$pdf     			PDF
725
+     * 		@param	Object		$object				Object to show
726
+     *      @param	Translate	$outputlangs		Object lang for output
727
+     *      @param	int			$hidefreetext		1=Hide free text
728
+     *      @return	integer
729
+     */
730
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
731
+    {
732
+        global $conf;
733
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
734
+        return pdf_pagefoot($pdf,$outputlangs,'FICHINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
735
+    }
736 736
 }
Please login to merge, or discard this patch.
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	function __construct($db)
120 120
 	{
121
-		global $conf,$langs,$mysoc;
121
+		global $conf, $langs, $mysoc;
122 122
 
123 123
 		$this->db = $db;
124 124
 		$this->name = 'soleil';
@@ -126,29 +126,29 @@  discard block
 block discarded – undo
126 126
 
127 127
 		// Dimension page pour format A4
128 128
 		$this->type = 'pdf';
129
-		$formatarray=pdf_getFormat();
129
+		$formatarray = pdf_getFormat();
130 130
 		$this->page_largeur = $formatarray['width'];
131 131
 		$this->page_hauteur = $formatarray['height'];
132
-		$this->format = array($this->page_largeur,$this->page_hauteur);
133
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
134
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
135
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
136
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
137
-
138
-		$this->option_logo = 1;                    // Affiche logo
139
-		$this->option_tva = 0;                     // Gere option tva FACTURE_TVAOPTION
140
-		$this->option_modereg = 0;                 // Affiche mode reglement
141
-		$this->option_condreg = 0;                 // Affiche conditions reglement
142
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
143
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
144
-		$this->option_draft_watermark = 1;		   //Support add of a watermark on drafts
132
+		$this->format = array($this->page_largeur, $this->page_hauteur);
133
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
134
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
135
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
136
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
137
+
138
+		$this->option_logo = 1; // Affiche logo
139
+		$this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION
140
+		$this->option_modereg = 0; // Affiche mode reglement
141
+		$this->option_condreg = 0; // Affiche conditions reglement
142
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
143
+		$this->option_multilang = 1; // Dispo en plusieurs langues
144
+		$this->option_draft_watermark = 1; //Support add of a watermark on drafts
145 145
 
146 146
 		// Get source company
147
-		$this->emetteur=$mysoc;
148
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if not defined
147
+		$this->emetteur = $mysoc;
148
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if not defined
149 149
 
150 150
 		// Define position of columns
151
-		$this->posxdesc=$this->marge_gauche+1;
151
+		$this->posxdesc = $this->marge_gauche + 1;
152 152
 	}
153 153
 
154 154
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 	 *  @param		int				$hideref			Do not show ref
164 164
 	 *  @return		int									1=OK, 0=KO
165 165
 	 */
166
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
166
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
167 167
 	{
168 168
         // phpcs:enable
169
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
169
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
170 170
 
171
-		if (! is_object($outputlangs)) $outputlangs=$langs;
171
+		if (!is_object($outputlangs)) $outputlangs = $langs;
172 172
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
173
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
173
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
174 174
 
175 175
 		// Load traductions files requiredby by page
176 176
 		$outputlangs->loadLangs(array("main", "interventions", "dict", "companies"));
@@ -183,20 +183,20 @@  discard block
 block discarded – undo
183 183
 			if ($object->specimen)
184 184
 			{
185 185
 				$dir = $conf->ficheinter->dir_output;
186
-				$file = $dir . "/SPECIMEN.pdf";
186
+				$file = $dir."/SPECIMEN.pdf";
187 187
 			}
188 188
 			else
189 189
 			{
190 190
 				$objectref = dol_sanitizeFileName($object->ref);
191
-				$dir = $conf->ficheinter->dir_output . "/" . $objectref;
192
-				$file = $dir . "/" . $objectref . ".pdf";
191
+				$dir = $conf->ficheinter->dir_output."/".$objectref;
192
+				$file = $dir."/".$objectref.".pdf";
193 193
 			}
194 194
 
195
-			if (! file_exists($dir))
195
+			if (!file_exists($dir))
196 196
 			{
197 197
 				if (dol_mkdir($dir) < 0)
198 198
 				{
199
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
199
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
200 200
 					return 0;
201 201
 				}
202 202
 			}
@@ -204,27 +204,27 @@  discard block
 block discarded – undo
204 204
 			if (file_exists($dir))
205 205
 			{
206 206
 				// Add pdfgeneration hook
207
-				if (! is_object($hookmanager))
207
+				if (!is_object($hookmanager))
208 208
 				{
209 209
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
210
-					$hookmanager=new HookManager($this->db);
210
+					$hookmanager = new HookManager($this->db);
211 211
 				}
212 212
 
213 213
 				$hookmanager->initHooks(array('pdfgeneration'));
214
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
214
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
215 215
 				global $action;
216
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
216
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
217 217
 
218 218
 				$nblignes = count($object->lines);
219 219
 
220 220
 				// Create pdf instance
221
-				$pdf=pdf_getInstance($this->format);
222
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
223
-				$heightforinfotot = 50;	// Height reserved to output the info and total part
224
-				$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
225
-				$heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
226
-				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
227
-				$pdf->SetAutoPageBreak(1,0);
221
+				$pdf = pdf_getInstance($this->format);
222
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
223
+				$heightforinfotot = 50; // Height reserved to output the info and total part
224
+				$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
225
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
226
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
227
+				$pdf->SetAutoPageBreak(1, 0);
228 228
 
229 229
 				if (class_exists('TCPDF'))
230 230
 				{
@@ -233,63 +233,63 @@  discard block
 block discarded – undo
233 233
 				}
234 234
 				$pdf->SetFont(pdf_getPDFFont($outputlangs));
235 235
 				// Set path to the background PDF File
236
-				if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
236
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
237 237
 				{
238 238
 					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
239 239
 					$tplidx = $pdf->importPage(1);
240 240
 				}
241 241
 
242 242
 				$pdf->Open();
243
-				$pagenb=0;
244
-				$pdf->SetDrawColor(128,128,128);
243
+				$pagenb = 0;
244
+				$pdf->SetDrawColor(128, 128, 128);
245 245
 
246 246
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
247 247
 				$pdf->SetSubject($outputlangs->transnoentities("InterventionCard"));
248 248
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
249 249
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
250 250
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("InterventionCard"));
251
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
251
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
252 252
 
253
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
253
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
254 254
 
255 255
 				// New page
256 256
 				$pdf->AddPage();
257
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
257
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
258 258
 				$pagenb++;
259 259
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
260
-				$pdf->SetFont('','', $default_font_size - 1);
261
-				$pdf->SetTextColor(0,0,0);
260
+				$pdf->SetFont('', '', $default_font_size - 1);
261
+				$pdf->SetTextColor(0, 0, 0);
262 262
 
263 263
 				$tab_top = 90;
264
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
264
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
265 265
 				$tab_height = 130;
266 266
 				$tab_height_newpage = 150;
267 267
 
268 268
 				// Affiche notes
269
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
269
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
270 270
 				if ($notetoshow)
271 271
 				{
272
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
272
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
273 273
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
274 274
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
275 275
 
276 276
 					$tab_top = 88;
277 277
 
278
-					$pdf->SetFont('','', $default_font_size - 1);
279
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
278
+					$pdf->SetFont('', '', $default_font_size - 1);
279
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
280 280
 					$nexY = $pdf->GetY();
281
-					$height_note=$nexY-$tab_top;
281
+					$height_note = $nexY - $tab_top;
282 282
 
283 283
 					// Rect prend une longueur en 3eme param
284
-					$pdf->SetDrawColor(192,192,192);
285
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
284
+					$pdf->SetDrawColor(192, 192, 192);
285
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
286 286
 
287 287
 					$tab_height = $tab_height - $height_note;
288
-					$tab_top = $nexY+6;
288
+					$tab_top = $nexY + 6;
289 289
 				}
290 290
 				else
291 291
 				{
292
-					$height_note=0;
292
+					$height_note = 0;
293 293
 				}
294 294
 
295 295
 				$iniY = $tab_top + 7;
@@ -297,25 +297,25 @@  discard block
 block discarded – undo
297 297
 				$nexY = $tab_top + 7;
298 298
 
299 299
 				$pdf->SetXY($this->marge_gauche, $tab_top);
300
-				$pdf->MultiCell(190,5,$outputlangs->transnoentities("Description"),0,'L',0);
301
-				$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur-$this->marge_droite, $tab_top + 5);
300
+				$pdf->MultiCell(190, 5, $outputlangs->transnoentities("Description"), 0, 'L', 0);
301
+				$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
302 302
 
303 303
 				$pdf->SetFont('', '', $default_font_size - 1);
304 304
 
305 305
 				$pdf->SetXY($this->marge_gauche, $tab_top + 5);
306
-				$text=$object->description;
306
+				$text = $object->description;
307 307
 				if ($object->duration > 0)
308 308
 				{
309
-				    $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY);
310
-				    $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime;
309
+				    $totaltime = convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
310
+				    $text .= ($text ? ' - ' : '').$langs->trans("Total").": ".$totaltime;
311 311
 				}
312
-				$desc=dol_htmlentitiesbr($text,1);
312
+				$desc = dol_htmlentitiesbr($text, 1);
313 313
 				//print $outputlangs->convToOutputCharset($desc); exit;
314 314
 
315 315
 				$pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1);
316 316
 				$nexY = $pdf->GetY();
317 317
 
318
-				$pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY);
318
+				$pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
319 319
 
320 320
 				$nblines = count($object->lines);
321 321
 
@@ -328,54 +328,54 @@  discard block
 block discarded – undo
328 328
 					if ($valide > 0 || $object->specimen)
329 329
 					{
330 330
 						$curY = $nexY;
331
-						$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
332
-						$pdf->SetTextColor(0,0,0);
331
+						$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
332
+						$pdf->SetTextColor(0, 0, 0);
333 333
 
334 334
 						$pdf->setTopMargin($tab_top_newpage);
335
-						$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
336
-						$pageposbefore=$pdf->getPage();
335
+						$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
336
+						$pageposbefore = $pdf->getPage();
337 337
 
338 338
 						// Description of product line
339
-						$curX = $this->posxdesc-1;
339
+						$curX = $this->posxdesc - 1;
340 340
 
341 341
 						// Description of product line
342 342
                                                 if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR))
343 343
                                                 {
344
-						        $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true);
344
+						        $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true);
345 345
                                                 }
346 346
                                                 else
347 347
                                                 {
348
-                                                        $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'day',false,$outputlangs,true);
348
+                                                        $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'day', false, $outputlangs, true);
349 349
                                                 }
350 350
 
351 351
 						if ($objectligne->duration > 0)
352 352
 						{
353
-							$txt.=" - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration);
353
+							$txt .= " - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration);
354 354
 						}
355
-						$txt='<strong>'.dol_htmlentitiesbr($txt,1,$outputlangs->charset_output).'</strong>';
356
-						$desc=dol_htmlentitiesbr($objectligne->desc,1);
355
+						$txt = '<strong>'.dol_htmlentitiesbr($txt, 1, $outputlangs->charset_output).'</strong>';
356
+						$desc = dol_htmlentitiesbr($objectligne->desc, 1);
357 357
 
358 358
 						$pdf->startTransaction();
359
-						$pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt,$desc), 0, 1, 0);
360
-						$pageposafter=$pdf->getPage();
359
+						$pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt, $desc), 0, 1, 0);
360
+						$pageposafter = $pdf->getPage();
361 361
 						if ($pageposafter > $pageposbefore)	// There is a pagebreak
362 362
 						{
363 363
 							$pdf->rollbackTransaction(true);
364
-							$pageposafter=$pageposbefore;
364
+							$pageposafter = $pageposbefore;
365 365
 							//print $pageposafter.'-'.$pageposbefore;exit;
366
-							$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
367
-							$pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt,$desc), 0, 1, 0);
368
-							$pageposafter=$pdf->getPage();
369
-							$posyafter=$pdf->GetY();
366
+							$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
367
+							$pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt, $desc), 0, 1, 0);
368
+							$pageposafter = $pdf->getPage();
369
+							$posyafter = $pdf->GetY();
370 370
 							//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
371
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
371
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
372 372
 							{
373
-								if ($i == ($nblines-1))	// No more lines, and no space left to show total, so we create a new page
373
+								if ($i == ($nblines - 1))	// No more lines, and no space left to show total, so we create a new page
374 374
 								{
375
-									$pdf->AddPage('','',true);
376
-									if (! empty($tplidx)) $pdf->useTemplate($tplidx);
375
+									$pdf->AddPage('', '', true);
376
+									if (!empty($tplidx)) $pdf->useTemplate($tplidx);
377 377
 									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
378
-									$pdf->setPage($pageposafter+1);
378
+									$pdf->setPage($pageposafter + 1);
379 379
 								}
380 380
 							}
381 381
 						}
@@ -385,17 +385,17 @@  discard block
 block discarded – undo
385 385
 						}
386 386
 
387 387
 						$nexY = $pdf->GetY();
388
-						$pageposafter=$pdf->getPage();
388
+						$pageposafter = $pdf->getPage();
389 389
 						$pdf->setPage($pageposbefore);
390 390
 						$pdf->setTopMargin($this->marge_haute);
391
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
391
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
392 392
 
393 393
 						// We suppose that a too long description is moved completely on next page
394 394
 						if ($pageposafter > $pageposbefore) {
395 395
 							$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
396 396
 						}
397 397
 
398
-						$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
398
+						$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
399 399
 
400 400
 						// Detect if some page were added automatically and output _tableau for past pages
401 401
 						while ($pagenb < $pageposafter)
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
 							{
410 410
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
411 411
 							}
412
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
412
+							$this->_pagefoot($pdf, $object, $outputlangs, 1);
413 413
 							$pagenb++;
414 414
 							$pdf->setPage($pagenb);
415
-							$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
415
+							$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
416 416
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
417 417
 						}
418
-						if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
418
+						if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
419 419
 						{
420 420
 							if ($pagenb == 1)
421 421
 							{
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
 							{
426 426
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
427 427
 							}
428
-							$this->_pagefoot($pdf,$object,$outputlangs,1);
428
+							$this->_pagefoot($pdf, $object, $outputlangs, 1);
429 429
 							// New page
430 430
 							$pdf->AddPage();
431
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
431
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
432 432
 							$pagenb++;
433 433
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
434 434
 						}
@@ -439,27 +439,27 @@  discard block
 block discarded – undo
439 439
 				if ($pagenb == 1)
440 440
 				{
441 441
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
442
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
442
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
443 443
 				}
444 444
 				else
445 445
 				{
446 446
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
447
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
447
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
448 448
 				}
449 449
 
450
-				$this->_pagefoot($pdf,$object,$outputlangs);
451
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
450
+				$this->_pagefoot($pdf, $object, $outputlangs);
451
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
452 452
 
453 453
 				$pdf->Close();
454
-				$pdf->Output($file,'F');
454
+				$pdf->Output($file, 'F');
455 455
 
456 456
 				// Add pdfgeneration hook
457 457
 				$hookmanager->initHooks(array('pdfgeneration'));
458
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
458
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
459 459
 				global $action;
460
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
460
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
461 461
 
462
-				if (! empty($conf->global->MAIN_UMASK))
462
+				if (!empty($conf->global->MAIN_UMASK))
463 463
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
464 464
 
465 465
 				$this->result = array('fullpath'=>$file);
@@ -468,13 +468,13 @@  discard block
 block discarded – undo
468 468
 			}
469 469
 			else
470 470
 			{
471
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
471
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
472 472
 				return 0;
473 473
 			}
474 474
 		}
475 475
 		else
476 476
 		{
477
-			$this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR");
477
+			$this->error = $langs->trans("ErrorConstantNotDefined", "FICHEINTER_OUTPUTDIR");
478 478
 			return 0;
479 479
 		}
480 480
 	}
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	 *   @param		int			$hidebottom		Hide bottom bar of array
492 492
 	 *   @return	void
493 493
 	 */
494
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
494
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
495 495
 	{
496 496
 		global $conf;
497 497
 
@@ -524,21 +524,21 @@  discard block
 block discarded – undo
524 524
 */
525 525
 
526 526
 		// Output Rect
527
-		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+1, 0, 0);	// Rect prend une longueur en 3eme param et 4eme param
527
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 1, 0, 0); // Rect prend une longueur en 3eme param et 4eme param
528 528
 
529 529
 		if (empty($hidebottom))
530 530
 		{
531
-			$pdf->SetXY(20,230);
532
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0);
531
+			$pdf->SetXY(20, 230);
532
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"), 0, 'L', 0);
533 533
 
534
-			$pdf->SetXY(20,235);
535
-			$pdf->MultiCell(80,25, '', 1);
534
+			$pdf->SetXY(20, 235);
535
+			$pdf->MultiCell(80, 25, '', 1);
536 536
 
537
-			$pdf->SetXY(110,230);
538
-			$pdf->MultiCell(80,5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0);
537
+			$pdf->SetXY(110, 230);
538
+			$pdf->MultiCell(80, 5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"), 0, 'L', 0);
539 539
 
540
-			$pdf->SetXY(110,235);
541
-			$pdf->MultiCell(80,25, '', 1);
540
+			$pdf->SetXY(110, 235);
541
+			$pdf->MultiCell(80, 25, '', 1);
542 542
 		}
543 543
 	}
544 544
 
@@ -553,129 +553,129 @@  discard block
 block discarded – undo
553 553
 	 */
554 554
 	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
555 555
 	{
556
-		global $conf,$langs;
556
+		global $conf, $langs;
557 557
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
558 558
 
559 559
 		// Load traductions files requiredby by page
560 560
 		$outputlangs->loadLangs(array("main", "dict", "companies", "interventions"));
561 561
 
562
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
562
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
563 563
 
564 564
 		//Affiche le filigrane brouillon - Print Draft Watermark
565
-		if($object->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) )
565
+		if ($object->statut == 0 && (!empty($conf->global->FICHINTER_DRAFT_WATERMARK)))
566 566
 		{
567
-			pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FICHINTER_DRAFT_WATERMARK);
567
+			pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FICHINTER_DRAFT_WATERMARK);
568 568
 		}
569 569
 
570 570
 		//Prepare la suite
571
-		$pdf->SetTextColor(0,0,60);
572
-		$pdf->SetFont('','B', $default_font_size + 3);
571
+		$pdf->SetTextColor(0, 0, 60);
572
+		$pdf->SetFont('', 'B', $default_font_size + 3);
573 573
 
574
-		$posx=$this->page_largeur-$this->marge_droite-100;
575
-		$posy=$this->marge_haute;
574
+		$posx = $this->page_largeur - $this->marge_droite - 100;
575
+		$posy = $this->marge_haute;
576 576
 
577
-		$pdf->SetXY($this->marge_gauche,$posy);
577
+		$pdf->SetXY($this->marge_gauche, $posy);
578 578
 
579 579
 		// Logo
580
-		$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
580
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
581 581
 		if ($this->emetteur->logo)
582 582
 		{
583 583
 			if (is_readable($logo))
584 584
 			{
585
-			    $height=pdf_getHeightForLogo($logo);
586
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
585
+			    $height = pdf_getHeightForLogo($logo);
586
+			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
587 587
 			}
588 588
 			else
589 589
 			{
590
-				$pdf->SetTextColor(200,0,0);
591
-				$pdf->SetFont('','B',$default_font_size - 2);
592
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
590
+				$pdf->SetTextColor(200, 0, 0);
591
+				$pdf->SetFont('', 'B', $default_font_size - 2);
592
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
593 593
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
594 594
 			}
595 595
 		}
596 596
 		else
597 597
 		{
598
-			$text=$this->emetteur->name;
598
+			$text = $this->emetteur->name;
599 599
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
600 600
 		}
601 601
 
602
-		$pdf->SetFont('','B',$default_font_size + 3);
603
-		$pdf->SetXY($posx,$posy);
604
-		$pdf->SetTextColor(0,0,60);
605
-		$title=$outputlangs->transnoentities("InterventionCard");
602
+		$pdf->SetFont('', 'B', $default_font_size + 3);
603
+		$pdf->SetXY($posx, $posy);
604
+		$pdf->SetTextColor(0, 0, 60);
605
+		$title = $outputlangs->transnoentities("InterventionCard");
606 606
 		$pdf->MultiCell(100, 4, $title, '', 'R');
607 607
 
608
-		$pdf->SetFont('','B',$default_font_size + 2);
608
+		$pdf->SetFont('', 'B', $default_font_size + 2);
609 609
 
610
-		$posy+=5;
611
-		$pdf->SetXY($posx,$posy);
612
-		$pdf->SetTextColor(0,0,60);
613
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
610
+		$posy += 5;
611
+		$pdf->SetXY($posx, $posy);
612
+		$pdf->SetTextColor(0, 0, 60);
613
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
614 614
 
615
-		$posy+=1;
616
-		$pdf->SetFont('','', $default_font_size);
615
+		$posy += 1;
616
+		$pdf->SetFont('', '', $default_font_size);
617 617
 
618
-		$posy+=4;
619
-		$pdf->SetXY($posx,$posy);
620
-		$pdf->SetTextColor(0,0,60);
621
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->datec,"day",false,$outputlangs,true), '', 'R');
618
+		$posy += 4;
619
+		$pdf->SetXY($posx, $posy);
620
+		$pdf->SetTextColor(0, 0, 60);
621
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->datec, "day", false, $outputlangs, true), '', 'R');
622 622
 
623 623
 		if ($object->thirdparty->code_client)
624 624
 		{
625
-			$posy+=4;
626
-			$pdf->SetXY($posx,$posy);
627
-			$pdf->SetTextColor(0,0,60);
628
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
625
+			$posy += 4;
626
+			$pdf->SetXY($posx, $posy);
627
+			$pdf->SetTextColor(0, 0, 60);
628
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
629 629
 		}
630 630
 
631 631
 		if ($showaddress)
632 632
 		{
633 633
 			// Sender properties
634
-			$carac_emetteur='';
634
+			$carac_emetteur = '';
635 635
 			// Add internal contact of proposal if defined
636
-			$arrayidcontact=$object->getIdContact('internal','INTERREPFOLL');
636
+			$arrayidcontact = $object->getIdContact('internal', 'INTERREPFOLL');
637 637
 			if (count($arrayidcontact) > 0)
638 638
 			{
639 639
 				$object->fetch_user($arrayidcontact[0]);
640
-				$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
640
+				$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
641 641
 			}
642 642
 
643 643
 			$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
644 644
 
645 645
 			// Show sender
646
-			$posy=42;
647
-			$posx=$this->marge_gauche;
648
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
649
-			$hautcadre=40;
646
+			$posy = 42;
647
+			$posx = $this->marge_gauche;
648
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
649
+			$hautcadre = 40;
650 650
 
651 651
 			// Show sender frame
652
-			$pdf->SetTextColor(0,0,0);
653
-			$pdf->SetFont('','', $default_font_size - 2);
654
-			$pdf->SetXY($posx,$posy-5);
655
-			$pdf->SetXY($posx,$posy);
656
-			$pdf->SetFillColor(230,230,230);
652
+			$pdf->SetTextColor(0, 0, 0);
653
+			$pdf->SetFont('', '', $default_font_size - 2);
654
+			$pdf->SetXY($posx, $posy - 5);
655
+			$pdf->SetXY($posx, $posy);
656
+			$pdf->SetFillColor(230, 230, 230);
657 657
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
658 658
 
659 659
 			// Show sender name
660
-			$pdf->SetXY($posx+2,$posy+3);
661
-			$pdf->SetTextColor(0,0,60);
662
-			$pdf->SetFont('','B',$default_font_size);
660
+			$pdf->SetXY($posx + 2, $posy + 3);
661
+			$pdf->SetTextColor(0, 0, 60);
662
+			$pdf->SetFont('', 'B', $default_font_size);
663 663
 			$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
664
-			$posy=$pdf->getY();
664
+			$posy = $pdf->getY();
665 665
 
666 666
 			// Show sender information
667
-			$pdf->SetFont('','', $default_font_size - 1);
668
-			$pdf->SetXY($posx+2,$posy);
667
+			$pdf->SetFont('', '', $default_font_size - 1);
668
+			$pdf->SetXY($posx + 2, $posy);
669 669
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
670 670
 
671 671
 
672 672
 			// If CUSTOMER contact defined, we use it
673
-			$usecontact=false;
674
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
673
+			$usecontact = false;
674
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
675 675
 			if (count($arrayidcontact) > 0)
676 676
 			{
677
-				$usecontact=true;
678
-				$result=$object->fetch_contact($arrayidcontact[0]);
677
+				$usecontact = true;
678
+				$result = $object->fetch_contact($arrayidcontact[0]);
679 679
 			}
680 680
 
681 681
 			//Recipient name
@@ -686,34 +686,34 @@  discard block
 block discarded – undo
686 686
 				$thirdparty = $object->thirdparty;
687 687
 			}
688 688
 
689
-			$carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs);
689
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
690 690
 
691
-			$carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target',$object);
691
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact) ? $object->contact : ''), $usecontact, 'target', $object);
692 692
 
693 693
 			// Show recipient
694
-			$widthrecbox=100;
695
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
696
-			$posy=42;
697
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
698
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
694
+			$widthrecbox = 100;
695
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
696
+			$posy = 42;
697
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
698
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
699 699
 
700 700
 			// Show recipient frame
701
-			$pdf->SetTextColor(0,0,0);
702
-			$pdf->SetFont('','', $default_font_size - 2);
703
-			$pdf->SetXY($posx+2,$posy-5);
701
+			$pdf->SetTextColor(0, 0, 0);
702
+			$pdf->SetFont('', '', $default_font_size - 2);
703
+			$pdf->SetXY($posx + 2, $posy - 5);
704 704
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
705
-			$pdf->SetTextColor(0,0,0);
705
+			$pdf->SetTextColor(0, 0, 0);
706 706
 
707 707
 			// Show recipient name
708
-			$pdf->SetXY($posx+2,$posy+3);
709
-			$pdf->SetFont('','B', $default_font_size);
708
+			$pdf->SetXY($posx + 2, $posy + 3);
709
+			$pdf->SetFont('', 'B', $default_font_size);
710 710
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
711 711
 
712 712
 			$posy = $pdf->getY();
713 713
 
714 714
 			// Show recipient information
715
-			$pdf->SetFont('','', $default_font_size - 1);
716
-			$pdf->SetXY($posx+2,$posy);
715
+			$pdf->SetFont('', '', $default_font_size - 1);
716
+			$pdf->SetXY($posx + 2, $posy);
717 717
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
718 718
 		}
719 719
 	}
@@ -727,10 +727,10 @@  discard block
 block discarded – undo
727 727
 	 *      @param	int			$hidefreetext		1=Hide free text
728 728
 	 *      @return	integer
729 729
 	 */
730
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
730
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
731 731
 	{
732 732
 		global $conf;
733
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
734
-		return pdf_pagefoot($pdf,$outputlangs,'FICHINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
733
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
734
+		return pdf_pagefoot($pdf, $outputlangs, 'FICHINTER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
735 735
 	}
736 736
 }
Please login to merge, or discard this patch.
Braces   +67 added lines, -41 removed lines patch added patch discarded remove patch
@@ -145,7 +145,10 @@  discard block
 block discarded – undo
145 145
 
146 146
 		// Get source company
147 147
 		$this->emetteur=$mysoc;
148
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if not defined
148
+		if (empty($this->emetteur->country_code)) {
149
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
150
+		}
151
+		// By default, if not defined
149 152
 
150 153
 		// Define position of columns
151 154
 		$this->posxdesc=$this->marge_gauche+1;
@@ -168,9 +171,13 @@  discard block
 block discarded – undo
168 171
         // phpcs:enable
169 172
 		global $user,$langs,$conf,$mysoc,$db,$hookmanager;
170 173
 
171
-		if (! is_object($outputlangs)) $outputlangs=$langs;
174
+		if (! is_object($outputlangs)) {
175
+		    $outputlangs=$langs;
176
+		}
172 177
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
173
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
178
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
179
+		    $outputlangs->charset_output='ISO-8859-1';
180
+		}
174 181
 
175 182
 		// Load traductions files requiredby by page
176 183
 		$outputlangs->loadLangs(array("main", "interventions", "dict", "companies"));
@@ -184,8 +191,7 @@  discard block
 block discarded – undo
184 191
 			{
185 192
 				$dir = $conf->ficheinter->dir_output;
186 193
 				$file = $dir . "/SPECIMEN.pdf";
187
-			}
188
-			else
194
+			} else
189 195
 			{
190 196
 				$objectref = dol_sanitizeFileName($object->ref);
191 197
 				$dir = $conf->ficheinter->dir_output . "/" . $objectref;
@@ -223,7 +229,9 @@  discard block
 block discarded – undo
223 229
 				$heightforinfotot = 50;	// Height reserved to output the info and total part
224 230
 				$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
225 231
 				$heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
226
-				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
232
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
233
+				    $heightforfooter+= 6;
234
+				}
227 235
 				$pdf->SetAutoPageBreak(1,0);
228 236
 
229 237
 				if (class_exists('TCPDF'))
@@ -248,13 +256,17 @@  discard block
 block discarded – undo
248 256
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
249 257
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
250 258
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("InterventionCard"));
251
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
259
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
260
+				    $pdf->SetCompression(false);
261
+				}
252 262
 
253 263
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
254 264
 
255 265
 				// New page
256 266
 				$pdf->AddPage();
257
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
267
+				if (! empty($tplidx)) {
268
+				    $pdf->useTemplate($tplidx);
269
+				}
258 270
 				$pagenb++;
259 271
 				$this->_pagehead($pdf, $object, 1, $outputlangs);
260 272
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -286,8 +298,7 @@  discard block
 block discarded – undo
286 298
 
287 299
 					$tab_height = $tab_height - $height_note;
288 300
 					$tab_top = $nexY+6;
289
-				}
290
-				else
301
+				} else
291 302
 				{
292 303
 					$height_note=0;
293 304
 				}
@@ -342,8 +353,7 @@  discard block
 block discarded – undo
342 353
                                                 if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR))
343 354
                                                 {
344 355
 						        $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'dayhour',false,$outputlangs,true);
345
-                                                }
346
-                                                else
356
+                                                } else
347 357
                                                 {
348 358
                                                         $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei,'day',false,$outputlangs,true);
349 359
                                                 }
@@ -358,9 +368,11 @@  discard block
 block discarded – undo
358 368
 						$pdf->startTransaction();
359 369
 						$pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt,$desc), 0, 1, 0);
360 370
 						$pageposafter=$pdf->getPage();
361
-						if ($pageposafter > $pageposbefore)	// There is a pagebreak
371
+						if ($pageposafter > $pageposbefore) {
372
+						    // There is a pagebreak
362 373
 						{
363 374
 							$pdf->rollbackTransaction(true);
375
+						}
364 376
 							$pageposafter=$pageposbefore;
365 377
 							//print $pageposafter.'-'.$pageposbefore;exit;
366 378
 							$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -368,18 +380,23 @@  discard block
 block discarded – undo
368 380
 							$pageposafter=$pdf->getPage();
369 381
 							$posyafter=$pdf->GetY();
370 382
 							//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
371
-							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
383
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
384
+							    // There is no space left for total+free text
372 385
 							{
373 386
 								if ($i == ($nblines-1))	// No more lines, and no space left to show total, so we create a new page
374 387
 								{
375 388
 									$pdf->AddPage('','',true);
376
-									if (! empty($tplidx)) $pdf->useTemplate($tplidx);
377
-									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
389
+							}
390
+									if (! empty($tplidx)) {
391
+									    $pdf->useTemplate($tplidx);
392
+									}
393
+									if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
394
+									    $this->_pagehead($pdf, $object, 0, $outputlangs);
395
+									}
378 396
 									$pdf->setPage($pageposafter+1);
379 397
 								}
380 398
 							}
381
-						}
382
-						else	// No pagebreak
399
+						} else	// No pagebreak
383 400
 						{
384 401
 							$pdf->commitTransaction();
385 402
 						}
@@ -404,8 +421,7 @@  discard block
 block discarded – undo
404 421
 							if ($pagenb == 1)
405 422
 							{
406 423
 								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
407
-							}
408
-							else
424
+							} else
409 425
 							{
410 426
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
411 427
 							}
@@ -413,24 +429,29 @@  discard block
 block discarded – undo
413 429
 							$pagenb++;
414 430
 							$pdf->setPage($pagenb);
415 431
 							$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
416
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
432
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
433
+							    $this->_pagehead($pdf, $object, 0, $outputlangs);
434
+							}
417 435
 						}
418 436
 						if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
419 437
 						{
420 438
 							if ($pagenb == 1)
421 439
 							{
422 440
 								$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
423
-							}
424
-							else
441
+							} else
425 442
 							{
426 443
 								$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
427 444
 							}
428 445
 							$this->_pagefoot($pdf,$object,$outputlangs,1);
429 446
 							// New page
430 447
 							$pdf->AddPage();
431
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
448
+							if (! empty($tplidx)) {
449
+							    $pdf->useTemplate($tplidx);
450
+							}
432 451
 							$pagenb++;
433
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
452
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
453
+							    $this->_pagehead($pdf, $object, 0, $outputlangs);
454
+							}
434 455
 						}
435 456
 					}
436 457
 				}
@@ -440,15 +461,16 @@  discard block
 block discarded – undo
440 461
 				{
441 462
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
442 463
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
443
-				}
444
-				else
464
+				} else
445 465
 				{
446 466
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
447 467
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
448 468
 				}
449 469
 
450 470
 				$this->_pagefoot($pdf,$object,$outputlangs);
451
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
471
+				if (method_exists($pdf,'AliasNbPages')) {
472
+				    $pdf->AliasNbPages();
473
+				}
452 474
 
453 475
 				$pdf->Close();
454 476
 				$pdf->Output($file,'F');
@@ -459,20 +481,19 @@  discard block
 block discarded – undo
459 481
 				global $action;
460 482
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
461 483
 
462
-				if (! empty($conf->global->MAIN_UMASK))
463
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
484
+				if (! empty($conf->global->MAIN_UMASK)) {
485
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
486
+				}
464 487
 
465 488
 				$this->result = array('fullpath'=>$file);
466 489
 
467 490
 				return 1;
468
-			}
469
-			else
491
+			} else
470 492
 			{
471 493
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
472 494
 				return 0;
473 495
 			}
474
-		}
475
-		else
496
+		} else
476 497
 		{
477 498
 			$this->error=$langs->trans("ErrorConstantNotDefined","FICHEINTER_OUTPUTDIR");
478 499
 			return 0;
@@ -584,16 +605,14 @@  discard block
 block discarded – undo
584 605
 			{
585 606
 			    $height=pdf_getHeightForLogo($logo);
586 607
 			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
587
-			}
588
-			else
608
+			} else
589 609
 			{
590 610
 				$pdf->SetTextColor(200,0,0);
591 611
 				$pdf->SetFont('','B',$default_font_size - 2);
592 612
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
593 613
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
594 614
 			}
595
-		}
596
-		else
615
+		} else
597 616
 		{
598 617
 			$text=$this->emetteur->name;
599 618
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -645,7 +664,9 @@  discard block
 block discarded – undo
645 664
 			// Show sender
646 665
 			$posy=42;
647 666
 			$posx=$this->marge_gauche;
648
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
667
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
668
+			    $posx=$this->page_largeur-$this->marge_droite-80;
669
+			}
649 670
 			$hautcadre=40;
650 671
 
651 672
 			// Show sender frame
@@ -692,10 +713,15 @@  discard block
 block discarded – undo
692 713
 
693 714
 			// Show recipient
694 715
 			$widthrecbox=100;
695
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
716
+			if ($this->page_largeur < 210) {
717
+			    $widthrecbox=84;
718
+			}
719
+			// To work with US executive format
696 720
 			$posy=42;
697 721
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
698
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
722
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
723
+			    $posx=$this->marge_gauche;
724
+			}
699 725
 
700 726
 			// Show recipient frame
701 727
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/fichinter/mod_pacific.php 3 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -34,132 +34,132 @@
 block discarded – undo
34 34
      * Dolibarr version of the loaded document
35 35
      * @public string
36 36
      */
37
-	public $version = 'dolibarr';        // 'development', 'experimental', 'dolibarr'
37
+    public $version = 'dolibarr';        // 'development', 'experimental', 'dolibarr'
38 38
 
39
-	public $prefix='FI';
39
+    public $prefix='FI';
40 40
 
41
-	/**
42
-	 * @var string Error code (or message)
43
-	 */
44
-	public $error='';
41
+    /**
42
+     * @var string Error code (or message)
43
+     */
44
+    public $error='';
45 45
 
46
-	/**
47
-	 * @var string Nom du modele
48
-	 * @deprecated
49
-	 * @see name
50
-	 */
51
-	public $nom='pacific';
46
+    /**
47
+     * @var string Nom du modele
48
+     * @deprecated
49
+     * @see name
50
+     */
51
+    public $nom='pacific';
52 52
 
53
-	/**
54
-	 * @var string model name
55
-	 */
56
-	public $name='pacific';
53
+    /**
54
+     * @var string model name
55
+     */
56
+    public $name='pacific';
57 57
 
58 58
 
59
-	/**
60
-	 *  Return description of numbering module
61
-	 *
59
+    /**
60
+     *  Return description of numbering module
61
+     *
62 62
      *  @return     string      Text with description
63 63
      */
64 64
     function info()
65 65
     {
66
-    	global $langs;
67
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
66
+        global $langs;
67
+            return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
68
+    }
69
+
70
+    /**
71
+     *  Renvoi un exemple de numerotation
72
+     *
73
+     *  @return     string      Example
74
+     */
75
+    function getExample()
76
+    {
77
+        return $this->prefix."0501-0001";
78
+    }
79
+
80
+    /**
81
+     *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
82
+     *  de conflits qui empechera cette numerotation de fonctionner.
83
+     *
84
+     *  @return     boolean     false si conflit, true si ok
85
+     */
86
+    function canBeActivated()
87
+    {
88
+        global $langs,$conf,$db;
89
+
90
+        $langs->load("bills");
91
+
92
+        $fayymm=''; $max='';
93
+
94
+        $posindice=8;
95
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
96
+        $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
97
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
98
+        $sql.= " WHERE entity = ".$conf->entity;
99
+
100
+        $resql=$db->query($sql);
101
+        if ($resql)
102
+        {
103
+            $row = $db->fetch_row($resql);
104
+            if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
105
+        }
106
+        if (! $fayymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$fayymm))
107
+        {
108
+            return true;
109
+        }
110
+        else
111
+        {
112
+            $langs->load("errors");
113
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
114
+            return false;
115
+        }
68 116
     }
69 117
 
70
-	/**
71
-	 *  Renvoi un exemple de numerotation
72
-	 *
73
-	 *  @return     string      Example
74
-	 */
75
-	function getExample()
76
-	{
77
-		return $this->prefix."0501-0001";
78
-	}
79
-
80
-	/**
81
-	 *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
82
-	 *  de conflits qui empechera cette numerotation de fonctionner.
83
-	 *
84
-	 *  @return     boolean     false si conflit, true si ok
85
-	 */
86
-	function canBeActivated()
87
-	{
88
-		global $langs,$conf,$db;
89
-
90
-		$langs->load("bills");
91
-
92
-		$fayymm=''; $max='';
93
-
94
-		$posindice=8;
95
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
96
-		$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
97
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
98
-		$sql.= " WHERE entity = ".$conf->entity;
99
-
100
-		$resql=$db->query($sql);
101
-		if ($resql)
102
-		{
103
-			$row = $db->fetch_row($resql);
104
-			if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
105
-		}
106
-		if (! $fayymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$fayymm))
107
-		{
108
-			return true;
109
-		}
110
-		else
111
-		{
112
-			$langs->load("errors");
113
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
114
-			return false;
115
-		}
116
-	}
117
-
118
-	/**
119
-	 * 	Return next free value
120
-	 *
121
-	 *  @param	Societe		$objsoc     Object thirdparty
122
-	 *  @param  Object		$object		Object we need next value for
123
-	 *  @return string      			Value if KO, <0 if KO
124
-	 */
125
-	function getNextValue($objsoc=0,$object='')
126
-	{
127
-		global $db,$conf;
128
-
129
-		// D'abord on recupere la valeur max
130
-		$posindice=8;
131
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
132
-		$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
133
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
134
-		$sql.= " AND entity = ".$conf->entity;
135
-
136
-		$resql=$db->query($sql);
137
-		if ($resql)
138
-		{
139
-			$obj = $db->fetch_object($resql);
140
-			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
142
-		}
143
-
144
-		//$date=time();
145
-		$date=$object->datec;
146
-		$yymm = strftime("%y%m",$date);
147
-
148
-    	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
149
-    	else $num = sprintf("%04s",$max+1);
150
-
151
-		return $this->prefix.$yymm."-".$num;
152
-	}
153
-
154
-	/**
155
-	 * 	Return next free value
156
-	 *
157
-	 *  @param	Societe	$objsoc     Object third party
158
-	 * 	@param	Object	$objforref	Object for number to search
159
-	 *  @return string      		Next free value
160
-	 */
161
-	function getNumRef($objsoc,$objforref)
162
-	{
163
-		return $this->getNextValue($objsoc,$objforref);
164
-	}
118
+    /**
119
+     * 	Return next free value
120
+     *
121
+     *  @param	Societe		$objsoc     Object thirdparty
122
+     *  @param  Object		$object		Object we need next value for
123
+     *  @return string      			Value if KO, <0 if KO
124
+     */
125
+    function getNextValue($objsoc=0,$object='')
126
+    {
127
+        global $db,$conf;
128
+
129
+        // D'abord on recupere la valeur max
130
+        $posindice=8;
131
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
132
+        $sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
133
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
134
+        $sql.= " AND entity = ".$conf->entity;
135
+
136
+        $resql=$db->query($sql);
137
+        if ($resql)
138
+        {
139
+            $obj = $db->fetch_object($resql);
140
+            if ($obj) $max = intval($obj->max);
141
+            else $max=0;
142
+        }
143
+
144
+        //$date=time();
145
+        $date=$object->datec;
146
+        $yymm = strftime("%y%m",$date);
147
+
148
+        if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
149
+        else $num = sprintf("%04s",$max+1);
150
+
151
+        return $this->prefix.$yymm."-".$num;
152
+    }
153
+
154
+    /**
155
+     * 	Return next free value
156
+     *
157
+     *  @param	Societe	$objsoc     Object third party
158
+     * 	@param	Object	$objforref	Object for number to search
159
+     *  @return string      		Next free value
160
+     */
161
+    function getNumRef($objsoc,$objforref)
162
+    {
163
+        return $this->getNextValue($objsoc,$objforref);
164
+    }
165 165
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *  \ingroup    fiche intervention
24 24
  *  \brief      File with Pacific numbering module for interventions
25 25
  */
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/fichinter/modules_fichinter.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
27 27
 
28 28
 /**
29 29
  *	Class to manage numbering of intervention cards with rule Pacific.
@@ -34,26 +34,26 @@  discard block
 block discarded – undo
34 34
      * Dolibarr version of the loaded document
35 35
      * @public string
36 36
      */
37
-	public $version = 'dolibarr';        // 'development', 'experimental', 'dolibarr'
37
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
38 38
 
39
-	public $prefix='FI';
39
+	public $prefix = 'FI';
40 40
 
41 41
 	/**
42 42
 	 * @var string Error code (or message)
43 43
 	 */
44
-	public $error='';
44
+	public $error = '';
45 45
 
46 46
 	/**
47 47
 	 * @var string Nom du modele
48 48
 	 * @deprecated
49 49
 	 * @see name
50 50
 	 */
51
-	public $nom='pacific';
51
+	public $nom = 'pacific';
52 52
 
53 53
 	/**
54 54
 	 * @var string model name
55 55
 	 */
56
-	public $name='pacific';
56
+	public $name = 'pacific';
57 57
 
58 58
 
59 59
 	/**
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     function info()
65 65
     {
66 66
     	global $langs;
67
-      	return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
67
+      	return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
68 68
     }
69 69
 
70 70
 	/**
@@ -85,32 +85,32 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	function canBeActivated()
87 87
 	{
88
-		global $langs,$conf,$db;
88
+		global $langs, $conf, $db;
89 89
 
90 90
 		$langs->load("bills");
91 91
 
92
-		$fayymm=''; $max='';
92
+		$fayymm = ''; $max = '';
93 93
 
94
-		$posindice=8;
94
+		$posindice = 8;
95 95
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
96
-		$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
97
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
98
-		$sql.= " WHERE entity = ".$conf->entity;
96
+		$sql .= " FROM ".MAIN_DB_PREFIX."fichinter";
97
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
98
+		$sql .= " WHERE entity = ".$conf->entity;
99 99
 
100
-		$resql=$db->query($sql);
100
+		$resql = $db->query($sql);
101 101
 		if ($resql)
102 102
 		{
103 103
 			$row = $db->fetch_row($resql);
104
-			if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
104
+			if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; }
105 105
 		}
106
-		if (! $fayymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$fayymm))
106
+		if (!$fayymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm))
107 107
 		{
108 108
 			return true;
109 109
 		}
110 110
 		else
111 111
 		{
112 112
 			$langs->load("errors");
113
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
113
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
114 114
 			return false;
115 115
 		}
116 116
 	}
@@ -122,31 +122,31 @@  discard block
 block discarded – undo
122 122
 	 *  @param  Object		$object		Object we need next value for
123 123
 	 *  @return string      			Value if KO, <0 if KO
124 124
 	 */
125
-	function getNextValue($objsoc=0,$object='')
125
+	function getNextValue($objsoc = 0, $object = '')
126 126
 	{
127
-		global $db,$conf;
127
+		global $db, $conf;
128 128
 
129 129
 		// D'abord on recupere la valeur max
130
-		$posindice=8;
130
+		$posindice = 8;
131 131
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
132
-		$sql.= " FROM ".MAIN_DB_PREFIX."fichinter";
133
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
134
-		$sql.= " AND entity = ".$conf->entity;
132
+		$sql .= " FROM ".MAIN_DB_PREFIX."fichinter";
133
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
134
+		$sql .= " AND entity = ".$conf->entity;
135 135
 
136
-		$resql=$db->query($sql);
136
+		$resql = $db->query($sql);
137 137
 		if ($resql)
138 138
 		{
139 139
 			$obj = $db->fetch_object($resql);
140 140
 			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
141
+			else $max = 0;
142 142
 		}
143 143
 
144 144
 		//$date=time();
145
-		$date=$object->datec;
146
-		$yymm = strftime("%y%m",$date);
145
+		$date = $object->datec;
146
+		$yymm = strftime("%y%m", $date);
147 147
 
148
-    	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
149
-    	else $num = sprintf("%04s",$max+1);
148
+    	if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
149
+    	else $num = sprintf("%04s", $max + 1);
150 150
 
151 151
 		return $this->prefix.$yymm."-".$num;
152 152
 	}
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * 	@param	Object	$objforref	Object for number to search
159 159
 	 *  @return string      		Next free value
160 160
 	 */
161
-	function getNumRef($objsoc,$objforref)
161
+	function getNumRef($objsoc, $objforref)
162 162
 	{
163
-		return $this->getNextValue($objsoc,$objforref);
163
+		return $this->getNextValue($objsoc, $objforref);
164 164
 	}
165 165
 }
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -106,8 +106,7 @@  discard block
 block discarded – undo
106 106
 		if (! $fayymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$fayymm))
107 107
 		{
108 108
 			return true;
109
-		}
110
-		else
109
+		} else
111 110
 		{
112 111
 			$langs->load("errors");
113 112
 			$this->error=$langs->trans('ErrorNumRefModel',$max);
@@ -137,16 +136,24 @@  discard block
 block discarded – undo
137 136
 		if ($resql)
138 137
 		{
139 138
 			$obj = $db->fetch_object($resql);
140
-			if ($obj) $max = intval($obj->max);
141
-			else $max=0;
139
+			if ($obj) {
140
+			    $max = intval($obj->max);
141
+			} else {
142
+			    $max=0;
143
+			}
142 144
 		}
143 145
 
144 146
 		//$date=time();
145 147
 		$date=$object->datec;
146 148
 		$yymm = strftime("%y%m",$date);
147 149
 
148
-    	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
149
-    	else $num = sprintf("%04s",$max+1);
150
+    	if ($max >= (pow(10, 4) - 1)) {
151
+    	    $num=$max+1;
152
+    	}
153
+    	// If counter > 9999, we do not format on 4 chars, we take number as it is
154
+    	else {
155
+    	    $num = sprintf("%04s",$max+1);
156
+    	}
150 157
 
151 158
 		return $this->prefix.$yymm."-".$num;
152 159
 	}
Please login to merge, or discard this patch.