Passed
Pull Request — master (#2)
by
unknown
26:19
created
dolibarr/htdocs/core/modules/security/generate/modules_genpassword.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     /**
34 34
 	 * @var string Error code (or message)
35 35
 	 */
36
-	public $error='';
36
+	public $error = '';
37 37
 
38 38
     /**
39 39
      * 		Return if a module can be used or not
Please login to merge, or discard this patch.
htdocs/core/modules/security/generate/modGeneratePassStandard.class.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *		\brief      File to manage password generation according to standard rule
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/security/generate/modules_genpassword.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php';
26 26
 
27 27
 
28 28
 /**
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
 		$this->id = "standard";
62 62
 		$this->length = 8;
63 63
 
64
-		$this->db=$db;
65
-		$this->conf=$conf;
66
-		$this->langs=$langs;
67
-		$this->user=$user;
64
+		$this->db = $db;
65
+		$this->conf = $conf;
66
+		$this->langs = $langs;
67
+		$this->user = $user;
68 68
 	}
69 69
 
70 70
 	/**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		{
110 110
 
111 111
 			// pick a random character from the possible ones
112
-			$char = substr($possible, mt_rand(0, dol_strlen($possible)-1), 1);
112
+			$char = substr($possible, mt_rand(0, dol_strlen($possible) - 1), 1);
113 113
 
114 114
 			// we don't want this character if it's already in the password
115 115
 			if (!strstr($password, $char))
Please login to merge, or discard this patch.
htdocs/core/modules/security/generate/modGeneratePassPerso.class.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *      \brief      File to manage no password generation.
25 25
  */
26 26
 
27
-require_once DOL_DOCUMENT_ROOT .'/core/modules/security/generate/modules_genpassword.php';
27
+require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php';
28 28
 
29 29
 
30 30
 /**
@@ -75,23 +75,23 @@  discard block
 block discarded – undo
75 75
 		$this->id = "Perso";
76 76
 		$this->length = $langs->trans("SetupPerso");
77 77
 
78
-		$this->db=$db;
79
-		$this->conf=$conf;
80
-		$this->langs=$langs;
81
-		$this->user=$user;
78
+		$this->db = $db;
79
+		$this->conf = $conf;
80
+		$this->langs = $langs;
81
+		$this->user = $user;
82 82
 
83 83
 		if (empty($conf->global->USER_PASSWORD_PATTERN)) {
84 84
 			// default value (8carac, 1maj, 1digit, 1spe,  3 repeat, no ambi at auto generation.
85
-			dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '8;1;1;1;3;1','chaine',0,'',$conf->entity);
85
+			dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '8;1;1;1;3;1', 'chaine', 0, '', $conf->entity);
86 86
 		}
87 87
 
88 88
 		$this->Maj = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
89 89
 		$this->Min = strtolower($this->Maj);
90 90
 		$this->Nb = "0123456789";
91 91
 		$this->Spe = "!@#$%&*()_-+={}[]\\|:;'/";
92
-		$this->Ambi = array("1","I","l","|","O","0");
92
+		$this->Ambi = array("1", "I", "l", "|", "O", "0");
93 93
 
94
-		$tabConf = explode(";",$conf->global->USER_PASSWORD_PATTERN);
94
+		$tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN);
95 95
 		$this->length2 = $tabConf[0];
96 96
 		$this->NbMaj = $tabConf[1];
97 97
 		$this->NbNum = $tabConf[2];
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
 
102 102
 		if ($this->WithoutAmbi)
103 103
 		{
104
-			$this->Maj = str_replace($this->Ambi,"",$this->Maj);
105
-			$this->Min = str_replace($this->Ambi,"",$this->Min);
106
-			$this->Nb  = str_replace($this->Ambi,"",$this->Nb);
107
-			$this->Spe = str_replace($this->Ambi,"",$this->Spe);
104
+			$this->Maj = str_replace($this->Ambi, "", $this->Maj);
105
+			$this->Min = str_replace($this->Ambi, "", $this->Min);
106
+			$this->Nb  = str_replace($this->Ambi, "", $this->Nb);
107
+			$this->Spe = str_replace($this->Ambi, "", $this->Spe);
108 108
 		}
109 109
 
110
-		$pattern = $this->Min . (! empty($this->NbMaj)?$this->Maj:'') . (! empty($this->NbNum)?$this->Nb:'') . (! empty($this->NbSpe)?$this->Spe:'');
110
+		$pattern = $this->Min.(!empty($this->NbMaj) ? $this->Maj : '').(!empty($this->NbNum) ? $this->Nb : '').(!empty($this->NbSpe) ? $this->Spe : '');
111 111
 		$this->All = str_shuffle($pattern);
112 112
 
113 113
 		//$this->All = str_shuffle($this->Maj. $this->Min. $this->Nb. $this->Spe);
@@ -144,20 +144,20 @@  discard block
 block discarded – undo
144 144
 	function getNewGeneratedPassword()
145 145
 	{
146 146
 		$pass = "";
147
-		for($i=0; $i<$this->NbMaj; $i++){ // Y
148
-			$pass .= $this->Maj[mt_rand(0,strlen($this->Maj) - 1)];
147
+		for ($i = 0; $i < $this->NbMaj; $i++) { // Y
148
+			$pass .= $this->Maj[mt_rand(0, strlen($this->Maj) - 1)];
149 149
 		}
150 150
 
151
-		for($i=0; $i<$this->NbNum; $i++){ // X
152
-			$pass .= $this->Nb[mt_rand(0,strlen($this->Nb) - 1)];
151
+		for ($i = 0; $i < $this->NbNum; $i++) { // X
152
+			$pass .= $this->Nb[mt_rand(0, strlen($this->Nb) - 1)];
153 153
 		}
154 154
 
155
-		for($i=0; $i<$this->NbSpe; $i++){ // @
156
-			$pass .= $this->Spe[mt_rand(0,strlen($this->Spe) - 1)];
155
+		for ($i = 0; $i < $this->NbSpe; $i++) { // @
156
+			$pass .= $this->Spe[mt_rand(0, strlen($this->Spe) - 1)];
157 157
 		}
158 158
 
159
-		for($i=strlen($pass);$i<$this->length2; $i++){ // y
160
-			$pass .= $this->All[mt_rand(0,strlen($this->All) -1)];
159
+		for ($i = strlen($pass); $i < $this->length2; $i++) { // y
160
+			$pass .= $this->All[mt_rand(0, strlen($this->All) - 1)];
161 161
 		}
162 162
 
163 163
 		$pass = str_shuffle($pass);
@@ -183,19 +183,19 @@  discard block
 block discarded – undo
183 183
 		$num = str_split($this->Nb);
184 184
 		$spe = str_split($this->Spe);
185 185
 
186
-		if(count(array_intersect($password_a, $maj)) < $this->NbMaj){
186
+		if (count(array_intersect($password_a, $maj)) < $this->NbMaj) {
187 187
 			return 0;
188 188
 		}
189 189
 
190
-		if(count(array_intersect($password_a, $num)) < $this->NbNum){
190
+		if (count(array_intersect($password_a, $num)) < $this->NbNum) {
191 191
 			return 0;
192 192
 		}
193 193
 
194
-		if(count(array_intersect($password_a, $spe)) < $this->NbSpe){
194
+		if (count(array_intersect($password_a, $spe)) < $this->NbSpe) {
195 195
 			return 0;
196 196
 		}
197 197
 
198
-		if(!$this->consecutiveInterationSameCharacter($password)){
198
+		if (!$this->consecutiveInterationSameCharacter($password)) {
199 199
 			return 0;
200 200
 		}
201 201
 
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
 		$last = "";
214 214
 		$count = 0;
215 215
 		$char = str_split($password);
216
-		foreach($char as $c){
217
-			if($c != $last){
216
+		foreach ($char as $c) {
217
+			if ($c != $last) {
218 218
 				$last = $c;
219 219
 				$count = 0;
220
-			}else{
220
+			} else {
221 221
 				$count++;
222 222
 			}
223 223
 
224
-			if($count >= $this->NbRepeat) {
224
+			if ($count >= $this->NbRepeat) {
225 225
 				return 0;
226 226
 			}
227 227
 		}
Please login to merge, or discard this patch.
htdocs/core/modules/security/generate/modGeneratePassNone.class.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *      \brief      File to manage no password generation.
23 23
  */
24 24
 
25
-require_once DOL_DOCUMENT_ROOT .'/core/modules/security/generate/modules_genpassword.php';
25
+require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php';
26 26
 
27 27
 
28 28
 /**
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
 		$this->id = "none";
62 62
 		$this->length = 0;
63 63
 
64
-		$this->db=$db;
65
-		$this->conf=$conf;
66
-		$this->langs=$langs;
67
-		$this->user=$user;
64
+		$this->db = $db;
65
+		$this->conf = $conf;
66
+		$this->langs = $langs;
67
+		$this->user = $user;
68 68
 	}
69 69
 
70 70
 	/**
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modApi.class.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *  \ingroup    api
26 26
  *  \brief      Description and activation file for module Api
27 27
  */
28
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
28
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
29 29
 
30 30
 
31 31
 /**
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	function __construct($db)
42 42
 	{
43
-        global $langs,$conf;
43
+        global $langs, $conf;
44 44
 
45 45
         $this->db = $db;
46 46
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		// It is used to group modules in module setup page
55 55
 		$this->family = "interface";
56 56
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
57
-		$this->name = preg_replace('/^mod/i','',get_class($this));
57
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
58 58
 		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
59 59
 		$this->description = "REST interface";
60 60
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		// Name of image file used for this module.
67 67
 		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
68 68
 		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
69
-		$this->picto='technic';
69
+		$this->picto = 'technic';
70 70
 
71 71
 		$this->module_parts = array();
72 72
 
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 		$this->config_page_url = array("index.php@api");
79 79
 
80 80
 		// Dependencies
81
-		$this->hidden = false;			// A condition to hide module
82
-		$this->depends = array();		// List of modules id that must be enabled if this module is enabled
83
-		$this->requiredby = array();	// List of modules id to disable if this one is disabled
84
-		$this->conflictwith = array();	// List of modules id this module is in conflict with
85
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
81
+		$this->hidden = false; // A condition to hide module
82
+		$this->depends = array(); // List of modules id that must be enabled if this module is enabled
83
+		$this->requiredby = array(); // List of modules id to disable if this one is disabled
84
+		$this->conflictwith = array(); // List of modules id this module is in conflict with
85
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
86 86
 		$this->langfiles = array("other");
87 87
 
88 88
 		// Constants
@@ -119,22 +119,22 @@  discard block
 block discarded – undo
119 119
         $this->tabs = array();
120 120
 
121 121
         // Dictionaries
122
-	    if (! isset($conf->api->enabled))
122
+	    if (!isset($conf->api->enabled))
123 123
         {
124
-        	$conf->api=new stdClass();
125
-        	$conf->api->enabled=0;
124
+        	$conf->api = new stdClass();
125
+        	$conf->api->enabled = 0;
126 126
         }
127
-		$this->dictionaries=array();
127
+		$this->dictionaries = array();
128 128
 
129 129
         // Boxes
130 130
 		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
131
-        $this->boxes = array();			// List of boxes
131
+        $this->boxes = array(); // List of boxes
132 132
 		// Example:
133 133
 		//$this->boxes=array(array(0=>array('file'=>'myboxa.php','note'=>'','enabledbydefaulton'=>'Home'),1=>array('file'=>'myboxb.php','note'=>''),2=>array('file'=>'myboxc.php','note'=>'')););
134 134
 
135 135
 		// Permissions
136
-		$this->rights = array();		// Permission array used by this module
137
-		$r=0;
136
+		$this->rights = array(); // Permission array used by this module
137
+		$r = 0;
138 138
 
139 139
 		// Add here list of permission defined by an id, a label, a boolean and two constant strings.
140 140
 		// Example:
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 
148 148
 
149 149
 		// Main menu entries
150
-		$this->menu = array();			// List of menus to add
151
-		$r=0;
150
+		$this->menu = array(); // List of menus to add
151
+		$r = 0;
152 152
 
153 153
 		// Add here entries to declare new menus
154 154
 		//
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 
185 185
 
186 186
 		// Exports
187
-		$r=1;
187
+		$r = 1;
188 188
 
189 189
 		// Example:
190 190
 		// $this->export_code[$r]=$this->rights_class.'_'.$r;
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
225 225
 	 *      @return     int             	1 if OK, 0 if KO
226 226
 	 */
227
-	function init($options='')
227
+	function init($options = '')
228 228
 	{
229 229
 		$sql = array();
230 230
 
231
-		$result=$this->_load_tables('/api/sql/');
231
+		$result = $this->_load_tables('/api/sql/');
232 232
 
233 233
 		return $this->_init($sql, $options);
234 234
 	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/facture/doc/pdf_sponge.modules.php 1 patch
Spacing   +525 added lines, -525 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	public $marge_haute;
89 89
 	public $marge_basse;
90 90
 
91
-	public $emetteur;	// Objet societe qui emet
91
+	public $emetteur; // Objet societe qui emet
92 92
 
93 93
 	/**
94 94
 	 * @var bool Situation invoice type
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	function __construct($db)
110 110
 	{
111
-		global $conf,$langs,$mysoc;
111
+		global $conf, $langs, $mysoc;
112 112
 
113 113
 		// Translations
114 114
 		$langs->loadLangs(array("main", "bills"));
@@ -116,47 +116,47 @@  discard block
 block discarded – undo
116 116
 		$this->db = $db;
117 117
 		$this->name = "sponge";
118 118
 		$this->description = $langs->trans('PDFSpongeDescription');
119
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
119
+		$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
120 120
 
121 121
 		// Dimensiont page
122 122
 		$this->type = 'pdf';
123
-		$formatarray=pdf_getFormat();
123
+		$formatarray = pdf_getFormat();
124 124
 		$this->page_largeur = $formatarray['width'];
125 125
 		$this->page_hauteur = $formatarray['height'];
126
-		$this->format = array($this->page_largeur,$this->page_hauteur);
127
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
128
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
129
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
130
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
131
-
132
-		$this->option_logo = 1;                    // Affiche logo
133
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
134
-		$this->option_modereg = 1;                 // Affiche mode reglement
135
-		$this->option_condreg = 1;                 // Affiche conditions reglement
136
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
137
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
138
-		$this->option_escompte = 1;                // Affiche si il y a eu escompte
139
-		$this->option_credit_note = 1;             // Support credit notes
140
-		$this->option_freetext = 1;				   // Support add of a personalised text
141
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
142
-
143
-		$this->franchise=!$mysoc->tva_assuj;
126
+		$this->format = array($this->page_largeur, $this->page_hauteur);
127
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
128
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
129
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
130
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
131
+
132
+		$this->option_logo = 1; // Affiche logo
133
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
134
+		$this->option_modereg = 1; // Affiche mode reglement
135
+		$this->option_condreg = 1; // Affiche conditions reglement
136
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
137
+		$this->option_multilang = 1; // Dispo en plusieurs langues
138
+		$this->option_escompte = 1; // Affiche si il y a eu escompte
139
+		$this->option_credit_note = 1; // Support credit notes
140
+		$this->option_freetext = 1; // Support add of a personalised text
141
+		$this->option_draft_watermark = 1; // Support add of a watermark on drafts
142
+
143
+		$this->franchise = !$mysoc->tva_assuj;
144 144
 
145 145
 		// Get source company
146
-		$this->emetteur=$mysoc;
147
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
146
+		$this->emetteur = $mysoc;
147
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
148 148
 
149 149
 		// Define position of columns
150
-		$this->posxdesc=$this->marge_gauche+1; // used for notes ans other stuff
150
+		$this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff
151 151
 
152 152
 		//  Use new system for position of columns, view  $this->defineColumnField()
153 153
 
154
-		$this->tva=array();
155
-		$this->localtax1=array();
156
-		$this->localtax2=array();
157
-		$this->atleastoneratenotnull=0;
158
-		$this->atleastonediscount=0;
159
-		$this->situationinvoice=false;
154
+		$this->tva = array();
155
+		$this->localtax1 = array();
156
+		$this->localtax2 = array();
157
+		$this->atleastoneratenotnull = 0;
158
+		$this->atleastonediscount = 0;
159
+		$this->situationinvoice = false;
160 160
 	}
161 161
 
162 162
 
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
      *  @param		int			$hideref			Do not show ref
173 173
      *  @return     int         	    			1=OK, 0=KO
174 174
 	 */
175
-	public function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
175
+	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
176 176
 	{
177 177
 	    // phpcs:enable
178
-	    global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
178
+	    global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
179 179
 
180
-	    if (! is_object($outputlangs)) $outputlangs=$langs;
180
+	    if (!is_object($outputlangs)) $outputlangs = $langs;
181 181
 	    // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
182
-	    if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
182
+	    if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
183 183
 
184 184
 	    // Translations
185 185
 	    $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
@@ -187,52 +187,52 @@  discard block
 block discarded – undo
187 187
 	    $nblignes = count($object->lines);
188 188
 
189 189
 	    // Loop on each lines to detect if there is at least one image to show
190
-	    $realpatharray=array();
190
+	    $realpatharray = array();
191 191
 	    $this->atleastonephoto = false;
192
-	    if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
192
+	    if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
193 193
 	    {
194 194
 	        $objphoto = new Product($this->db);
195 195
 
196
-	        for ($i = 0 ; $i < $nblignes ; $i++)
196
+	        for ($i = 0; $i < $nblignes; $i++)
197 197
 	        {
198 198
 	            if (empty($object->lines[$i]->fk_product)) continue;
199 199
 
200 200
 	            $objphoto->fetch($object->lines[$i]->fk_product);
201 201
 	            //var_dump($objphoto->ref);exit;
202
-	            if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
202
+	            if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
203 203
 	            {
204
-	                $pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";
205
-	                $pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';
204
+	                $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
205
+	                $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
206 206
 	            }
207 207
 	            else
208 208
 	            {
209
-	                $pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/';				// default
210
-	                $pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/";	// alternative
209
+	                $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
210
+	                $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
211 211
 	            }
212 212
 
213 213
 	            $arephoto = false;
214 214
 	            foreach ($pdir as $midir)
215 215
 	            {
216
-	                if (! $arephoto)
216
+	                if (!$arephoto)
217 217
 	                {
218 218
 	                    $dir = $conf->product->dir_output.'/'.$midir;
219 219
 
220
-	                    foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
220
+	                    foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
221 221
 	                    {
222 222
 	                        if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
223 223
 	                        {
224 224
 	                            if ($obj['photo_vignette'])
225 225
 	                            {
226
-	                                $filename= $obj['photo_vignette'];
226
+	                                $filename = $obj['photo_vignette'];
227 227
 	                            }
228 228
 	                            else
229 229
 	                            {
230
-	                                $filename=$obj['photo'];
230
+	                                $filename = $obj['photo'];
231 231
 	                            }
232 232
 	                        }
233 233
 	                        else
234 234
 	                        {
235
-	                            $filename=$obj['photo'];
235
+	                            $filename = $obj['photo'];
236 236
 	                        }
237 237
 
238 238
 	                        $realpath = $dir.$filename;
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	                }
243 243
 	            }
244 244
 
245
-	            if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
245
+	            if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
246 246
 	        }
247 247
 	    }
248 248
 
@@ -260,19 +260,19 @@  discard block
 block discarded – undo
260 260
 	        if ($object->specimen)
261 261
 	        {
262 262
 	            $dir = $conf->facture->dir_output;
263
-	            $file = $dir . "/SPECIMEN.pdf";
263
+	            $file = $dir."/SPECIMEN.pdf";
264 264
 	        }
265 265
 	        else
266 266
 	        {
267 267
 	            $objectref = dol_sanitizeFileName($object->ref);
268
-	            $dir = $conf->facture->dir_output . "/" . $objectref;
269
-	            $file = $dir . "/" . $objectref . ".pdf";
268
+	            $dir = $conf->facture->dir_output."/".$objectref;
269
+	            $file = $dir."/".$objectref.".pdf";
270 270
 	        }
271
-	        if (! file_exists($dir))
271
+	        if (!file_exists($dir))
272 272
 	        {
273 273
 	            if (dol_mkdir($dir) < 0)
274 274
 	            {
275
-	                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
275
+	                $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
276 276
 	                return 0;
277 277
 	            }
278 278
 	        }
@@ -280,28 +280,28 @@  discard block
 block discarded – undo
280 280
 	        if (file_exists($dir))
281 281
 	        {
282 282
 	            // Add pdfgeneration hook
283
-	            if (! is_object($hookmanager))
283
+	            if (!is_object($hookmanager))
284 284
 	            {
285 285
 	                include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
286
-	                $hookmanager=new HookManager($this->db);
286
+	                $hookmanager = new HookManager($this->db);
287 287
 	            }
288 288
 	            $hookmanager->initHooks(array('pdfgeneration'));
289
-	            $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
289
+	            $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
290 290
 	            global $action;
291
-	            $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
291
+	            $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
292 292
 
293 293
 	            // Set nblignes with the new facture lines content after hook
294 294
 	            $nblignes = count($object->lines);
295 295
 	            $nbpayments = count($object->getListOfPayments());
296 296
 
297 297
 	            // Create pdf instance
298
-	            $pdf=pdf_getInstance($this->format);
299
-	            $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
300
-	            $pdf->SetAutoPageBreak(1,0);
298
+	            $pdf = pdf_getInstance($this->format);
299
+	            $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
300
+	            $pdf->SetAutoPageBreak(1, 0);
301 301
 
302
-	            $heightforinfotot = 50+(4*$nbpayments);	// Height reserved to output the info and total part and payment 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 + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)?12:22);	// Height reserved to output the footer (value include bottom margin)
302
+	            $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment 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 + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
305 305
 
306 306
 	            if (class_exists('TCPDF'))
307 307
 	            {
@@ -311,28 +311,28 @@  discard block
 block discarded – undo
311 311
 	            $pdf->SetFont(pdf_getPDFFont($outputlangs));
312 312
 
313 313
 	            // Set path to the background PDF File
314
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
314
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
315 315
 	            {
316 316
 	                $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
317 317
 	                $tplidx = $pdf->importPage(1);
318 318
 	            }
319 319
 
320 320
 	            $pdf->Open();
321
-	            $pagenb=0;
322
-	            $pdf->SetDrawColor(128,128,128);
321
+	            $pagenb = 0;
322
+	            $pdf->SetDrawColor(128, 128, 128);
323 323
 
324 324
 	            $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
325 325
 	            $pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle"));
326 326
 	            $pdf->SetCreator("Dolibarr ".DOL_VERSION);
327 327
 	            $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
328 328
 	            $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
329
-	            if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
329
+	            if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
330 330
 
331
-	            $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
331
+	            $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
332 332
 
333 333
 	            // Does we have at least one line with discount $this->atleastonediscount
334 334
 	            foreach ($object->lines as $line) {
335
-	               if ($line->remise_percent){
335
+	               if ($line->remise_percent) {
336 336
 	                    $this->atleastonediscount = true;
337 337
 	                    break;
338 338
 	               }
@@ -347,17 +347,17 @@  discard block
 block discarded – undo
347 347
 
348 348
 	            // New page
349 349
 	            $pdf->AddPage();
350
-	            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
350
+	            if (!empty($tplidx)) $pdf->useTemplate($tplidx);
351 351
 	            $pagenb++;
352 352
 
353 353
 	            $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
354
-	            $pdf->SetFont('','', $default_font_size - 1);
355
-	            $pdf->MultiCell(0, 3, '');		// Set interline to 3
356
-	            $pdf->SetTextColor(0,0,0);
354
+	            $pdf->SetFont('', '', $default_font_size - 1);
355
+	            $pdf->MultiCell(0, 3, ''); // Set interline to 3
356
+	            $pdf->SetTextColor(0, 0, 0);
357 357
 
358
-	            $tab_top = 90+$top_shift;
359
-	            $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
360
-	            $tab_height = 130-$top_shift;
358
+	            $tab_top = 90 + $top_shift;
359
+	            $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
360
+	            $tab_height = 130 - $top_shift;
361 361
 	            $tab_height_newpage = 150;
362 362
 	            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
363 363
 
@@ -370,31 +370,31 @@  discard block
 block discarded – undo
370 370
 	                {
371 371
 						$tab_top -= 2;
372 372
 
373
-	                    $pdf->SetFont('','', $default_font_size - 1);
374
-	                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
375
-	                    $nexY = max($pdf->GetY(),$nexY);
376
-	                    $height_incoterms=$nexY-$tab_top;
373
+	                    $pdf->SetFont('', '', $default_font_size - 1);
374
+	                    $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
375
+	                    $nexY = max($pdf->GetY(), $nexY);
376
+	                    $height_incoterms = $nexY - $tab_top;
377 377
 
378 378
 	                    // Rect prend une longueur en 3eme param
379
-	                    $pdf->SetDrawColor(192,192,192);
380
-	                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
379
+	                    $pdf->SetDrawColor(192, 192, 192);
380
+	                    $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
381 381
 
382
-	                    $tab_top = $nexY+6;
382
+	                    $tab_top = $nexY + 6;
383 383
 	                    $height_incoterms += 4;
384 384
 	                }
385 385
 	            }
386 386
 
387 387
 	            // Affiche notes
388
-	            $notetoshow=empty($object->note_public)?'':$object->note_public;
389
-	            if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
388
+	            $notetoshow = empty($object->note_public) ? '' : $object->note_public;
389
+	            if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
390 390
 	            {
391 391
 	                // Get first sale rep
392 392
 	                if (is_object($object->thirdparty))
393 393
 	                {
394
-	                    $salereparray=$object->thirdparty->getSalesRepresentatives($user);
395
-	                    $salerepobj=new User($this->db);
394
+	                    $salereparray = $object->thirdparty->getSalesRepresentatives($user);
395
+	                    $salerepobj = new User($this->db);
396 396
 	                    $salerepobj->fetch($salereparray[0]['id']);
397
-	                    if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
397
+	                    if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
398 398
 	                }
399 399
 	            }
400 400
 
@@ -403,23 +403,23 @@  discard block
 block discarded – undo
403 403
 	            {
404 404
 					$tab_top -= 2;
405 405
 
406
-	                $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
406
+	                $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
407 407
 	                $pageposbeforenote = $pagenb;
408 408
 
409
-	                $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
409
+	                $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
410 410
 	                complete_substitutions_array($substitutionarray, $outputlangs, $object);
411 411
 	                $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
412 412
 
413 413
 
414 414
 	                $pdf->startTransaction();
415 415
 
416
-	                $pdf->SetFont('','', $default_font_size - 1);
417
-	                $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
416
+	                $pdf->SetFont('', '', $default_font_size - 1);
417
+	                $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
418 418
 	                // Description
419
-	                $pageposafternote=$pdf->getPage();
419
+	                $pageposafternote = $pdf->getPage();
420 420
 	                $posyafter = $pdf->GetY();
421 421
 
422
-	                if($pageposafternote>$pageposbeforenote )
422
+	                if ($pageposafternote > $pageposbeforenote)
423 423
 	                {
424 424
 	                    $pdf->rollbackTransaction(true);
425 425
 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	                    while ($pagenb < $pageposafternote) {
428 428
 	                        $pdf->AddPage();
429 429
 	                        $pagenb++;
430
-	                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
430
+	                        if (!empty($tplidx)) $pdf->useTemplate($tplidx);
431 431
 	                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
432 432
 	                        // $this->_pagefoot($pdf,$object,$outputlangs,1);
433 433
 	                        $pdf->setTopMargin($tab_top_newpage);
@@ -438,15 +438,15 @@  discard block
 block discarded – undo
438 438
 	                    // back to start
439 439
 	                    $pdf->setPage($pageposbeforenote);
440 440
 	                    $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
441
-	                    $pdf->SetFont('','', $default_font_size - 1);
442
-	                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
443
-	                    $pageposafternote=$pdf->getPage();
441
+	                    $pdf->SetFont('', '', $default_font_size - 1);
442
+	                    $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
443
+	                    $pageposafternote = $pdf->getPage();
444 444
 
445 445
 	                    $posyafter = $pdf->GetY();
446 446
 
447
-	                    if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
447
+	                    if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))	// There is no space left for total+free text
448 448
 	                    {
449
-	                        $pdf->AddPage('','',true);
449
+	                        $pdf->AddPage('', '', true);
450 450
 	                        $pagenb++;
451 451
 	                        $pageposafternote++;
452 452
 	                        $pdf->setPage($pageposafternote);
@@ -463,47 +463,47 @@  discard block
 block discarded – undo
463 463
 	                        $pdf->setPage($i);
464 464
 
465 465
 
466
-	                        $pdf->SetDrawColor(128,128,128);
466
+	                        $pdf->SetDrawColor(128, 128, 128);
467 467
 	                        // Draw note frame
468
-	                        if($i>$pageposbeforenote){
468
+	                        if ($i > $pageposbeforenote) {
469 469
 	                            $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
470
-	                            $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
470
+	                            $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
471 471
 	                        }
472
-	                        else{
472
+	                        else {
473 473
 	                            $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
474
-	                            $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
474
+	                            $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
475 475
 	                        }
476 476
 
477 477
 	                        // Add footer
478
-	                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
479
-	                        $this->_pagefoot($pdf,$object,$outputlangs,1);
478
+	                        $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
479
+	                        $this->_pagefoot($pdf, $object, $outputlangs, 1);
480 480
 
481 481
 	                        $i++;
482 482
 	                    }
483 483
 
484 484
 	                    // apply note frame to last page
485 485
 	                    $pdf->setPage($pageposafternote);
486
-	                    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
486
+	                    if (!empty($tplidx)) $pdf->useTemplate($tplidx);
487 487
 	                    if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
488
-	                    $height_note=$posyafter-$tab_top_newpage;
489
-	                    $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
488
+	                    $height_note = $posyafter - $tab_top_newpage;
489
+	                    $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
490 490
 	                }
491 491
 	                else // No pagebreak
492 492
 	                {
493 493
 	                    $pdf->commitTransaction();
494 494
 	                    $posyafter = $pdf->GetY();
495
-	                    $height_note=$posyafter-$tab_top;
496
-	                    $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
495
+	                    $height_note = $posyafter - $tab_top;
496
+	                    $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
497 497
 
498 498
 
499
-	                    if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
499
+	                    if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
500 500
 	                    {
501 501
 	                        // not enough space, need to add page
502
-	                        $pdf->AddPage('','',true);
502
+	                        $pdf->AddPage('', '', true);
503 503
 	                        $pagenb++;
504 504
 	                        $pageposafternote++;
505 505
 	                        $pdf->setPage($pageposafternote);
506
-	                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
506
+	                        if (!empty($tplidx)) $pdf->useTemplate($tplidx);
507 507
 	                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
508 508
 
509 509
 	                        $posyafter = $tab_top_newpage;
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 	                }
512 512
 
513 513
 	                $tab_height = $tab_height - $height_note;
514
-	                $tab_top = $posyafter +6;
514
+	                $tab_top = $posyafter + 6;
515 515
 	            }
516 516
 	            else
517 517
 	            {
518
-	                $height_note=0;
518
+	                $height_note = 0;
519 519
 	            }
520 520
 
521 521
 	            $iniY = $tab_top + 7;
@@ -523,48 +523,48 @@  discard block
 block discarded – undo
523 523
 	            $nexY = $tab_top + 7;
524 524
 
525 525
 	            // Use new auto collum system
526
-	            $this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
526
+	            $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
527 527
 
528 528
 	            // Loop on each lines
529
-	            $pageposbeforeprintlines=$pdf->getPage();
529
+	            $pageposbeforeprintlines = $pdf->getPage();
530 530
 	            $pagenb = $pageposbeforeprintlines;
531 531
 	            for ($i = 0; $i < $nblignes; $i++)
532 532
 	            {
533 533
 
534 534
 	                $curY = $nexY;
535
-	                $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
536
-	                $pdf->SetTextColor(0,0,0);
535
+	                $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
536
+	                $pdf->SetTextColor(0, 0, 0);
537 537
 
538 538
 	                // Define size of image if we need it
539
-	                $imglinesize=array();
540
-	                if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
539
+	                $imglinesize = array();
540
+	                if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
541 541
 
542 542
 	                $pdf->setTopMargin($tab_top_newpage);
543
-	                $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
544
-	                $pageposbefore=$pdf->getPage();
543
+	                $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
544
+	                $pageposbefore = $pdf->getPage();
545 545
 
546
-	                $showpricebeforepagebreak=1;
547
-	                $posYAfterImage=0;
548
-	                $posYAfterDescription=0;
546
+	                $showpricebeforepagebreak = 1;
547
+	                $posYAfterImage = 0;
548
+	                $posYAfterDescription = 0;
549 549
 
550
-	                if($this->getColumnStatus('photo'))
550
+	                if ($this->getColumnStatus('photo'))
551 551
 	                {
552 552
     	                // We start with Photo of product line
553
-    	                if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
553
+    	                if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// If photo too high, we moved completely on new page
554 554
     	                {
555
-    	                    $pdf->AddPage('','',true);
556
-    	                    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
557
-    	                    $pdf->setPage($pageposbefore+1);
555
+    	                    $pdf->AddPage('', '', true);
556
+    	                    if (!empty($tplidx)) $pdf->useTemplate($tplidx);
557
+    	                    $pdf->setPage($pageposbefore + 1);
558 558
 
559 559
     	                    $curY = $tab_top_newpage;
560
-    	                    $showpricebeforepagebreak=0;
560
+    	                    $showpricebeforepagebreak = 0;
561 561
     	                }
562 562
 
563 563
     	                if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
564 564
     	                {
565
-    	                    $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
565
+    	                    $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
566 566
     	                    // $pdf->Image does not increase value return by getY, so we save it manually
567
-    	                    $posYAfterImage=$curY+$imglinesize['height'];
567
+    	                    $posYAfterImage = $curY + $imglinesize['height'];
568 568
     	                }
569 569
 	                }
570 570
 
@@ -572,59 +572,59 @@  discard block
 block discarded – undo
572 572
 	                if ($this->getColumnStatus('desc'))
573 573
 	                {
574 574
     	                $pdf->startTransaction();
575
-    	                pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
576
-    	                $pageposafter=$pdf->getPage();
575
+    	                pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
576
+    	                $pageposafter = $pdf->getPage();
577 577
     	                if ($pageposafter > $pageposbefore)	// There is a pagebreak
578 578
     	                {
579 579
     	                    $pdf->rollbackTransaction(true);
580
-    	                    $pageposafter=$pageposbefore;
580
+    	                    $pageposafter = $pageposbefore;
581 581
     	                    //print $pageposafter.'-'.$pageposbefore;exit;
582
-    	                    $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
583
-    	                    pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
584
-    	                    $pageposafter=$pdf->getPage();
585
-    	                    $posyafter=$pdf->GetY();
582
+    	                    $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
583
+    	                    pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
584
+    	                    $pageposafter = $pdf->getPage();
585
+    	                    $posyafter = $pdf->GetY();
586 586
     	                    //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
587
-    	                    if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
587
+    	                    if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
588 588
     	                    {
589
-    	                        if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
589
+    	                        if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
590 590
     	                        {
591
-    	                            $pdf->AddPage('','',true);
592
-    	                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
593
-    	                            $pdf->setPage($pageposafter+1);
591
+    	                            $pdf->AddPage('', '', true);
592
+    	                            if (!empty($tplidx)) $pdf->useTemplate($tplidx);
593
+    	                            $pdf->setPage($pageposafter + 1);
594 594
     	                        }
595 595
     	                    }
596 596
     	                    else
597 597
     	                    {
598 598
     	                        // We found a page break
599
-    	                        $showpricebeforepagebreak=0;
599
+    	                        $showpricebeforepagebreak = 0;
600 600
     	                    }
601 601
     	                }
602 602
     	                else	// No pagebreak
603 603
     	                {
604 604
     	                    $pdf->commitTransaction();
605 605
     	                }
606
-    	                $posYAfterDescription=$pdf->GetY();
606
+    	                $posYAfterDescription = $pdf->GetY();
607 607
 	                }
608 608
 
609 609
 	                $nexY = $pdf->GetY();
610
-	                $pageposafter=$pdf->getPage();
610
+	                $pageposafter = $pdf->getPage();
611 611
 	                $pdf->setPage($pageposbefore);
612 612
 	                $pdf->setTopMargin($this->marge_haute);
613
-	                $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
613
+	                $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
614 614
 
615 615
 	                // We suppose that a too long description or photo were moved completely on next page
616 616
 	                if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
617 617
 	                    $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
618 618
 	                }
619 619
 
620
-	                $pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
620
+	                $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
621 621
 
622 622
 	                // VAT Rate
623 623
 	                if ($this->getColumnStatus('vat'))
624 624
 	                {
625 625
 	                    $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
626 626
 	                    $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
627
-	                    $nexY = max($pdf->GetY(),$nexY);
627
+	                    $nexY = max($pdf->GetY(), $nexY);
628 628
 	                }
629 629
 
630 630
 	                // Unit price before discount
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	                {
633 633
 	                    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
634 634
 	                    $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
635
-	                    $nexY = max($pdf->GetY(),$nexY);
635
+	                    $nexY = max($pdf->GetY(), $nexY);
636 636
 	                }
637 637
 
638 638
 	                // Quantity
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 	                {
642 642
 	                    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
643 643
 	                    $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
644
-	                    $nexY = max($pdf->GetY(),$nexY);
644
+	                    $nexY = max($pdf->GetY(), $nexY);
645 645
 	                }
646 646
 
647 647
 	                // Situation progress
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
 	                {
650 650
 	                    $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
651 651
 	                    $this->printStdColumnContent($pdf, $curY, 'progress', $progress);
652
-	                    $nexY = max($pdf->GetY(),$nexY);
652
+	                    $nexY = max($pdf->GetY(), $nexY);
653 653
 	                }
654 654
 
655 655
 	                // Unit
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 	                {
658 658
 	                    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
659 659
 	                    $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
660
-	                    $nexY = max($pdf->GetY(),$nexY);
660
+	                    $nexY = max($pdf->GetY(), $nexY);
661 661
 	                }
662 662
 
663 663
 	                // Discount on line
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 	                {
666 666
 	                    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
667 667
 	                    $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
668
-	                    $nexY = max($pdf->GetY(),$nexY);
668
+	                    $nexY = max($pdf->GetY(), $nexY);
669 669
 	                }
670 670
 
671 671
 	                // Total HT line
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 	                {
674 674
 	                    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
675 675
 	                    $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
676
-	                    $nexY = max($pdf->GetY(),$nexY);
676
+	                    $nexY = max($pdf->GetY(), $nexY);
677 677
 	                }
678 678
 
679 679
 
680
-	                $parameters=array(
680
+	                $parameters = array(
681 681
 	                    'object' => $object,
682 682
 	                    'i' => $i,
683 683
 	                    'pdf' =>& $pdf,
@@ -686,12 +686,12 @@  discard block
 block discarded – undo
686 686
 	                    'outputlangs' => $outputlangs,
687 687
 	                    'hidedetails' => $hidedetails
688 688
 	                );
689
-	                $reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this);    // Note that $object may have been modified by hook
689
+	                $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
690 690
 
691 691
 
692 692
 
693
-	                $sign=1;
694
-	                if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
693
+	                $sign = 1;
694
+	                if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
695 695
 	                // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
696 696
 	                $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
697 697
 	                if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
@@ -699,55 +699,55 @@  discard block
 block discarded – undo
699 699
 	                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
700 700
 	                    else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
701 701
 	                } else {
702
-	                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva;
703
-	                    else $tvaligne= $sign * $object->lines[$i]->total_tva;
702
+	                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
703
+	                    else $tvaligne = $sign * $object->lines[$i]->total_tva;
704 704
 	                }
705 705
 
706
-	                $localtax1ligne=$object->lines[$i]->total_localtax1;
707
-	                $localtax2ligne=$object->lines[$i]->total_localtax2;
708
-	                $localtax1_rate=$object->lines[$i]->localtax1_tx;
709
-	                $localtax2_rate=$object->lines[$i]->localtax2_tx;
710
-	                $localtax1_type=$object->lines[$i]->localtax1_type;
711
-	                $localtax2_type=$object->lines[$i]->localtax2_type;
706
+	                $localtax1ligne = $object->lines[$i]->total_localtax1;
707
+	                $localtax2ligne = $object->lines[$i]->total_localtax2;
708
+	                $localtax1_rate = $object->lines[$i]->localtax1_tx;
709
+	                $localtax2_rate = $object->lines[$i]->localtax2_tx;
710
+	                $localtax1_type = $object->lines[$i]->localtax1_type;
711
+	                $localtax2_type = $object->lines[$i]->localtax2_type;
712 712
 
713
-	                if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
714
-	                if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
715
-	                if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
713
+	                if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
714
+	                if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
715
+	                if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
716 716
 
717
-	                $vatrate=(string) $object->lines[$i]->tva_tx;
717
+	                $vatrate = (string) $object->lines[$i]->tva_tx;
718 718
 
719 719
 	                // Retrieve type from database for backward compatibility with old records
720
-	                if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
721
-	                    && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
720
+	                if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
721
+	                    && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
722 722
 	                {
723
-	                    $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0, $object->thirdparty, $mysoc);
723
+	                    $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
724 724
 	                    $localtax1_type = $localtaxtmp_array[0];
725 725
 	                    $localtax2_type = $localtaxtmp_array[2];
726 726
 	                }
727 727
 
728 728
 	                // retrieve global local tax
729 729
 	                if ($localtax1_type && $localtax1ligne != 0)
730
-	                    $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
730
+	                    $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
731 731
 	                    if ($localtax2_type && $localtax2ligne != 0)
732
-	                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
732
+	                        $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
733 733
 
734
-	                        if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
735
-	                        if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
734
+	                        if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
735
+	                        if (!isset($this->tva[$vatrate])) 				$this->tva[$vatrate] = 0;
736 736
 	                        $this->tva[$vatrate] += $tvaligne;
737 737
 
738
-	                        $nexY = max($nexY,$posYAfterImage);
738
+	                        $nexY = max($nexY, $posYAfterImage);
739 739
 
740 740
 	                        // Add line
741
-	                        if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
741
+	                        if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
742 742
 	                        {
743 743
 	                            $pdf->setPage($pageposafter);
744
-	                            $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
744
+	                            $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
745 745
 	                            //$pdf->SetDrawColor(190,190,200);
746
-	                            $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
746
+	                            $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
747 747
 	                            $pdf->SetLineStyle(array('dash'=>0));
748 748
 	                        }
749 749
 
750
-	                        $nexY+=2;    // Passe espace entre les lignes
750
+	                        $nexY += 2; // Passe espace entre les lignes
751 751
 
752 752
 	                        // Detect if some page were added automatically and output _tableau for past pages
753 753
 	                        while ($pagenb < $pageposafter)
@@ -761,14 +761,14 @@  discard block
 block discarded – undo
761 761
 	                            {
762 762
 	                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
763 763
 	                            }
764
-	                            $this->_pagefoot($pdf,$object,$outputlangs,1);
764
+	                            $this->_pagefoot($pdf, $object, $outputlangs, 1);
765 765
 	                            $pagenb++;
766 766
 	                            $pdf->setPage($pagenb);
767
-	                            $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
767
+	                            $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
768 768
 	                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
769 769
 	                        }
770 770
 
771
-	                        if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
771
+	                        if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
772 772
 	                        {
773 773
 	                            if ($pagenb == $pageposafter)
774 774
 	                            {
@@ -778,10 +778,10 @@  discard block
 block discarded – undo
778 778
 	                            {
779 779
 	                                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
780 780
 	                            }
781
-	                            $this->_pagefoot($pdf,$object,$outputlangs,1);
781
+	                            $this->_pagefoot($pdf, $object, $outputlangs, 1);
782 782
 	                            // New page
783 783
 	                            $pdf->AddPage();
784
-	                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
784
+	                            if (!empty($tplidx)) $pdf->useTemplate($tplidx);
785 785
 	                            $pagenb++;
786 786
 	                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
787 787
 	                        }
@@ -791,56 +791,56 @@  discard block
 block discarded – undo
791 791
 	            if ($pagenb == $pageposbeforeprintlines)
792 792
 	            {
793 793
 	                $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
794
-	                $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
794
+	                $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
795 795
 	            }
796 796
 	            else
797 797
 	            {
798 798
 	                $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
799
-	                $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
799
+	                $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
800 800
 	            }
801 801
 
802 802
 	            // Affiche zone infos
803
-	            $posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
803
+	            $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
804 804
 
805 805
 	            // Affiche zone totaux
806
-	            $posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
806
+	            $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
807 807
 
808 808
 	            // Affiche zone versements
809 809
 	            if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
810 810
 	            {
811
-	                $posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
811
+	                $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
812 812
 	            }
813 813
 
814 814
 	            // Pied de page
815
-	            $this->_pagefoot($pdf,$object,$outputlangs);
816
-	            if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
815
+	            $this->_pagefoot($pdf, $object, $outputlangs);
816
+	            if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
817 817
 
818 818
 	            $pdf->Close();
819 819
 
820
-	            $pdf->Output($file,'F');
820
+	            $pdf->Output($file, 'F');
821 821
 
822 822
 	            // Add pdfgeneration hook
823 823
 	            $hookmanager->initHooks(array('pdfgeneration'));
824
-	            $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
824
+	            $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
825 825
 	            global $action;
826
-	            $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
826
+	            $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
827 827
 
828
-	            if (! empty($conf->global->MAIN_UMASK))
828
+	            if (!empty($conf->global->MAIN_UMASK))
829 829
 	                @chmod($file, octdec($conf->global->MAIN_UMASK));
830 830
 
831 831
 	                $this->result = array('fullpath'=>$file);
832 832
 
833
-	                return 1;   // No error
833
+	                return 1; // No error
834 834
 	        }
835 835
 	        else
836 836
 	        {
837
-	            $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
837
+	            $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
838 838
 	            return 0;
839 839
 	        }
840 840
 	    }
841 841
 	    else
842 842
 	    {
843
-	        $this->error=$langs->transnoentities("ErrorConstantNotDefined","FAC_OUTPUTDIR");
843
+	        $this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
844 844
 	        return 0;
845 845
 	    }
846 846
 	}
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
 	{
860 860
 		global $conf;
861 861
 
862
-        $sign=1;
863
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
862
+        $sign = 1;
863
+        if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
864 864
 
865 865
         $tab3_posx = 120;
866 866
 		$tab3_top = $posy + 8;
@@ -873,113 +873,113 @@  discard block
 block discarded – undo
873 873
 
874 874
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
875 875
 
876
-		$title=$outputlangs->transnoentities("PaymentsAlreadyDone");
877
-		if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone");
876
+		$title = $outputlangs->transnoentities("PaymentsAlreadyDone");
877
+		if ($object->type == 2) $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
878 878
 
879
-		$pdf->SetFont('','', $default_font_size - 3);
879
+		$pdf->SetFont('', '', $default_font_size - 3);
880 880
 		$pdf->SetXY($tab3_posx, $tab3_top - 4);
881 881
 		$pdf->MultiCell(60, 3, $title, 0, 'L', 0);
882 882
 
883
-		$pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top);
883
+		$pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
884 884
 
885
-		$pdf->SetFont('','', $default_font_size - 4);
885
+		$pdf->SetFont('', '', $default_font_size - 4);
886 886
 		$pdf->SetXY($tab3_posx, $tab3_top);
887 887
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
888
-		$pdf->SetXY($tab3_posx+21, $tab3_top);
888
+		$pdf->SetXY($tab3_posx + 21, $tab3_top);
889 889
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
890
-		$pdf->SetXY($tab3_posx+40, $tab3_top);
890
+		$pdf->SetXY($tab3_posx + 40, $tab3_top);
891 891
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
892
-		$pdf->SetXY($tab3_posx+58, $tab3_top);
892
+		$pdf->SetXY($tab3_posx + 58, $tab3_top);
893 893
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
894 894
 
895
-		$pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
895
+		$pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
896 896
 
897
-		$y=0;
897
+		$y = 0;
898 898
 
899
-		$pdf->SetFont('','', $default_font_size - 4);
899
+		$pdf->SetFont('', '', $default_font_size - 4);
900 900
 
901 901
 
902 902
 		// Loop on each deposits and credit notes included
903 903
 		$sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva,  re.amount_ttc, re.multicurrency_amount_ttc,";
904
-		$sql.= " re.description, re.fk_facture_source,";
905
-		$sql.= " f.type, f.datef";
906
-		$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f";
907
-		$sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
908
-		$resql=$this->db->query($sql);
904
+		$sql .= " re.description, re.fk_facture_source,";
905
+		$sql .= " f.type, f.datef";
906
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f";
907
+		$sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
908
+		$resql = $this->db->query($sql);
909 909
 		if ($resql)
910 910
 		{
911 911
 			$num = $this->db->num_rows($resql);
912
-			$i=0;
913
-			$invoice=new Facture($this->db);
912
+			$i = 0;
913
+			$invoice = new Facture($this->db);
914 914
 			while ($i < $num)
915 915
 			{
916
-				$y+=3;
916
+				$y += 3;
917 917
 				$obj = $this->db->fetch_object($resql);
918 918
 
919
-				if ($obj->type == 2) $text=$outputlangs->trans("CreditNote");
920
-				elseif ($obj->type == 3) $text=$outputlangs->trans("Deposit");
921
-				else $text=$outputlangs->trans("UnknownType");
919
+				if ($obj->type == 2) $text = $outputlangs->trans("CreditNote");
920
+				elseif ($obj->type == 3) $text = $outputlangs->trans("Deposit");
921
+				else $text = $outputlangs->trans("UnknownType");
922 922
 
923 923
 				$invoice->fetch($obj->fk_facture_source);
924 924
 
925
-				$pdf->SetXY($tab3_posx, $tab3_top+$y);
926
-				$pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0);
927
-				$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
925
+				$pdf->SetXY($tab3_posx, $tab3_top + $y);
926
+				$pdf->MultiCell(20, 3, dol_print_date($obj->datef, 'day', false, $outputlangs, true), 0, 'L', 0);
927
+				$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
928 928
 				$pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
929
-				$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
929
+				$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
930 930
 				$pdf->MultiCell(20, 3, $text, 0, 'L', 0);
931
-				$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
931
+				$pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
932 932
 				$pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0);
933 933
 
934
-				$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
934
+				$pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
935 935
 
936 936
 				$i++;
937 937
 			}
938 938
 		}
939 939
 		else
940 940
 		{
941
-			$this->error=$this->db->lasterror();
941
+			$this->error = $this->db->lasterror();
942 942
 			return -1;
943 943
 		}
944 944
 
945 945
 		// Loop on each payment
946 946
 		// TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql
947 947
 		$sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
948
-		$sql.= " cp.code";
949
-		$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
950
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
951
-		$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
948
+		$sql .= " cp.code";
949
+		$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
950
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
951
+		$sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
952 952
 		//$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1";
953
-		$sql.= " ORDER BY p.datep";
953
+		$sql .= " ORDER BY p.datep";
954 954
 
955
-		$resql=$this->db->query($sql);
955
+		$resql = $this->db->query($sql);
956 956
 		if ($resql)
957 957
 		{
958 958
 			$num = $this->db->num_rows($resql);
959
-			$i=0;
959
+			$i = 0;
960 960
 			while ($i < $num) {
961
-				$y+=3;
961
+				$y += 3;
962 962
 				$row = $this->db->fetch_object($resql);
963 963
 
964
-				$pdf->SetXY($tab3_posx, $tab3_top+$y);
965
-				$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
966
-				$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
964
+				$pdf->SetXY($tab3_posx, $tab3_top + $y);
965
+				$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
966
+				$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
967 967
 				$pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
968
-				$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
969
-				$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
968
+				$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
969
+				$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
970 970
 
971 971
 				$pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
972
-				$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
972
+				$pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
973 973
 				$pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
974 974
 
975
-				$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
975
+				$pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
976 976
 
977 977
 				$i++;
978 978
 			}
979 979
 		}
980 980
 		else
981 981
 		{
982
-			$this->error=$this->db->lasterror();
982
+			$this->error = $this->db->lasterror();
983 983
 			return -1;
984 984
 		}
985 985
 	}
@@ -1000,35 +1000,35 @@  discard block
 block discarded – undo
1000 1000
 
1001 1001
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1002 1002
 
1003
-		$pdf->SetFont('','', $default_font_size - 1);
1003
+		$pdf->SetFont('', '', $default_font_size - 1);
1004 1004
 
1005 1005
 		// If France, show VAT mention if not applicable
1006 1006
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
1007 1007
 		{
1008
-			$pdf->SetFont('','B', $default_font_size - 2);
1008
+			$pdf->SetFont('', 'B', $default_font_size - 2);
1009 1009
 			$pdf->SetXY($this->marge_gauche, $posy);
1010 1010
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
1011 1011
 
1012
-			$posy=$pdf->GetY()+4;
1012
+			$posy = $pdf->GetY() + 4;
1013 1013
 		}
1014 1014
 
1015
-		$posxval=52;
1015
+		$posxval = 52;
1016 1016
 
1017 1017
 		// Show payments conditions
1018 1018
 		if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
1019 1019
 		{
1020
-			$pdf->SetFont('','B', $default_font_size - 2);
1020
+			$pdf->SetFont('', 'B', $default_font_size - 2);
1021 1021
 			$pdf->SetXY($this->marge_gauche, $posy);
1022 1022
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
1023 1023
 			$pdf->MultiCell(43, 4, $titre, 0, 'L');
1024 1024
 
1025
-			$pdf->SetFont('','', $default_font_size - 2);
1025
+			$pdf->SetFont('', '', $default_font_size - 2);
1026 1026
 			$pdf->SetXY($posxval, $posy);
1027
-			$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);
1028
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
1029
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
1027
+			$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);
1028
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
1029
+			$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
1030 1030
 
1031
-			$posy=$pdf->GetY()+3;
1031
+			$posy = $pdf->GetY() + 3;
1032 1032
 		}
1033 1033
 
1034 1034
 		if ($object->type != 2)
@@ -1047,13 +1047,13 @@  discard block
 block discarded – undo
1047 1047
 				$outputlangs->load("errors");
1048 1048
 
1049 1049
 				$pdf->SetXY($this->marge_gauche, $posy);
1050
-				$pdf->SetTextColor(200,0,0);
1051
-				$pdf->SetFont('','B', $default_font_size - 2);
1052
-				$this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup",$object->mode_reglement_code);
1053
-				$pdf->MultiCell(80, 3, $this->error,0,'L',0);
1054
-				$pdf->SetTextColor(0,0,0);
1050
+				$pdf->SetTextColor(200, 0, 0);
1051
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1052
+				$this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
1053
+				$pdf->MultiCell(80, 3, $this->error, 0, 'L', 0);
1054
+				$pdf->SetTextColor(0, 0, 0);
1055 1055
 
1056
-				$posy=$pdf->GetY()+1;
1056
+				$posy = $pdf->GetY() + 1;
1057 1057
 			}
1058 1058
 
1059 1059
 			// Show payment mode
@@ -1061,26 +1061,26 @@  discard block
 block discarded – undo
1061 1061
 			&& $object->mode_reglement_code != 'CHQ'
1062 1062
 			&& $object->mode_reglement_code != 'VIR')
1063 1063
 			{
1064
-				$pdf->SetFont('','B', $default_font_size - 2);
1064
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1065 1065
 				$pdf->SetXY($this->marge_gauche, $posy);
1066 1066
 				$titre = $outputlangs->transnoentities("PaymentMode").':';
1067 1067
 				$pdf->MultiCell(80, 5, $titre, 0, 'L');
1068 1068
 
1069
-				$pdf->SetFont('','', $default_font_size - 2);
1069
+				$pdf->SetFont('', '', $default_font_size - 2);
1070 1070
 				$pdf->SetXY($posxval, $posy);
1071
-				$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);
1072
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
1071
+				$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);
1072
+				$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
1073 1073
 
1074
-				$posy=$pdf->GetY()+2;
1074
+				$posy = $pdf->GetY() + 2;
1075 1075
 			}
1076 1076
 
1077 1077
 			// Show payment mode CHQ
1078 1078
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
1079 1079
 			{
1080 1080
 				// Si mode reglement non force ou si force a CHQ
1081
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
1081
+				if (!empty($conf->global->FACTURE_CHQ_NUMBER))
1082 1082
 				{
1083
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
1083
+					$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1084 1084
 
1085 1085
 					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
1086 1086
 					{
@@ -1088,31 +1088,31 @@  discard block
 block discarded – undo
1088 1088
 						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1089 1089
 
1090 1090
 						$pdf->SetXY($this->marge_gauche, $posy);
1091
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
1092
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
1093
-						$posy=$pdf->GetY()+1;
1091
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1092
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
1093
+						$posy = $pdf->GetY() + 1;
1094 1094
 
1095 1095
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1096 1096
 			            {
1097 1097
 							$pdf->SetXY($this->marge_gauche, $posy);
1098
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
1098
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1099 1099
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
1100
-							$posy=$pdf->GetY()+2;
1100
+							$posy = $pdf->GetY() + 2;
1101 1101
 			            }
1102 1102
 					}
1103 1103
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
1104 1104
 					{
1105 1105
 						$pdf->SetXY($this->marge_gauche, $posy);
1106
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
1107
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
1108
-						$posy=$pdf->GetY()+1;
1106
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1107
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
1108
+						$posy = $pdf->GetY() + 1;
1109 1109
 
1110 1110
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1111 1111
 			            {
1112 1112
 							$pdf->SetXY($this->marge_gauche, $posy);
1113
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
1113
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1114 1114
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1115
-							$posy=$pdf->GetY()+2;
1115
+							$posy = $pdf->GetY() + 2;
1116 1116
 			            }
1117 1117
 					}
1118 1118
 				}
@@ -1121,19 +1121,19 @@  discard block
 block discarded – undo
1121 1121
 			// If payment mode not forced or forced to VIR, show payment with BAN
1122 1122
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
1123 1123
 			{
1124
-				if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1124
+				if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
1125 1125
 				{
1126
-					$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1127
-					if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1126
+					$bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1127
+					if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1128 1128
 					$account = new Account($this->db);
1129 1129
 					$account->fetch($bankid);
1130 1130
 
1131
-					$curx=$this->marge_gauche;
1132
-					$cury=$posy;
1131
+					$curx = $this->marge_gauche;
1132
+					$cury = $posy;
1133 1133
 
1134
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
1134
+					$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1135 1135
 
1136
-					$posy+=2;
1136
+					$posy += 2;
1137 1137
 				}
1138 1138
 			}
1139 1139
 		}
@@ -1154,47 +1154,47 @@  discard block
 block discarded – undo
1154 1154
 	 */
1155 1155
 	private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1156 1156
 	{
1157
-		global $conf,$mysoc;
1157
+		global $conf, $mysoc;
1158 1158
 
1159
-        $sign=1;
1160
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1159
+        $sign = 1;
1160
+        if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
1161 1161
 
1162 1162
         $default_font_size = pdf_getPDFFontSize($outputlangs);
1163 1163
 
1164 1164
 		$tab2_top = $posy;
1165 1165
 		$tab2_hl = 4;
1166
-		$pdf->SetFont('','', $default_font_size - 1);
1166
+		$pdf->SetFont('', '', $default_font_size - 1);
1167 1167
 
1168 1168
 		// Tableau total
1169 1169
 		$col1x = 120; $col2x = 170;
1170 1170
 		if ($this->page_largeur < 210) // To work with US executive format
1171 1171
 		{
1172
-			$col2x-=20;
1172
+			$col2x -= 20;
1173 1173
 		}
1174 1174
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1175 1175
 
1176
-		$useborder=0;
1176
+		$useborder = 0;
1177 1177
 		$index = 0;
1178 1178
 
1179 1179
 		// Total HT
1180
-		$pdf->SetFillColor(255,255,255);
1180
+		$pdf->SetFillColor(255, 255, 255);
1181 1181
 		$pdf->SetXY($col1x, $tab2_top + 0);
1182
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1182
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1183 1183
 
1184 1184
 		$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
1185 1185
 		$pdf->SetXY($col2x, $tab2_top + 0);
1186
-		$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
1186
+		$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
1187 1187
 
1188 1188
 		// Show VAT by rates and total
1189
-		$pdf->SetFillColor(248,248,248);
1189
+		$pdf->SetFillColor(248, 248, 248);
1190 1190
 
1191 1191
 		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1192 1192
 
1193
-		$this->atleastoneratenotnull=0;
1193
+		$this->atleastoneratenotnull = 0;
1194 1194
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1195 1195
 		{
1196
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1197
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1196
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1197
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1198 1198
 			{
1199 1199
 				// Nothing to do
1200 1200
 			}
@@ -1205,29 +1205,29 @@  discard block
 block discarded – undo
1205 1205
 				//Local tax 1 before VAT
1206 1206
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1207 1207
 				//{
1208
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1208
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1209 1209
 					{
1210
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1210
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1211 1211
 
1212
-						foreach( $localtax_rate as $tvakey => $tvaval )
1212
+						foreach ($localtax_rate as $tvakey => $tvaval)
1213 1213
 						{
1214
-							if ($tvakey!=0)    // On affiche pas taux 0
1214
+							if ($tvakey != 0)    // On affiche pas taux 0
1215 1215
 							{
1216 1216
 								//$this->atleastoneratenotnull++;
1217 1217
 
1218 1218
 								$index++;
1219 1219
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1220 1220
 
1221
-								$tvacompl='';
1222
-								if (preg_match('/\*/',$tvakey))
1221
+								$tvacompl = '';
1222
+								if (preg_match('/\*/', $tvakey))
1223 1223
 								{
1224
-									$tvakey=str_replace('*','',$tvakey);
1224
+									$tvakey = str_replace('*', '', $tvakey);
1225 1225
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1226 1226
 								}
1227 1227
 
1228
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1229
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1230
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1228
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1229
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1230
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1231 1231
 
1232 1232
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1233 1233
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1238,13 +1238,13 @@  discard block
 block discarded – undo
1238 1238
 				//Local tax 2 before VAT
1239 1239
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1240 1240
 				//{
1241
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1241
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1242 1242
 					{
1243
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1243
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1244 1244
 
1245
-						foreach( $localtax_rate as $tvakey => $tvaval )
1245
+						foreach ($localtax_rate as $tvakey => $tvaval)
1246 1246
 						{
1247
-							if ($tvakey!=0)    // On affiche pas taux 0
1247
+							if ($tvakey != 0)    // On affiche pas taux 0
1248 1248
 							{
1249 1249
 								//$this->atleastoneratenotnull++;
1250 1250
 
@@ -1253,15 +1253,15 @@  discard block
 block discarded – undo
1253 1253
 								$index++;
1254 1254
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1255 1255
 
1256
-								$tvacompl='';
1257
-								if (preg_match('/\*/',$tvakey))
1256
+								$tvacompl = '';
1257
+								if (preg_match('/\*/', $tvakey))
1258 1258
 								{
1259
-									$tvakey=str_replace('*','',$tvakey);
1259
+									$tvakey = str_replace('*', '', $tvakey);
1260 1260
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1261 1261
 								}
1262
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1263
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1264
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1262
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1263
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1264
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1265 1265
 
1266 1266
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1267 1267
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1276,20 +1276,20 @@  discard block
 block discarded – undo
1276 1276
 				if ($object->situation_cycle_ref && $object->situation_counter > 1) {
1277 1277
 
1278 1278
 					$sum_pdf_tva = 0;
1279
-					foreach($this->tva as $tvakey => $tvaval){
1280
-						$sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object
1279
+					foreach ($this->tva as $tvakey => $tvaval) {
1280
+						$sum_pdf_tva += $tvaval; // sum VAT amounts to compare to object
1281 1281
 					}
1282 1282
 
1283
-					if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one)
1283
+					if ($sum_pdf_tva != $object->total_tva) { // apply coef to recover the VAT object amount (the good one)
1284 1284
 						$coef_fix_tva = $object->total_tva / $sum_pdf_tva;
1285 1285
 
1286
-						foreach($this->tva as $tvakey => $tvaval) {
1287
-							$this->tva[$tvakey]=$tvaval * $coef_fix_tva;
1286
+						foreach ($this->tva as $tvakey => $tvaval) {
1287
+							$this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1288 1288
 						}
1289 1289
 					}
1290 1290
 				}
1291 1291
 
1292
-				foreach($this->tva as $tvakey => $tvaval)
1292
+				foreach ($this->tva as $tvakey => $tvaval)
1293 1293
 				{
1294 1294
 					if ($tvakey != 0)    // On affiche pas taux 0
1295 1295
 					{
@@ -1298,15 +1298,15 @@  discard block
 block discarded – undo
1298 1298
 						$index++;
1299 1299
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1300 1300
 
1301
-						$tvacompl='';
1302
-						if (preg_match('/\*/',$tvakey))
1301
+						$tvacompl = '';
1302
+						if (preg_match('/\*/', $tvakey))
1303 1303
 						{
1304
-							$tvakey=str_replace('*','',$tvakey);
1304
+							$tvakey = str_replace('*', '', $tvakey);
1305 1305
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1306 1306
 						}
1307
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1308
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1309
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1307
+						$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
1308
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
1309
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1310 1310
 
1311 1311
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1312 1312
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1316,11 +1316,11 @@  discard block
 block discarded – undo
1316 1316
 				//Local tax 1 after VAT
1317 1317
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1318 1318
 				//{
1319
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1319
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1320 1320
 					{
1321
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1321
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1322 1322
 
1323
-						foreach( $localtax_rate as $tvakey => $tvaval )
1323
+						foreach ($localtax_rate as $tvakey => $tvaval)
1324 1324
 						{
1325 1325
 							if ($tvakey != 0)    // On affiche pas taux 0
1326 1326
 							{
@@ -1329,16 +1329,16 @@  discard block
 block discarded – undo
1329 1329
 								$index++;
1330 1330
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1331 1331
 
1332
-								$tvacompl='';
1333
-								if (preg_match('/\*/',$tvakey))
1332
+								$tvacompl = '';
1333
+								if (preg_match('/\*/', $tvakey))
1334 1334
 								{
1335
-									$tvakey=str_replace('*','',$tvakey);
1335
+									$tvakey = str_replace('*', '', $tvakey);
1336 1336
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1337 1337
 								}
1338
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1339
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1338
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1339
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1340 1340
 
1341
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1341
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1342 1342
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1343 1343
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1344 1344
 							}
@@ -1348,11 +1348,11 @@  discard block
 block discarded – undo
1348 1348
 				//Local tax 2 after VAT
1349 1349
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1350 1350
 				//{
1351
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1351
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1352 1352
 					{
1353
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1353
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1354 1354
 
1355
-						foreach( $localtax_rate as $tvakey => $tvaval )
1355
+						foreach ($localtax_rate as $tvakey => $tvaval)
1356 1356
 						{
1357 1357
 						    // retrieve global local tax
1358 1358
 							if ($tvakey != 0)    // On affiche pas taux 0
@@ -1362,16 +1362,16 @@  discard block
 block discarded – undo
1362 1362
 								$index++;
1363 1363
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1364 1364
 
1365
-								$tvacompl='';
1366
-								if (preg_match('/\*/',$tvakey))
1365
+								$tvacompl = '';
1366
+								if (preg_match('/\*/', $tvakey))
1367 1367
 								{
1368
-									$tvakey=str_replace('*','',$tvakey);
1368
+									$tvakey = str_replace('*', '', $tvakey);
1369 1369
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1370 1370
 								}
1371
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1371
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1372 1372
 
1373
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1374
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1373
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1374
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1375 1375
 
1376 1376
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1377 1377
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 				{
1386 1386
 					$index++;
1387 1387
 					$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1388
-					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
1388
+					$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
1389 1389
 
1390 1390
 					$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1391 1391
 					$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
@@ -1394,29 +1394,29 @@  discard block
 block discarded – undo
1394 1394
 				// Total TTC
1395 1395
 				$index++;
1396 1396
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1397
-				$pdf->SetTextColor(0,0,60);
1398
-				$pdf->SetFillColor(224,224,224);
1399
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1397
+				$pdf->SetTextColor(0, 0, 60);
1398
+				$pdf->SetFillColor(224, 224, 224);
1399
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1400 1400
 
1401 1401
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1402 1402
 				$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1403 1403
 			}
1404 1404
 		}
1405 1405
 
1406
-		$pdf->SetTextColor(0,0,0);
1406
+		$pdf->SetTextColor(0, 0, 0);
1407 1407
 
1408
-		$creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
1409
-		$depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
1408
+		$creditnoteamount = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
1409
+		$depositsamount = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
1410 1410
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1411 1411
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1412
-		if ($object->paye) $resteapayer=0;
1412
+		if ($object->paye) $resteapayer = 0;
1413 1413
 
1414 1414
 		if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
1415 1415
 		{
1416 1416
 			// Already paid + Deposits
1417 1417
 			$index++;
1418 1418
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1419
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
1419
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
1420 1420
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1421 1421
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
1422 1422
 
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 			{
1426 1426
 				$index++;
1427 1427
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1428
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
1428
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0);
1429 1429
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1430 1430
 				$pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
1431 1431
 			}
@@ -1434,26 +1434,26 @@  discard block
 block discarded – undo
1434 1434
 			if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT)
1435 1435
 			{
1436 1436
 				$index++;
1437
-				$pdf->SetFillColor(255,255,255);
1437
+				$pdf->SetFillColor(255, 255, 255);
1438 1438
 
1439 1439
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1440
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
1440
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
1441 1441
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1442 1442
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
1443 1443
 
1444
-				$resteapayer=0;
1444
+				$resteapayer = 0;
1445 1445
 			}
1446 1446
 
1447 1447
 			$index++;
1448
-			$pdf->SetTextColor(0,0,60);
1449
-			$pdf->SetFillColor(224,224,224);
1448
+			$pdf->SetTextColor(0, 0, 60);
1449
+			$pdf->SetFillColor(224, 224, 224);
1450 1450
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1451
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1451
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1452 1452
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1453 1453
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1454 1454
 
1455
-			$pdf->SetFont('','', $default_font_size - 1);
1456
-			$pdf->SetTextColor(0,0,0);
1455
+			$pdf->SetFont('', '', $default_font_size - 1);
1456
+			$pdf->SetTextColor(0, 0, 0);
1457 1457
 		}
1458 1458
 
1459 1459
 		$index++;
@@ -1473,61 +1473,61 @@  discard block
 block discarded – undo
1473 1473
 	 *   @param		string		$currency		Currency code
1474 1474
 	 *   @return	void
1475 1475
 	 */
1476
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1476
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1477 1477
 	{
1478 1478
 		global $conf;
1479 1479
 
1480 1480
 		// Force to disable hidetop and hidebottom
1481
-		$hidebottom=0;
1482
-		if ($hidetop) $hidetop=-1;
1481
+		$hidebottom = 0;
1482
+		if ($hidetop) $hidetop = -1;
1483 1483
 
1484 1484
 		$currency = !empty($currency) ? $currency : $conf->currency;
1485 1485
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1486 1486
 
1487 1487
 		// Amount in (at tab_top - 1)
1488
-		$pdf->SetTextColor(0,0,0);
1489
-		$pdf->SetFont('','', $default_font_size - 2);
1488
+		$pdf->SetTextColor(0, 0, 0);
1489
+		$pdf->SetFont('', '', $default_font_size - 2);
1490 1490
 
1491 1491
 		if (empty($hidetop))
1492 1492
 		{
1493
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1494
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1493
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1494
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1495 1495
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1496 1496
 
1497 1497
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1498
-			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));
1498
+			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));
1499 1499
 		}
1500 1500
 
1501
-		$pdf->SetDrawColor(128,128,128);
1502
-		$pdf->SetFont('','', $default_font_size - 1);
1501
+		$pdf->SetDrawColor(128, 128, 128);
1502
+		$pdf->SetFont('', '', $default_font_size - 1);
1503 1503
 
1504 1504
 		// Output Rect
1505
-		$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
1505
+		$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
1506 1506
 
1507 1507
 
1508 1508
 		foreach ($this->cols as $colKey => $colDef)
1509 1509
 		{
1510
-		    if(!$this->getColumnStatus($colKey)) continue;
1510
+		    if (!$this->getColumnStatus($colKey)) continue;
1511 1511
 
1512 1512
 		    // get title label
1513
-		    $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
1513
+		    $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']);
1514 1514
 
1515 1515
 		    // Add column separator
1516
-		    if(!empty($colDef['border-left'])){
1516
+		    if (!empty($colDef['border-left'])) {
1517 1517
 		        $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
1518 1518
 		    }
1519 1519
 
1520 1520
 		    if (empty($hidetop))
1521 1521
 		    {
1522
-		      $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
1522
+		      $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]);
1523 1523
 
1524
-		      $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
1525
-		      $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
1524
+		      $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1];
1525
+		      $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']);
1526 1526
 		    }
1527 1527
 		}
1528 1528
 
1529
-		if (empty($hidetop)){
1530
-			$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
1529
+		if (empty($hidetop)) {
1530
+			$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
1531 1531
 		}
1532 1532
 	}
1533 1533
 
@@ -1549,162 +1549,162 @@  discard block
 block discarded – undo
1549 1549
 
1550 1550
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1551 1551
 
1552
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1552
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1553 1553
 
1554 1554
 		// Show Draft Watermark
1555
-		if($object->statut==Facture::STATUS_DRAFT && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
1555
+		if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
1556 1556
         {
1557
-		      pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
1557
+		      pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
1558 1558
         }
1559 1559
 
1560
-		$pdf->SetTextColor(0,0,60);
1561
-		$pdf->SetFont('','B', $default_font_size + 3);
1560
+		$pdf->SetTextColor(0, 0, 60);
1561
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1562 1562
 
1563 1563
 		$w = 110;
1564 1564
 
1565
-		$posy=$this->marge_haute;
1566
-        $posx=$this->page_largeur-$this->marge_droite-$w;
1565
+		$posy = $this->marge_haute;
1566
+        $posx = $this->page_largeur - $this->marge_droite - $w;
1567 1567
 
1568
-		$pdf->SetXY($this->marge_gauche,$posy);
1568
+		$pdf->SetXY($this->marge_gauche, $posy);
1569 1569
 
1570 1570
 		// Logo
1571 1571
 		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1572 1572
 		{
1573
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1573
+			$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1574 1574
 			if ($this->emetteur->logo)
1575 1575
 			{
1576 1576
 				if (is_readable($logo))
1577 1577
 				{
1578
-				    $height=pdf_getHeightForLogo($logo);
1579
-					$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1578
+				    $height = pdf_getHeightForLogo($logo);
1579
+					$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1580 1580
 				}
1581 1581
 				else
1582 1582
 				{
1583
-					$pdf->SetTextColor(200,0,0);
1584
-					$pdf->SetFont('','B',$default_font_size - 2);
1585
-					$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1583
+					$pdf->SetTextColor(200, 0, 0);
1584
+					$pdf->SetFont('', 'B', $default_font_size - 2);
1585
+					$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1586 1586
 					$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1587 1587
 				}
1588 1588
 			}
1589 1589
 			else
1590 1590
 			{
1591
-				$text=$this->emetteur->name;
1591
+				$text = $this->emetteur->name;
1592 1592
 				$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1593 1593
 			}
1594 1594
 		}
1595 1595
 
1596
-		$pdf->SetFont('','B', $default_font_size + 3);
1597
-		$pdf->SetXY($posx,$posy);
1598
-		$pdf->SetTextColor(0,0,60);
1599
-		$title=$outputlangs->transnoentities("PdfInvoiceTitle");
1600
-		if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement");
1601
-		if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir");
1602
-		if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit");
1603
-		if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProForma");
1604
-		if ($this->situationinvoice) $title=$outputlangs->transnoentities("InvoiceSituation");
1596
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1597
+		$pdf->SetXY($posx, $posy);
1598
+		$pdf->SetTextColor(0, 0, 60);
1599
+		$title = $outputlangs->transnoentities("PdfInvoiceTitle");
1600
+		if ($object->type == 1) $title = $outputlangs->transnoentities("InvoiceReplacement");
1601
+		if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir");
1602
+		if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit");
1603
+		if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma");
1604
+		if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation");
1605 1605
 		$pdf->MultiCell($w, 3, $title, '', 'R');
1606 1606
 
1607
-		$pdf->SetFont('','B',$default_font_size);
1607
+		$pdf->SetFont('', 'B', $default_font_size);
1608 1608
 
1609
-		$posy+=5;
1610
-		$pdf->SetXY($posx,$posy);
1611
-		$pdf->SetTextColor(0,0,60);
1612
-		$textref=$outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref);
1609
+		$posy += 5;
1610
+		$pdf->SetXY($posx, $posy);
1611
+		$pdf->SetTextColor(0, 0, 60);
1612
+		$textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
1613 1613
 		if ($object->statut == Facture::STATUS_DRAFT)
1614 1614
 		{
1615
-			$pdf->SetTextColor(128,0,0);
1616
-			$textref.=' - '.$outputlangs->transnoentities("NotValidated");
1615
+			$pdf->SetTextColor(128, 0, 0);
1616
+			$textref .= ' - '.$outputlangs->transnoentities("NotValidated");
1617 1617
 		}
1618 1618
 		$pdf->MultiCell($w, 4, $textref, '', 'R');
1619 1619
 
1620
-		$posy+=1;
1621
-		$pdf->SetFont('','', $default_font_size - 2);
1620
+		$posy += 1;
1621
+		$pdf->SetFont('', '', $default_font_size - 2);
1622 1622
 
1623 1623
 		if ($object->ref_client)
1624 1624
 		{
1625
-			$posy+=4;
1626
-			$pdf->SetXY($posx,$posy);
1627
-			$pdf->SetTextColor(0,0,60);
1628
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1625
+			$posy += 4;
1626
+			$pdf->SetXY($posx, $posy);
1627
+			$pdf->SetTextColor(0, 0, 60);
1628
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1629 1629
 		}
1630 1630
 
1631
-		$objectidnext=$object->getIdReplacingInvoice('validated');
1631
+		$objectidnext = $object->getIdReplacingInvoice('validated');
1632 1632
 		if ($object->type == 0 && $objectidnext)
1633 1633
 		{
1634
-			$objectreplacing=new Facture($this->db);
1634
+			$objectreplacing = new Facture($this->db);
1635 1635
 			$objectreplacing->fetch($objectidnext);
1636 1636
 
1637
-			$posy+=3;
1638
-			$pdf->SetXY($posx,$posy);
1639
-			$pdf->SetTextColor(0,0,60);
1637
+			$posy += 3;
1638
+			$pdf->SetXY($posx, $posy);
1639
+			$pdf->SetTextColor(0, 0, 60);
1640 1640
 			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
1641 1641
 		}
1642 1642
 		if ($object->type == 1)
1643 1643
 		{
1644
-			$objectreplaced=new Facture($this->db);
1644
+			$objectreplaced = new Facture($this->db);
1645 1645
 			$objectreplaced->fetch($object->fk_facture_source);
1646 1646
 
1647
-			$posy+=4;
1648
-			$pdf->SetXY($posx,$posy);
1649
-			$pdf->SetTextColor(0,0,60);
1647
+			$posy += 4;
1648
+			$pdf->SetXY($posx, $posy);
1649
+			$pdf->SetTextColor(0, 0, 60);
1650 1650
 			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
1651 1651
 		}
1652 1652
 		if ($object->type == 2 && !empty($object->fk_facture_source))
1653 1653
 		{
1654
-			$objectreplaced=new Facture($this->db);
1654
+			$objectreplaced = new Facture($this->db);
1655 1655
 			$objectreplaced->fetch($object->fk_facture_source);
1656 1656
 
1657
-			$posy+=3;
1658
-			$pdf->SetXY($posx,$posy);
1659
-			$pdf->SetTextColor(0,0,60);
1657
+			$posy += 3;
1658
+			$pdf->SetXY($posx, $posy);
1659
+			$pdf->SetTextColor(0, 0, 60);
1660 1660
 			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
1661 1661
 		}
1662 1662
 
1663
-		$posy+=4;
1664
-		$pdf->SetXY($posx,$posy);
1665
-		$pdf->SetTextColor(0,0,60);
1666
-		$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice")." : " . dol_print_date($object->date,"day",false,$outputlangs), '', 'R');
1663
+		$posy += 4;
1664
+		$pdf->SetXY($posx, $posy);
1665
+		$pdf->SetTextColor(0, 0, 60);
1666
+		$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice")." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
1667 1667
 
1668
-		if (! empty($conf->global->INVOICE_POINTOFTAX_DATE))
1668
+		if (!empty($conf->global->INVOICE_POINTOFTAX_DATE))
1669 1669
 		{
1670
-			$posy+=4;
1671
-			$pdf->SetXY($posx,$posy);
1672
-			$pdf->SetTextColor(0,0,60);
1673
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : " . dol_print_date($object->date_pointoftax,"day",false,$outputlangs), '', 'R');
1670
+			$posy += 4;
1671
+			$pdf->SetXY($posx, $posy);
1672
+			$pdf->SetTextColor(0, 0, 60);
1673
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : ".dol_print_date($object->date_pointoftax, "day", false, $outputlangs), '', 'R');
1674 1674
 		}
1675 1675
 
1676 1676
 		if ($object->type != 2)
1677 1677
 		{
1678
-			$posy+=3;
1679
-			$pdf->SetXY($posx,$posy);
1680
-			$pdf->SetTextColor(0,0,60);
1681
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateDue")." : " . dol_print_date($object->date_lim_reglement,"day",false,$outputlangs,true), '', 'R');
1678
+			$posy += 3;
1679
+			$pdf->SetXY($posx, $posy);
1680
+			$pdf->SetTextColor(0, 0, 60);
1681
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateDue")." : ".dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R');
1682 1682
 		}
1683 1683
 
1684 1684
 		if ($object->thirdparty->code_client)
1685 1685
 		{
1686
-			$posy+=3;
1687
-			$pdf->SetXY($posx,$posy);
1688
-			$pdf->SetTextColor(0,0,60);
1689
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1686
+			$posy += 3;
1687
+			$pdf->SetXY($posx, $posy);
1688
+			$pdf->SetTextColor(0, 0, 60);
1689
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1690 1690
 		}
1691 1691
 
1692 1692
 		// Get contact
1693 1693
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1694 1694
 		{
1695
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1695
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1696 1696
 		    if (count($arrayidcontact) > 0)
1697 1697
 		    {
1698
-		        $usertmp=new User($this->db);
1698
+		        $usertmp = new User($this->db);
1699 1699
 		        $usertmp->fetch($arrayidcontact[0]);
1700
-                $posy+=4;
1701
-                $pdf->SetXY($posx,$posy);
1702
-		        $pdf->SetTextColor(0,0,60);
1700
+                $posy += 4;
1701
+                $pdf->SetXY($posx, $posy);
1702
+		        $pdf->SetTextColor(0, 0, 60);
1703 1703
 		        $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1704 1704
 		    }
1705 1705
 		}
1706 1706
 
1707
-		$posy+=1;
1707
+		$posy += 1;
1708 1708
 
1709 1709
 		$top_shift = 0;
1710 1710
 		// Show list of linked objects
@@ -1721,43 +1721,43 @@  discard block
 block discarded – undo
1721 1721
 			$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1722 1722
 
1723 1723
 			// Show sender
1724
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1725
-			$posy+=$top_shift;
1726
-			$posx=$this->marge_gauche;
1727
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1724
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1725
+			$posy += $top_shift;
1726
+			$posx = $this->marge_gauche;
1727
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1728 1728
 
1729
-			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1730
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1729
+			$hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1730
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1731 1731
 
1732 1732
 
1733 1733
 			// Show sender frame
1734
-			$pdf->SetTextColor(0,0,0);
1735
-			$pdf->SetFont('','', $default_font_size - 2);
1736
-			$pdf->SetXY($posx,$posy-5);
1737
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1738
-			$pdf->SetXY($posx,$posy);
1739
-			$pdf->SetFillColor(230,230,230);
1734
+			$pdf->SetTextColor(0, 0, 0);
1735
+			$pdf->SetFont('', '', $default_font_size - 2);
1736
+			$pdf->SetXY($posx, $posy - 5);
1737
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1738
+			$pdf->SetXY($posx, $posy);
1739
+			$pdf->SetFillColor(230, 230, 230);
1740 1740
 			$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1741
-			$pdf->SetTextColor(0,0,60);
1741
+			$pdf->SetTextColor(0, 0, 60);
1742 1742
 
1743 1743
 			// Show sender name
1744
-			$pdf->SetXY($posx+2,$posy+3);
1745
-			$pdf->SetFont('','B', $default_font_size);
1746
-			$pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1747
-			$posy=$pdf->getY();
1744
+			$pdf->SetXY($posx + 2, $posy + 3);
1745
+			$pdf->SetFont('', 'B', $default_font_size);
1746
+			$pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1747
+			$posy = $pdf->getY();
1748 1748
 
1749 1749
 			// Show sender information
1750
-			$pdf->SetXY($posx+2,$posy);
1751
-			$pdf->SetFont('','', $default_font_size - 1);
1752
-			$pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L');
1750
+			$pdf->SetXY($posx + 2, $posy);
1751
+			$pdf->SetFont('', '', $default_font_size - 1);
1752
+			$pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
1753 1753
 
1754 1754
 			// If BILLING contact defined on invoice, we use it
1755
-			$usecontact=false;
1756
-			$arrayidcontact=$object->getIdContact('external','BILLING');
1755
+			$usecontact = false;
1756
+			$arrayidcontact = $object->getIdContact('external', 'BILLING');
1757 1757
 			if (count($arrayidcontact) > 0)
1758 1758
 			{
1759
-				$usecontact=true;
1760
-				$result=$object->fetch_contact($arrayidcontact[0]);
1759
+				$usecontact = true;
1760
+				$result = $object->fetch_contact($arrayidcontact[0]);
1761 1761
 			}
1762 1762
 
1763 1763
 			//Recipient name
@@ -1768,39 +1768,39 @@  discard block
 block discarded – undo
1768 1768
 				$thirdparty = $object->thirdparty;
1769 1769
 			}
1770 1770
 
1771
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1771
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1772 1772
 
1773
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1773
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1774 1774
 
1775 1775
 			// Show recipient
1776
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1777
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1778
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1779
-			$posy+=$top_shift;
1780
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1781
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1776
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1777
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1778
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1779
+			$posy += $top_shift;
1780
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1781
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1782 1782
 
1783 1783
 			// Show recipient frame
1784
-			$pdf->SetTextColor(0,0,0);
1785
-			$pdf->SetFont('','', $default_font_size - 2);
1786
-			$pdf->SetXY($posx+2,$posy-5);
1787
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1784
+			$pdf->SetTextColor(0, 0, 0);
1785
+			$pdf->SetFont('', '', $default_font_size - 2);
1786
+			$pdf->SetXY($posx + 2, $posy - 5);
1787
+			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1788 1788
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1789 1789
 
1790 1790
 			// Show recipient name
1791
-			$pdf->SetXY($posx+2,$posy+3);
1792
-			$pdf->SetFont('','B', $default_font_size);
1791
+			$pdf->SetXY($posx + 2, $posy + 3);
1792
+			$pdf->SetFont('', 'B', $default_font_size);
1793 1793
 			$pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1794 1794
 
1795 1795
 			$posy = $pdf->getY();
1796 1796
 
1797 1797
 			// Show recipient information
1798
-			$pdf->SetFont('','', $default_font_size - 1);
1799
-			$pdf->SetXY($posx+2,$posy);
1798
+			$pdf->SetFont('', '', $default_font_size - 1);
1799
+			$pdf->SetXY($posx + 2, $posy);
1800 1800
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1801 1801
 		}
1802 1802
 
1803
-		$pdf->SetTextColor(0,0,0);
1803
+		$pdf->SetTextColor(0, 0, 0);
1804 1804
 		return $top_shift;
1805 1805
 	}
1806 1806
 
@@ -1813,11 +1813,11 @@  discard block
 block discarded – undo
1813 1813
 	 *      @param	int			$hidefreetext		1=Hide free text
1814 1814
 	 *      @return	int								Return height of bottom margin including footer text
1815 1815
 	 */
1816
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1816
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1817 1817
 	{
1818 1818
 		global $conf;
1819
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1820
-		return pdf_pagefoot($pdf,$outputlangs,'INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1819
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1820
+		return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1821 1821
 	}
1822 1822
 
1823 1823
 	/**
@@ -1830,20 +1830,20 @@  discard block
 block discarded – undo
1830 1830
      *      @param	int			   $hideref			Do not show ref
1831 1831
 	 *      @return	null
1832 1832
 	 */
1833
-    function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
1833
+    function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1834 1834
     {
1835 1835
 	    global $conf, $hookmanager;
1836 1836
 
1837 1837
 	    // Default field style for content
1838 1838
 	    $this->defaultContentsFieldsStyle = array(
1839 1839
 	        'align' => 'R', // R,C,L
1840
-	        'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1840
+	        'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1841 1841
 	    );
1842 1842
 
1843 1843
 	    // Default field style for content
1844 1844
 	    $this->defaultTitlesFieldsStyle = array(
1845 1845
 	        'align' => 'C', // R,C,L
1846
-	        'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1846
+	        'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1847 1847
 	    );
1848 1848
 
1849 1849
 	    /*
@@ -1864,7 +1864,7 @@  discard block
 block discarded – undo
1864 1864
 	    );
1865 1865
 	    */
1866 1866
 
1867
-	    $rank=0; // do not use negative rank
1867
+	    $rank = 0; // do not use negative rank
1868 1868
 	    $this->cols['desc'] = array(
1869 1869
 	        'rank' => $rank,
1870 1870
 	        'width' => false, // only for desc
@@ -1874,7 +1874,7 @@  discard block
 block discarded – undo
1874 1874
 	            'align' => 'L',
1875 1875
 	            // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1876 1876
 	            // 'label' => ' ', // the final label
1877
-	            'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1877
+	            'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1878 1878
 	        ),
1879 1879
 	        'content' => array(
1880 1880
 	            'align' => 'L',
@@ -1885,19 +1885,19 @@  discard block
 block discarded – undo
1885 1885
         $rank = $rank + 10;
1886 1886
         $this->cols['photo'] = array(
1887 1887
             'rank' => $rank,
1888
-            'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1888
+            'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1889 1889
             'status' => false,
1890 1890
             'title' => array(
1891 1891
                 'textkey' => 'Photo',
1892 1892
                 'label' => ' '
1893 1893
             ),
1894 1894
             'content' => array(
1895
-                'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1895
+                'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1896 1896
             ),
1897 1897
             'border-left' => false, // remove left line separator
1898 1898
         );
1899 1899
 
1900
-	    if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
1900
+	    if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
1901 1901
 	    {
1902 1902
 	        $this->cols['photo']['status'] = true;
1903 1903
 	    }
@@ -1952,7 +1952,7 @@  discard block
 block discarded – undo
1952 1952
 	        'border-left' => true, // add left line separator
1953 1953
 	    );
1954 1954
 
1955
-	    if($this->situationinvoice)
1955
+	    if ($this->situationinvoice)
1956 1956
 	    {
1957 1957
 	        $this->cols['progress']['status'] = true;
1958 1958
 	    }
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
 	        ),
1968 1968
 	        'border-left' => true, // add left line separator
1969 1969
 	    );
1970
-	    if($conf->global->PRODUCT_USE_UNITS){
1970
+	    if ($conf->global->PRODUCT_USE_UNITS) {
1971 1971
 	        $this->cols['unit']['status'] = true;
1972 1972
 	    }
1973 1973
 
@@ -1981,7 +1981,7 @@  discard block
 block discarded – undo
1981 1981
 	        ),
1982 1982
 	        'border-left' => true, // add left line separator
1983 1983
 	    );
1984
-	    if ($this->atleastonediscount){
1984
+	    if ($this->atleastonediscount) {
1985 1985
 	        $this->cols['discount']['status'] = true;
1986 1986
 	    }
1987 1987
 
@@ -1997,7 +1997,7 @@  discard block
 block discarded – undo
1997 1997
 	    );
1998 1998
 
1999 1999
 
2000
-	    $parameters=array(
2000
+	    $parameters = array(
2001 2001
 	        'object' => $object,
2002 2002
 	        'outputlangs' => $outputlangs,
2003 2003
 	        'hidedetails' => $hidedetails,
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
 	        'hideref' => $hideref
2006 2006
 	    );
2007 2007
 
2008
-	    $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this);    // Note that $object may have been modified by hook
2008
+	    $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
2009 2009
 	    if ($reshook < 0)
2010 2010
 	    {
2011 2011
 	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
Please login to merge, or discard this patch.
htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php 1 patch
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -68,37 +68,37 @@  discard block
 block discarded – undo
68 68
 		global $conf, $langs, $mysoc;
69 69
 
70 70
 		// Load translation files required by the page
71
-        $langs->loadLangs(array("main","companies"));
71
+        $langs->loadLangs(array("main", "companies"));
72 72
 
73 73
 		$this->db = $db;
74 74
 		$this->name = "ODT/ODS templates";
75 75
 		$this->description = $langs->trans("DocumentModelOdt");
76
-		$this->scandir = 'FACTURE_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
76
+		$this->scandir = 'FACTURE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
77 77
 
78 78
 		// Dimension page pour format A4
79 79
 		$this->type = 'odt';
80 80
 		$this->page_largeur = 0;
81 81
 		$this->page_hauteur = 0;
82
-		$this->format = array($this->page_largeur,$this->page_hauteur);
83
-		$this->marge_gauche=0;
84
-		$this->marge_droite=0;
85
-		$this->marge_haute=0;
86
-		$this->marge_basse=0;
87
-
88
-		$this->option_logo = 1;                    // Affiche logo
89
-		$this->option_tva = 0;                     // Gere option tva FACTURE_TVAOPTION
90
-		$this->option_modereg = 0;                 // Affiche mode reglement
91
-		$this->option_condreg = 0;                 // Affiche conditions reglement
92
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
93
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
94
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
95
-		$this->option_credit_note = 0;             // Support credit notes
96
-		$this->option_freetext = 1;				   // Support add of a personalised text
97
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
82
+		$this->format = array($this->page_largeur, $this->page_hauteur);
83
+		$this->marge_gauche = 0;
84
+		$this->marge_droite = 0;
85
+		$this->marge_haute = 0;
86
+		$this->marge_basse = 0;
87
+
88
+		$this->option_logo = 1; // Affiche logo
89
+		$this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION
90
+		$this->option_modereg = 0; // Affiche mode reglement
91
+		$this->option_condreg = 0; // Affiche conditions reglement
92
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
93
+		$this->option_multilang = 1; // Dispo en plusieurs langues
94
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
95
+		$this->option_credit_note = 0; // Support credit notes
96
+		$this->option_freetext = 1; // Support add of a personalised text
97
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
98 98
 
99 99
 		// Recupere emetteur
100
-		$this->emetteur=$mysoc;
101
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // Par defaut, si n'etait pas defini
100
+		$this->emetteur = $mysoc;
101
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
102 102
 	}
103 103
 
104 104
 
@@ -113,79 +113,79 @@  discard block
 block discarded – undo
113 113
 		global $conf, $langs;
114 114
 
115 115
 		// Load translation files required by the page
116
-        $langs->loadLangs(array("errors","companies"));
116
+        $langs->loadLangs(array("errors", "companies"));
117 117
 
118 118
 		$form = new Form($this->db);
119 119
 
120 120
 		$texte = $this->description.".<br>\n";
121
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
122
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
123
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
124
-		$texte.= '<input type="hidden" name="param1" value="FACTURE_ADDON_PDF_ODT_PATH">';
125
-		$texte.= '<table class="nobordernopadding" width="100%">';
121
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
122
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
123
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
124
+		$texte .= '<input type="hidden" name="param1" value="FACTURE_ADDON_PDF_ODT_PATH">';
125
+		$texte .= '<table class="nobordernopadding" width="100%">';
126 126
 
127 127
 		// List of directories area
128
-		$texte.= '<tr><td valign="middle">';
129
-		$texttitle=$langs->trans("ListOfDirectories");
130
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->FACTURE_ADDON_PDF_ODT_PATH)));
131
-		$listoffiles=array();
132
-		foreach($listofdir as $key=>$tmpdir)
128
+		$texte .= '<tr><td valign="middle">';
129
+		$texttitle = $langs->trans("ListOfDirectories");
130
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->FACTURE_ADDON_PDF_ODT_PATH)));
131
+		$listoffiles = array();
132
+		foreach ($listofdir as $key=>$tmpdir)
133 133
 		{
134
-			$tmpdir=trim($tmpdir);
135
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
136
-			if (! $tmpdir) {
134
+			$tmpdir = trim($tmpdir);
135
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
136
+			if (!$tmpdir) {
137 137
 				unset($listofdir[$key]); continue;
138 138
 			}
139
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
139
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
140 140
 			else
141 141
 			{
142
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
143
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
142
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
143
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
144 144
 			}
145 145
 		}
146
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
146
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
147 147
 		// Add list of substitution keys
148
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
149
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
150
-
151
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
152
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
153
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
154
-		$texte.=$conf->global->FACTURE_ADDON_PDF_ODT_PATH;
155
-		$texte.= '</textarea>';
156
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
157
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
158
-		$texte.= '<br></div></div>';
148
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
149
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
150
+
151
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
152
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
153
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
154
+		$texte .= $conf->global->FACTURE_ADDON_PDF_ODT_PATH;
155
+		$texte .= '</textarea>';
156
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
157
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
158
+		$texte .= '<br></div></div>';
159 159
 
160 160
 		// Scan directories
161
-		$nbofiles=count($listoffiles);
162
-		if (! empty($conf->global->FACTURE_ADDON_PDF_ODT_PATH))
161
+		$nbofiles = count($listoffiles);
162
+		if (!empty($conf->global->FACTURE_ADDON_PDF_ODT_PATH))
163 163
 		{
164
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
164
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
165 165
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
166
-			$texte.=count($listoffiles);
166
+			$texte .= count($listoffiles);
167 167
 			//$texte.=$nbofiles?'</a>':'';
168
-			$texte.='</b>';
168
+			$texte .= '</b>';
169 169
 		}
170 170
 		if ($nbofiles)
171 171
 		{
172
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
173
-   			foreach($listoffiles as $file)
172
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
173
+   			foreach ($listoffiles as $file)
174 174
    			{
175
-                $texte.=$file['name'].'<br>';
175
+                $texte .= $file['name'].'<br>';
176 176
    			}
177
-   			$texte.='<div id="div_'.get_class($this).'">';
177
+   			$texte .= '<div id="div_'.get_class($this).'">';
178 178
 		}
179 179
 
180
-		$texte.= '</td>';
180
+		$texte .= '</td>';
181 181
 
182
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
183
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
184
-		$texte.= '</td>';
185
-		$texte.= '</tr>';
182
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
183
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
184
+		$texte .= '</td>';
185
+		$texte .= '</tr>';
186 186
 
187
-		$texte.= '</table>';
188
-		$texte.= '</form>';
187
+		$texte .= '</table>';
188
+		$texte .= '</form>';
189 189
 
190 190
 		return $texte;
191 191
 	}
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
 	 *  @param		int			$hideref			Do not show ref
203 203
 	 *	@return		int         					1 if OK, <=0 if KO
204 204
 	 */
205
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
205
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
206 206
 	{
207 207
         // phpcs:enable
208
-		global $user,$langs,$conf,$mysoc,$hookmanager;
208
+		global $user, $langs, $conf, $mysoc, $hookmanager;
209 209
 
210 210
 		if (empty($srctemplatepath))
211 211
 		{
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 		}
215 215
 
216 216
 		// Add odtgeneration hook
217
-		if (! is_object($hookmanager))
217
+		if (!is_object($hookmanager))
218 218
 		{
219 219
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
220
-			$hookmanager=new HookManager($this->db);
220
+			$hookmanager = new HookManager($this->db);
221 221
 		}
222 222
 		$hookmanager->initHooks(array('odtgeneration'));
223 223
 		global $action;
224 224
 
225
-		if (! is_object($outputlangs)) $outputlangs=$langs;
226
-		$sav_charset_output=$outputlangs->charset_output;
227
-		$outputlangs->charset_output='UTF-8';
225
+		if (!is_object($outputlangs)) $outputlangs = $langs;
226
+		$sav_charset_output = $outputlangs->charset_output;
227
+		$outputlangs->charset_output = 'UTF-8';
228 228
 
229 229
 		// Load translation files required by the page
230 230
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
@@ -232,28 +232,28 @@  discard block
 block discarded – undo
232 232
 		if ($conf->facture->dir_output)
233 233
 		{
234 234
 			// If $object is id instead of object
235
-			if (! is_object($object))
235
+			if (!is_object($object))
236 236
 			{
237 237
 				$id = $object;
238 238
 				$object = new Facture($this->db);
239
-				$result=$object->fetch($id);
239
+				$result = $object->fetch($id);
240 240
 				if ($result < 0)
241 241
 				{
242
-					dol_print_error($this->db,$object->error);
242
+					dol_print_error($this->db, $object->error);
243 243
 					return -1;
244 244
 				}
245 245
 			}
246 246
 
247 247
 			$dir = $conf->facture->dir_output;
248 248
 			$objectref = dol_sanitizeFileName($object->ref);
249
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
250
-			$file = $dir . "/" . $objectref . ".odt";
249
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
250
+			$file = $dir."/".$objectref.".odt";
251 251
 
252
-			if (! file_exists($dir))
252
+			if (!file_exists($dir))
253 253
 			{
254 254
 				if (dol_mkdir($dir) < 0)
255 255
 				{
256
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
256
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
257 257
 					return -1;
258 258
 				}
259 259
 			}
@@ -261,26 +261,26 @@  discard block
 block discarded – undo
261 261
 			if (file_exists($dir))
262 262
 			{
263 263
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
264
-				$newfile=basename($srctemplatepath);
265
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
266
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
267
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
264
+				$newfile = basename($srctemplatepath);
265
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
266
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
267
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
268 268
 
269
-				$newfiletmp=$objectref.'_'.$newfiletmp;
269
+				$newfiletmp = $objectref.'_'.$newfiletmp;
270 270
 
271 271
 				// Get extension (ods or odt)
272
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
273
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
272
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
273
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
274 274
 				{
275
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
277
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
275
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
276
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
277
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
278 278
 				}
279 279
 				else
280 280
 				{
281
-					$filename=$newfiletmp.'.'.$newfileformat;
281
+					$filename = $newfiletmp.'.'.$newfileformat;
282 282
 				}
283
-				$file=$dir.'/'.$filename;
283
+				$file = $dir.'/'.$filename;
284 284
 				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
285 285
 				//print "newdir=".$dir;
286 286
 				//print "newfile=".$newfile;
@@ -291,19 +291,19 @@  discard block
 block discarded – undo
291 291
 
292 292
 
293 293
 				// If BILLING contact defined on invoice, we use it
294
-				$usecontact=false;
295
-				$arrayidcontact=$object->getIdContact('external','BILLING');
294
+				$usecontact = false;
295
+				$arrayidcontact = $object->getIdContact('external', 'BILLING');
296 296
 				if (count($arrayidcontact) > 0)
297 297
 				{
298
-					$usecontact=true;
299
-					$result=$object->fetch_contact($arrayidcontact[0]);
298
+					$usecontact = true;
299
+					$result = $object->fetch_contact($arrayidcontact[0]);
300 300
 				}
301 301
 
302 302
 				// Recipient name
303 303
 				$contactobject = null;
304
-				if (! empty($usecontact)) {
304
+				if (!empty($usecontact)) {
305 305
 					// On peut utiliser le nom de la societe du contact
306
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
306
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
307 307
 						$socobject = $object->contact;
308 308
 					else {
309 309
 						$socobject = $object->thirdparty;
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
 				}
316 316
 
317 317
 				// Fetch info for linked propal
318
-				$object->fetchObjectLinked('','','','');
318
+				$object->fetchObjectLinked('', '', '', '');
319 319
 				//print_r($object->linkedObjects['propal']); exit;
320 320
 
321 321
 				$propal_object = $object->linkedObjects['propal'][0];
322 322
 
323 323
 				// Make substitution
324
-				$substitutionarray=array(
324
+				$substitutionarray = array(
325 325
 				'__FROM_NAME__' => $this->emetteur->name,
326 326
 				'__FROM_EMAIL__' => $this->emetteur->email,
327 327
 				'__TOTAL_TTC__' => $object->total_ttc,
@@ -330,15 +330,15 @@  discard block
 block discarded – undo
330 330
 				);
331 331
 				complete_substitutions_array($substitutionarray, $langs, $object);
332 332
 				// Call the ODTSubstitution hook
333
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
334
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
333
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
334
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
335 335
 
336 336
 				// Line of free text
337
-				$newfreetext='';
338
-				$paramfreetext='INVOICE_FREE_TEXT';
339
-				if (! empty($conf->global->$paramfreetext))
337
+				$newfreetext = '';
338
+				$paramfreetext = 'INVOICE_FREE_TEXT';
339
+				if (!empty($conf->global->$paramfreetext))
340 340
 				{
341
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
341
+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
342 342
 				}
343 343
 
344 344
 				// Open and load template
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 						$srctemplatepath,
349 349
 						array(
350 350
 						'PATH_TO_TMP'	  => $conf->facture->dir_temp,
351
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
351
+						'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
352 352
 						'DELIMITER_LEFT'  => '{',
353 353
 						'DELIMITER_RIGHT' => '}'
354 354
 						)
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 				}
357 357
 				catch (Exception $e)
358 358
 				{
359
-					$this->error=$e->getMessage();
359
+					$this->error = $e->getMessage();
360 360
 					dol_syslog($e->getMessage(), LOG_INFO);
361 361
 					return -1;
362 362
 				}
@@ -378,29 +378,29 @@  discard block
 block discarded – undo
378 378
 
379 379
 				// Define substitution array
380 380
 				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
381
-				$array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
382
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
383
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
384
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
385
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
386
-				$array_propal=is_object($propal_object)?$this->get_substitutionarray_object($propal_object,$outputlangs,'propal'):array();
387
-				$array_other=$this->get_substitutionarray_other($outputlangs);
381
+				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
382
+				$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
383
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
384
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
385
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
386
+				$array_propal = is_object($propal_object) ? $this->get_substitutionarray_object($propal_object, $outputlangs, 'propal') : array();
387
+				$array_other = $this->get_substitutionarray_other($outputlangs);
388 388
 				// retrieve contact information for use in object as contact_xxx tags
389 389
 				$array_thirdparty_contact = array();
390
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
390
+				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
391 391
 
392
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal,$array_other,$array_thirdparty_contact);
392
+				$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_propal, $array_other, $array_thirdparty_contact);
393 393
 				complete_substitutions_array($tmparray, $outputlangs, $object);
394 394
 
395 395
 				// Call the ODTSubstitution hook
396
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
397
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
396
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
397
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
398 398
 
399 399
 				//var_dump($tmparray); exit;
400
-				foreach($tmparray as $key=>$value)
400
+				foreach ($tmparray as $key=>$value)
401 401
 				{
402 402
 					try {
403
-						if (preg_match('/logo$/',$key)) // Image
403
+						if (preg_match('/logo$/', $key)) // Image
404 404
 						{
405 405
 							//var_dump($value);exit;
406 406
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 					try {
424 424
 						$listlines = $odfHandler->setSegment('lines');
425 425
 					}
426
-					catch(OdfException $e)
426
+					catch (OdfException $e)
427 427
 					{
428 428
 						// We may arrive here if tags for lines not present into template
429 429
 						$foundtagforlines = 0;
@@ -433,22 +433,22 @@  discard block
 block discarded – undo
433 433
 					{
434 434
 						foreach ($object->lines as $line)
435 435
 						{
436
-							$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
436
+							$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
437 437
 							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
438 438
 							// Call the ODTSubstitutionLine hook
439
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
440
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
441
-							foreach($tmparray as $key => $val)
439
+							$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
440
+							$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
441
+							foreach ($tmparray as $key => $val)
442 442
 							{
443 443
 								try
444 444
 								{
445 445
 									$listlines->setVars($key, $val, true, 'UTF-8');
446 446
 								}
447
-								catch(OdfException $e)
447
+								catch (OdfException $e)
448 448
 								{
449 449
 									dol_syslog($e->getMessage(), LOG_INFO);
450 450
 								}
451
-								catch(SegmentException $e)
451
+								catch (SegmentException $e)
452 452
 								{
453 453
 									dol_syslog($e->getMessage(), LOG_INFO);
454 454
 								}
@@ -458,36 +458,36 @@  discard block
 block discarded – undo
458 458
 						$odfHandler->mergeSegment($listlines);
459 459
 					}
460 460
 				}
461
-				catch(OdfException $e)
461
+				catch (OdfException $e)
462 462
 				{
463
-					$this->error=$e->getMessage();
463
+					$this->error = $e->getMessage();
464 464
 					dol_syslog($this->error, LOG_WARNING);
465 465
 					return -1;
466 466
 				}
467 467
 
468 468
 				// Replace labels translated
469
-				$tmparray=$outputlangs->get_translations_for_substitutions();
470
-				foreach($tmparray as $key=>$value)
469
+				$tmparray = $outputlangs->get_translations_for_substitutions();
470
+				foreach ($tmparray as $key=>$value)
471 471
 				{
472 472
 					try {
473 473
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
474 474
 					}
475
-					catch(OdfException $e)
475
+					catch (OdfException $e)
476 476
 					{
477 477
                         dol_syslog($e->getMessage(), LOG_INFO);
478 478
 					}
479 479
 				}
480 480
 
481 481
 				// Call the beforeODTSave hook
482
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
483
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
482
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
483
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
484 484
 
485 485
 				// Write new file
486 486
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
487 487
 					try {
488 488
 						$odfHandler->exportAsAttachedPDF($file);
489
-					}catch (Exception $e){
490
-						$this->error=$e->getMessage();
489
+					} catch (Exception $e) {
490
+						$this->error = $e->getMessage();
491 491
                         dol_syslog($e->getMessage(), LOG_INFO);
492 492
 						return -1;
493 493
 					}
@@ -496,26 +496,26 @@  discard block
 block discarded – undo
496 496
 					try {
497 497
 						$odfHandler->saveToDisk($file);
498 498
 					} catch (Exception $e) {
499
-						$this->error=$e->getMessage();
499
+						$this->error = $e->getMessage();
500 500
                         dol_syslog($e->getMessage(), LOG_INFO);
501 501
 						return -1;
502 502
 					}
503 503
 				}
504
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
505
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
504
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
505
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
506 506
 
507
-				if (! empty($conf->global->MAIN_UMASK))
507
+				if (!empty($conf->global->MAIN_UMASK))
508 508
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
509 509
 
510
-				$odfHandler=null;	// Destroy object
510
+				$odfHandler = null; // Destroy object
511 511
 
512 512
 				$this->result = array('fullpath'=>$file);
513 513
 
514
-				return 1;   // Success
514
+				return 1; // Success
515 515
 			}
516 516
 			else
517 517
 			{
518
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
518
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
519 519
 				return -1;
520 520
 			}
521 521
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/facture/doc/pdf_crabe.modules.php 1 patch
Spacing   +540 added lines, -540 removed lines patch added patch discarded remove patch
@@ -147,74 +147,74 @@  discard block
 block discarded – undo
147 147
 		$this->db = $db;
148 148
 		$this->name = "crabe";
149 149
 		$this->description = $langs->trans('PDFCrabeDescription');
150
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
150
+		$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
151 151
 
152 152
 		// Dimensiont page
153 153
 		$this->type = 'pdf';
154
-		$formatarray=pdf_getFormat();
154
+		$formatarray = pdf_getFormat();
155 155
 		$this->page_largeur = $formatarray['width'];
156 156
 		$this->page_hauteur = $formatarray['height'];
157
-		$this->format = array($this->page_largeur,$this->page_hauteur);
158
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
159
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
160
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
161
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
162
-
163
-		$this->option_logo = 1;                    // Affiche logo
164
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
165
-		$this->option_modereg = 1;                 // Affiche mode reglement
166
-		$this->option_condreg = 1;                 // Affiche conditions reglement
167
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
168
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
169
-		$this->option_escompte = 1;                // Affiche si il y a eu escompte
170
-		$this->option_credit_note = 1;             // Support credit notes
171
-		$this->option_freetext = 1;				   // Support add of a personalised text
172
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
173
-
174
-		$this->franchise=!$mysoc->tva_assuj;
157
+		$this->format = array($this->page_largeur, $this->page_hauteur);
158
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
159
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
160
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
161
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
162
+
163
+		$this->option_logo = 1; // Affiche logo
164
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
165
+		$this->option_modereg = 1; // Affiche mode reglement
166
+		$this->option_condreg = 1; // Affiche conditions reglement
167
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
168
+		$this->option_multilang = 1; // Dispo en plusieurs langues
169
+		$this->option_escompte = 1; // Affiche si il y a eu escompte
170
+		$this->option_credit_note = 1; // Support credit notes
171
+		$this->option_freetext = 1; // Support add of a personalised text
172
+		$this->option_draft_watermark = 1; // Support add of a watermark on drafts
173
+
174
+		$this->franchise = !$mysoc->tva_assuj;
175 175
 
176 176
 		// Get source company
177
-		$this->emetteur=$mysoc;
178
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
177
+		$this->emetteur = $mysoc;
178
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
179 179
 
180 180
 		// Define position of columns
181
-		$this->posxdesc=$this->marge_gauche+1;
182
-		if($conf->global->PRODUCT_USE_UNITS)
181
+		$this->posxdesc = $this->marge_gauche + 1;
182
+		if ($conf->global->PRODUCT_USE_UNITS)
183 183
 		{
184
-			$this->posxtva=101;
185
-			$this->posxup=118;
186
-			$this->posxqty=135;
187
-			$this->posxunit=151;
184
+			$this->posxtva = 101;
185
+			$this->posxup = 118;
186
+			$this->posxqty = 135;
187
+			$this->posxunit = 151;
188 188
 		}
189 189
 		else
190 190
 		{
191
-			$this->posxtva=110;
192
-			$this->posxup=126;
193
-			$this->posxqty=145;
191
+			$this->posxtva = 110;
192
+			$this->posxup = 126;
193
+			$this->posxqty = 145;
194 194
 		}
195
-		$this->posxdiscount=162;
196
-		$this->posxprogress=126; // Only displayed for situation invoices
197
-		$this->postotalht=174;
198
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
199
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
195
+		$this->posxdiscount = 162;
196
+		$this->posxprogress = 126; // Only displayed for situation invoices
197
+		$this->postotalht = 174;
198
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
199
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
200 200
 		if ($this->page_largeur < 210) // To work with US executive format
201 201
 		{
202
-		    $this->posxpicture-=20;
203
-		    $this->posxtva-=20;
204
-		    $this->posxup-=20;
205
-		    $this->posxqty-=20;
206
-		    $this->posxunit-=20;
207
-		    $this->posxdiscount-=20;
208
-		    $this->posxprogress-=20;
209
-		    $this->postotalht-=20;
202
+		    $this->posxpicture -= 20;
203
+		    $this->posxtva -= 20;
204
+		    $this->posxup -= 20;
205
+		    $this->posxqty -= 20;
206
+		    $this->posxunit -= 20;
207
+		    $this->posxdiscount -= 20;
208
+		    $this->posxprogress -= 20;
209
+		    $this->postotalht -= 20;
210 210
 		}
211 211
 
212
-		$this->tva=array();
213
-		$this->localtax1=array();
214
-		$this->localtax2=array();
215
-		$this->atleastoneratenotnull=0;
216
-		$this->atleastonediscount=0;
217
-		$this->situationinvoice=false;
212
+		$this->tva = array();
213
+		$this->localtax1 = array();
214
+		$this->localtax2 = array();
215
+		$this->atleastoneratenotnull = 0;
216
+		$this->atleastonediscount = 0;
217
+		$this->situationinvoice = false;
218 218
 	}
219 219
 
220 220
 
@@ -230,14 +230,14 @@  discard block
 block discarded – undo
230 230
      *  @param		int			$hideref			Do not show ref
231 231
      *  @return     int         	    			1=OK, 0=KO
232 232
 	 */
233
-	function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
233
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
234 234
 	{
235 235
         // phpcs:enable
236
-		global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
236
+		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
237 237
 
238
-		if (! is_object($outputlangs)) $outputlangs=$langs;
238
+		if (!is_object($outputlangs)) $outputlangs = $langs;
239 239
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
240
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
240
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
241 241
 
242 242
 		// Load traductions files requiredby by page
243 243
 		$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
@@ -245,32 +245,32 @@  discard block
 block discarded – undo
245 245
 		$nblignes = count($object->lines);
246 246
 
247 247
 		// Loop on each lines to detect if there is at least one image to show
248
-		$realpatharray=array();
249
-		if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
248
+		$realpatharray = array();
249
+		if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
250 250
 		{
251
-			for ($i = 0 ; $i < $nblignes ; $i++)
251
+			for ($i = 0; $i < $nblignes; $i++)
252 252
 			{
253 253
 				if (empty($object->lines[$i]->fk_product)) continue;
254 254
 
255 255
 				$objphoto = new Product($this->db);
256 256
 				$objphoto->fetch($object->lines[$i]->fk_product);
257 257
 
258
-				$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
258
+				$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
259 259
 				$dir = $conf->product->dir_output.'/'.$pdir;
260 260
 
261
-				$realpath='';
262
-				foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
261
+				$realpath = '';
262
+				foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
263 263
 				{
264
-					$filename=$obj['photo'];
264
+					$filename = $obj['photo'];
265 265
 					//if ($obj['photo_vignette']) $filename='thumbs/'.$obj['photo_vignette'];
266 266
 					$realpath = $dir.$filename;
267 267
 					break;
268 268
 				}
269 269
 
270
-				if ($realpath) $realpatharray[$i]=$realpath;
270
+				if ($realpath) $realpatharray[$i] = $realpath;
271 271
 			}
272 272
 		}
273
-		if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
273
+		if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
274 274
 
275 275
 		if ($conf->facture->dir_output)
276 276
 		{
@@ -284,19 +284,19 @@  discard block
 block discarded – undo
284 284
 			if ($object->specimen)
285 285
 			{
286 286
 				$dir = $conf->facture->dir_output;
287
-				$file = $dir . "/SPECIMEN.pdf";
287
+				$file = $dir."/SPECIMEN.pdf";
288 288
 			}
289 289
 			else
290 290
 			{
291 291
 				$objectref = dol_sanitizeFileName($object->ref);
292
-				$dir = $conf->facture->dir_output . "/" . $objectref;
293
-				$file = $dir . "/" . $objectref . ".pdf";
292
+				$dir = $conf->facture->dir_output."/".$objectref;
293
+				$file = $dir."/".$objectref.".pdf";
294 294
 			}
295
-			if (! file_exists($dir))
295
+			if (!file_exists($dir))
296 296
 			{
297 297
 				if (dol_mkdir($dir) < 0)
298 298
 				{
299
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
299
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
300 300
 					return 0;
301 301
 				}
302 302
 			}
@@ -304,29 +304,29 @@  discard block
 block discarded – undo
304 304
 			if (file_exists($dir))
305 305
 			{
306 306
 				// Add pdfgeneration hook
307
-				if (! is_object($hookmanager))
307
+				if (!is_object($hookmanager))
308 308
 				{
309 309
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
310
-					$hookmanager=new HookManager($this->db);
310
+					$hookmanager = new HookManager($this->db);
311 311
 				}
312 312
 				$hookmanager->initHooks(array('pdfgeneration'));
313
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
313
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
314 314
 				global $action;
315
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
315
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
316 316
 
317 317
 				// Set nblignes with the new facture lines content after hook
318 318
 				$nblignes = count($object->lines);
319 319
 				$nbpayments = count($object->getListOfPayments());
320 320
 
321 321
 				// Create pdf instance
322
-				$pdf=pdf_getInstance($this->format);
323
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
324
-                $pdf->SetAutoPageBreak(1,0);
322
+				$pdf = pdf_getInstance($this->format);
323
+                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
324
+                $pdf->SetAutoPageBreak(1, 0);
325 325
 
326
-                $heightforinfotot = 50+(4*$nbpayments);	// Height reserved to output the info and total part and payment part
327
-		        $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
328
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
329
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
326
+                $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
327
+		        $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
328
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
329
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
330 330
 
331 331
                 if (class_exists('TCPDF'))
332 332
                 {
@@ -336,27 +336,27 @@  discard block
 block discarded – undo
336 336
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
337 337
 
338 338
                 // Set path to the background PDF File
339
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
339
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
340 340
                 {
341 341
 				    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
342 342
 				    $tplidx = $pdf->importPage(1);
343 343
                 }
344 344
 
345 345
 				$pdf->Open();
346
-				$pagenb=0;
347
-				$pdf->SetDrawColor(128,128,128);
346
+				$pagenb = 0;
347
+				$pdf->SetDrawColor(128, 128, 128);
348 348
 
349 349
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
350 350
 				$pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle"));
351 351
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
352 352
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
353 353
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
354
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
354
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
355 355
 
356
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
356
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
357 357
 
358 358
 				// Positionne $this->atleastonediscount si on a au moins une remise
359
-				for ($i = 0 ; $i < $nblignes ; $i++)
359
+				for ($i = 0; $i < $nblignes; $i++)
360 360
 				{
361 361
 					if ($object->lines[$i]->remise_percent)
362 362
 					{
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
 				}
366 366
 				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))    // retreive space not used by discount
367 367
 				{
368
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
369
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
370
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
371
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
372
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
368
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
369
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
370
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
371
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
372
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
373 373
 					//$this->postotalht;
374 374
 				}
375 375
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 					$this->posxtva -= $progress_width;
383 383
 					$this->posxup -= $progress_width;
384 384
 					$this->posxqty -= $progress_width;
385
-					if(empty($conf->global->PRODUCT_USE_UNITS)) {
385
+					if (empty($conf->global->PRODUCT_USE_UNITS)) {
386 386
 						$this->posxprogress += $progress_width;
387 387
 					}
388 388
 					/*$this->posxdiscount -= $progress_width;
@@ -391,16 +391,16 @@  discard block
 block discarded – undo
391 391
 
392 392
 				// New page
393 393
 				$pdf->AddPage();
394
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
394
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
395 395
 				$pagenb++;
396 396
 
397 397
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
398
-				$pdf->SetFont('','', $default_font_size - 1);
399
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
400
-				$pdf->SetTextColor(0,0,0);
398
+				$pdf->SetFont('', '', $default_font_size - 1);
399
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
400
+				$pdf->SetTextColor(0, 0, 0);
401 401
 
402
-				$tab_top = 90+$top_shift;
403
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
402
+				$tab_top = 90 + $top_shift;
403
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
404 404
 
405 405
 				// Incoterm
406 406
 				if ($conf->incoterm->enabled)
@@ -410,50 +410,50 @@  discard block
 block discarded – undo
410 410
 					{
411 411
 						$tab_top -= 2;
412 412
 
413
-						$pdf->SetFont('','', $default_font_size - 1);
414
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
413
+						$pdf->SetFont('', '', $default_font_size - 1);
414
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
415 415
 						$nexY = $pdf->GetY();
416
-						$height_incoterms=$nexY-$tab_top;
416
+						$height_incoterms = $nexY - $tab_top;
417 417
 
418 418
 						// Rect prend une longueur en 3eme param
419
-						$pdf->SetDrawColor(192,192,192);
420
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
419
+						$pdf->SetDrawColor(192, 192, 192);
420
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
421 421
 
422
-						$tab_top = $nexY+6;
422
+						$tab_top = $nexY + 6;
423 423
 					}
424 424
 				}
425 425
 
426 426
 				// Affiche notes
427
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
428
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
427
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
428
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
429 429
 				{
430 430
 					// Get first sale rep
431 431
 					if (is_object($object->thirdparty))
432 432
 					{
433
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
434
-						$salerepobj=new User($this->db);
433
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
434
+						$salerepobj = new User($this->db);
435 435
 						$salerepobj->fetch($salereparray[0]['id']);
436
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
436
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
437 437
 					}
438 438
 				}
439 439
 				if ($notetoshow)
440 440
 				{
441 441
 					$tab_top -= 2;
442 442
 
443
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
443
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
444 444
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
445 445
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
446 446
 
447
-					$pdf->SetFont('','', $default_font_size - 1);
448
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
447
+					$pdf->SetFont('', '', $default_font_size - 1);
448
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
449 449
 					$nexY = $pdf->GetY();
450
-					$height_note=$nexY-$tab_top;
450
+					$height_note = $nexY - $tab_top;
451 451
 
452 452
 					// Rect prend une longueur en 3eme param
453
-					$pdf->SetDrawColor(192,192,192);
454
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
453
+					$pdf->SetDrawColor(192, 192, 192);
454
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
455 455
 
456
-					$tab_top = $nexY+6;
456
+					$tab_top = $nexY + 6;
457 457
 				}
458 458
 
459 459
 				$iniY = $tab_top + 7;
@@ -464,104 +464,104 @@  discard block
 block discarded – undo
464 464
 				for ($i = 0; $i < $nblignes; $i++)
465 465
 				{
466 466
 					$curY = $nexY;
467
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
468
-					$pdf->SetTextColor(0,0,0);
467
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
468
+					$pdf->SetTextColor(0, 0, 0);
469 469
 
470 470
 					// Define size of image if we need it
471
-					$imglinesize=array();
472
-					if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
471
+					$imglinesize = array();
472
+					if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
473 473
 
474 474
 					$pdf->setTopMargin($tab_top_newpage);
475
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
476
-					$pageposbefore=$pdf->getPage();
475
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
476
+					$pageposbefore = $pdf->getPage();
477 477
 
478
-					$showpricebeforepagebreak=1;
479
-					$posYAfterImage=0;
480
-					$posYAfterDescription=0;
478
+					$showpricebeforepagebreak = 1;
479
+					$posYAfterImage = 0;
480
+					$posYAfterDescription = 0;
481 481
 
482 482
 					// We start with Photo of product line
483
-					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot)))	// If photo too high, we moved completely on new page
483
+					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// If photo too high, we moved completely on new page
484 484
 					{
485
-						$pdf->AddPage('','',true);
486
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
485
+						$pdf->AddPage('', '', true);
486
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
487 487
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
488
-						$pdf->setPage($pageposbefore+1);
488
+						$pdf->setPage($pageposbefore + 1);
489 489
 
490 490
 						$curY = $tab_top_newpage;
491
-						$showpricebeforepagebreak=0;
491
+						$showpricebeforepagebreak = 0;
492 492
 					}
493 493
 
494 494
 					if (isset($imglinesize['width']) && isset($imglinesize['height']))
495 495
 					{
496
-						$curX = $this->posxpicture-1;
497
-						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300);	// Use 300 dpi
496
+						$curX = $this->posxpicture - 1;
497
+						$pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
498 498
 						// $pdf->Image does not increase value return by getY, so we save it manually
499
-						$posYAfterImage=$curY+$imglinesize['height'];
499
+						$posYAfterImage = $curY + $imglinesize['height'];
500 500
 					}
501 501
 
502 502
 					// Description of product line
503
-					$curX = $this->posxdesc-1;
503
+					$curX = $this->posxdesc - 1;
504 504
 
505 505
 					$pdf->startTransaction();
506
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX-$progress_width,3,$curX,$curY,$hideref,$hidedesc);
507
-					$pageposafter=$pdf->getPage();
506
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
507
+					$pageposafter = $pdf->getPage();
508 508
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
509 509
 					{
510 510
 						$pdf->rollbackTransaction(true);
511
-						$pageposafter=$pageposbefore;
511
+						$pageposafter = $pageposbefore;
512 512
 						//print $pageposafter.'-'.$pageposbefore;exit;
513
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
514
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX-$progress_width,3,$curX,$curY,$hideref,$hidedesc);
515
-						$pageposafter=$pdf->getPage();
516
-						$posyafter=$pdf->GetY();
513
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
514
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
515
+						$pageposafter = $pdf->getPage();
516
+						$posyafter = $pdf->GetY();
517 517
 						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
518
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
518
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
519 519
 						{
520
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
520
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
521 521
 							{
522
-								$pdf->AddPage('','',true);
523
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
522
+								$pdf->AddPage('', '', true);
523
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
524 524
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
525
-								$pdf->setPage($pageposafter+1);
525
+								$pdf->setPage($pageposafter + 1);
526 526
 							}
527 527
 						}
528 528
 						else
529 529
 						{
530 530
 							// We found a page break
531
-							$showpricebeforepagebreak=0;
531
+							$showpricebeforepagebreak = 0;
532 532
 						}
533 533
 					}
534 534
 					else	// No pagebreak
535 535
 					{
536 536
 						$pdf->commitTransaction();
537 537
 					}
538
-					$posYAfterDescription=$pdf->GetY();
538
+					$posYAfterDescription = $pdf->GetY();
539 539
 
540 540
 					$nexY = $pdf->GetY();
541
-					$pageposafter=$pdf->getPage();
541
+					$pageposafter = $pdf->getPage();
542 542
 					$pdf->setPage($pageposbefore);
543 543
 					$pdf->setTopMargin($this->marge_haute);
544
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
544
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
545 545
 
546 546
 					// We suppose that a too long description or photo were moved completely on next page
547 547
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
548 548
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
549 549
 					}
550 550
 
551
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
551
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
552 552
 
553 553
 					// VAT Rate
554 554
 					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
555 555
 					{
556 556
 						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
557
-						$pdf->SetXY($this->posxtva-5, $curY);
558
-						$pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
557
+						$pdf->SetXY($this->posxtva - 5, $curY);
558
+						$pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0, 'R');
559 559
 					}
560 560
 
561 561
 					// Unit price before discount
562 562
 					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
563 563
 					$pdf->SetXY($this->posxup, $curY);
564
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
564
+					$pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
565 565
 
566 566
 					// Quantity
567 567
 					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
@@ -570,15 +570,15 @@  discard block
 block discarded – undo
570 570
 
571 571
 					if ($this->situationinvoice)
572 572
 					{
573
-						$pdf->MultiCell($this->posxprogress-$this->posxqty-0.8, 4, $qty, 0, 'R');
573
+						$pdf->MultiCell($this->posxprogress - $this->posxqty - 0.8, 4, $qty, 0, 'R');
574 574
 					}
575
-					else if($conf->global->PRODUCT_USE_UNITS)
575
+					else if ($conf->global->PRODUCT_USE_UNITS)
576 576
 					{
577
-						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
577
+						$pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R');
578 578
 					}
579 579
 					else
580 580
 					{
581
-						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
581
+						$pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R');
582 582
 					}
583 583
 
584 584
 					// Situation progress
@@ -586,44 +586,44 @@  discard block
 block discarded – undo
586 586
 					{
587 587
 						$progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
588 588
 						$pdf->SetXY($this->posxprogress, $curY);
589
-						if($conf->global->PRODUCT_USE_UNITS)
589
+						if ($conf->global->PRODUCT_USE_UNITS)
590 590
 						{
591
-							$pdf->MultiCell($this->posxunit-$this->posxprogress-1, 3, $progress, 0, 'R');
591
+							$pdf->MultiCell($this->posxunit - $this->posxprogress - 1, 3, $progress, 0, 'R');
592 592
 						}
593 593
 						else if ($this->atleastonediscount)
594 594
 						{
595
-							$pdf->MultiCell($this->posxdiscount-$this->posxprogress-1, 3, $progress, 0, 'R');
595
+							$pdf->MultiCell($this->posxdiscount - $this->posxprogress - 1, 3, $progress, 0, 'R');
596 596
 						}
597 597
 						else
598 598
 						{
599
-							$pdf->MultiCell($this->postotalht-$this->posxprogress-1, 3, $progress, 0, 'R');
599
+							$pdf->MultiCell($this->postotalht - $this->posxprogress - 1, 3, $progress, 0, 'R');
600 600
 						}
601 601
 					}
602 602
 
603 603
 					// Unit
604
-					if($conf->global->PRODUCT_USE_UNITS)
604
+					if ($conf->global->PRODUCT_USE_UNITS)
605 605
 					{
606 606
 						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
607 607
 						$pdf->SetXY($this->posxunit, $curY);
608
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
608
+						$pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
609 609
 					}
610 610
 
611 611
 					// Discount on line
612 612
 					if ($object->lines[$i]->remise_percent)
613 613
 					{
614
-                        $pdf->SetXY($this->posxdiscount-2, $curY);
614
+                        $pdf->SetXY($this->posxdiscount - 2, $curY);
615 615
 					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
616
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
616
+						$pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
617 617
 					}
618 618
 
619 619
 					// Total HT line
620 620
 					$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
621 621
 					$pdf->SetXY($this->postotalht, $curY);
622
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
622
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
623 623
 
624 624
 
625
-					$sign=1;
626
-					if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
625
+					$sign = 1;
626
+					if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
627 627
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
628 628
 					$prev_progress = $object->lines[$i]->get_prev_progress($object->id);
629 629
 					if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
@@ -631,55 +631,55 @@  discard block
 block discarded – undo
631 631
 						if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
632 632
 						else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
633 633
 					} else {
634
-						if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva;
635
-						else $tvaligne= $sign * $object->lines[$i]->total_tva;
634
+						if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
635
+						else $tvaligne = $sign * $object->lines[$i]->total_tva;
636 636
 					}
637 637
 
638
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
639
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
640
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
641
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
642
-					$localtax1_type=$object->lines[$i]->localtax1_type;
643
-					$localtax2_type=$object->lines[$i]->localtax2_type;
638
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
639
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
640
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
641
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
642
+					$localtax1_type = $object->lines[$i]->localtax1_type;
643
+					$localtax2_type = $object->lines[$i]->localtax2_type;
644 644
 
645
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
646
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
647
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
645
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
646
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
647
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
648 648
 
649
-					$vatrate=(string) $object->lines[$i]->tva_tx;
649
+					$vatrate = (string) $object->lines[$i]->tva_tx;
650 650
 
651 651
 					// Retrieve type from database for backward compatibility with old records
652
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
653
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
652
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
653
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
654 654
 					{
655
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0, $object->thirdparty, $mysoc);
655
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
656 656
 						$localtax1_type = $localtaxtmp_array[0];
657 657
 						$localtax2_type = $localtaxtmp_array[2];
658 658
 					}
659 659
 
660 660
 				    // retrieve global local tax
661 661
 					if ($localtax1_type && $localtax1ligne != 0)
662
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
662
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
663 663
 					if ($localtax2_type && $localtax2ligne != 0)
664
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
664
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
665 665
 
666
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
667
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
666
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
667
+					if (!isset($this->tva[$vatrate])) 				$this->tva[$vatrate] = 0;
668 668
 					$this->tva[$vatrate] += $tvaligne;
669 669
 
670
-					if ($posYAfterImage > $posYAfterDescription) $nexY=$posYAfterImage;
670
+					if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
671 671
 
672 672
 					// Add line
673
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
673
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
674 674
 					{
675 675
 						$pdf->setPage($pageposafter);
676
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
676
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
677 677
 						//$pdf->SetDrawColor(190,190,200);
678
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
678
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
679 679
 						$pdf->SetLineStyle(array('dash'=>0));
680 680
 					}
681 681
 
682
-					$nexY+=2;    // Passe espace entre les lignes
682
+					$nexY += 2; // Passe espace entre les lignes
683 683
 
684 684
 					// Detect if some page were added automatically and output _tableau for past pages
685 685
 					while ($pagenb < $pageposafter)
@@ -693,13 +693,13 @@  discard block
 block discarded – undo
693 693
 						{
694 694
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
695 695
 						}
696
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
696
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
697 697
 						$pagenb++;
698 698
 						$pdf->setPage($pagenb);
699
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
699
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
700 700
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
701 701
 					}
702
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
702
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
703 703
 					{
704 704
 						if ($pagenb == 1)
705 705
 						{
@@ -709,10 +709,10 @@  discard block
 block discarded – undo
709 709
 						{
710 710
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
711 711
 						}
712
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
712
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
713 713
 						// New page
714 714
 						$pdf->AddPage();
715
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
715
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
716 716
 						$pagenb++;
717 717
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
718 718
 					}
@@ -722,56 +722,56 @@  discard block
 block discarded – undo
722 722
 				if ($pagenb == 1)
723 723
 				{
724 724
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
725
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
725
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
726 726
 				}
727 727
 				else
728 728
 				{
729 729
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
730
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
730
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
731 731
 				}
732 732
 
733 733
 				// Affiche zone infos
734
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
734
+				$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
735 735
 
736 736
 				// Affiche zone totaux
737
-				$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
737
+				$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
738 738
 
739 739
 				// Affiche zone versements
740 740
 				if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
741 741
 				{
742
-					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
742
+					$posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
743 743
 				}
744 744
 
745 745
 				// Pied de page
746
-				$this->_pagefoot($pdf,$object,$outputlangs);
747
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
746
+				$this->_pagefoot($pdf, $object, $outputlangs);
747
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
748 748
 
749 749
 				$pdf->Close();
750 750
 
751
-				$pdf->Output($file,'F');
751
+				$pdf->Output($file, 'F');
752 752
 
753 753
 				// Add pdfgeneration hook
754 754
 				$hookmanager->initHooks(array('pdfgeneration'));
755
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
755
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
756 756
 				global $action;
757
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
757
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
758 758
 
759
-				if (! empty($conf->global->MAIN_UMASK))
759
+				if (!empty($conf->global->MAIN_UMASK))
760 760
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
761 761
 
762 762
 				$this->result = array('fullpath'=>$file);
763 763
 
764
-				return 1;   // No error
764
+				return 1; // No error
765 765
 			}
766 766
 			else
767 767
 			{
768
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
768
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
769 769
 				return 0;
770 770
 			}
771 771
 		}
772 772
 		else
773 773
 		{
774
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","FAC_OUTPUTDIR");
774
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
775 775
 			return 0;
776 776
 		}
777 777
 	}
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
         // phpcs:enable
793 793
 		global $conf;
794 794
 
795
-        $sign=1;
796
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
795
+        $sign = 1;
796
+        if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
797 797
 
798 798
         $tab3_posx = 120;
799 799
 		$tab3_top = $posy + 8;
@@ -806,114 +806,114 @@  discard block
 block discarded – undo
806 806
 
807 807
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
808 808
 
809
-		$title=$outputlangs->transnoentities("PaymentsAlreadyDone");
810
-		if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone");
809
+		$title = $outputlangs->transnoentities("PaymentsAlreadyDone");
810
+		if ($object->type == 2) $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
811 811
 
812
-		$pdf->SetFont('','', $default_font_size - 3);
812
+		$pdf->SetFont('', '', $default_font_size - 3);
813 813
 		$pdf->SetXY($tab3_posx, $tab3_top - 4);
814 814
 		$pdf->MultiCell(60, 3, $title, 0, 'L', 0);
815 815
 
816
-		$pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top);
816
+		$pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
817 817
 
818
-		$pdf->SetFont('','', $default_font_size - 4);
818
+		$pdf->SetFont('', '', $default_font_size - 4);
819 819
 		$pdf->SetXY($tab3_posx, $tab3_top);
820 820
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
821
-		$pdf->SetXY($tab3_posx+21, $tab3_top);
821
+		$pdf->SetXY($tab3_posx + 21, $tab3_top);
822 822
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
823
-		$pdf->SetXY($tab3_posx+40, $tab3_top);
823
+		$pdf->SetXY($tab3_posx + 40, $tab3_top);
824 824
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
825
-		$pdf->SetXY($tab3_posx+58, $tab3_top);
825
+		$pdf->SetXY($tab3_posx + 58, $tab3_top);
826 826
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
827 827
 
828
-		$pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
828
+		$pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
829 829
 
830
-		$y=0;
830
+		$y = 0;
831 831
 
832
-		$pdf->SetFont('','', $default_font_size - 4);
832
+		$pdf->SetFont('', '', $default_font_size - 4);
833 833
 
834 834
 
835 835
 		// Loop on each discount available (deposits and credit notes and excess of payment included)
836 836
 		$sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva,  re.amount_ttc, re.multicurrency_amount_ttc,";
837
-		$sql.= " re.description, re.fk_facture_source,";
838
-		$sql.= " f.type, f.datef";
839
-		$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f";
840
-		$sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
841
-		$resql=$this->db->query($sql);
837
+		$sql .= " re.description, re.fk_facture_source,";
838
+		$sql .= " f.type, f.datef";
839
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f";
840
+		$sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
841
+		$resql = $this->db->query($sql);
842 842
 		if ($resql)
843 843
 		{
844 844
 			$num = $this->db->num_rows($resql);
845
-			$i=0;
846
-			$invoice=new Facture($this->db);
845
+			$i = 0;
846
+			$invoice = new Facture($this->db);
847 847
 			while ($i < $num)
848 848
 			{
849
-				$y+=3;
849
+				$y += 3;
850 850
 				$obj = $this->db->fetch_object($resql);
851 851
 
852
-				if ($obj->type == 2) $text=$outputlangs->transnoentities("CreditNote");
853
-				elseif ($obj->type == 3) $text=$outputlangs->transnoentities("Deposit");
854
-				elseif ($obj->type == 0) $text=$outputlangs->transnoentities("ExcessReceived");
855
-				else $text=$outputlangs->transnoentities("UnknownType");
852
+				if ($obj->type == 2) $text = $outputlangs->transnoentities("CreditNote");
853
+				elseif ($obj->type == 3) $text = $outputlangs->transnoentities("Deposit");
854
+				elseif ($obj->type == 0) $text = $outputlangs->transnoentities("ExcessReceived");
855
+				else $text = $outputlangs->transnoentities("UnknownType");
856 856
 
857 857
 				$invoice->fetch($obj->fk_facture_source);
858 858
 
859
-				$pdf->SetXY($tab3_posx, $tab3_top+$y);
860
-				$pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0);
861
-				$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
859
+				$pdf->SetXY($tab3_posx, $tab3_top + $y);
860
+				$pdf->MultiCell(20, 3, dol_print_date($obj->datef, 'day', false, $outputlangs, true), 0, 'L', 0);
861
+				$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
862 862
 				$pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
863
-				$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
863
+				$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
864 864
 				$pdf->MultiCell(20, 3, $text, 0, 'L', 0);
865
-				$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
865
+				$pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
866 866
 				$pdf->MultiCell(20, 3, $invoice->ref, 0, 'L', 0);
867 867
 
868
-				$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
868
+				$pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
869 869
 
870 870
 				$i++;
871 871
 			}
872 872
 		}
873 873
 		else
874 874
 		{
875
-			$this->error=$this->db->lasterror();
875
+			$this->error = $this->db->lasterror();
876 876
 			return -1;
877 877
 		}
878 878
 
879 879
 		// Loop on each payment
880 880
 		// TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql
881 881
 		$sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
882
-		$sql.= " cp.code";
883
-		$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
884
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
885
-		$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
882
+		$sql .= " cp.code";
883
+		$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
884
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
885
+		$sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
886 886
 		//$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1";
887
-		$sql.= " ORDER BY p.datep";
887
+		$sql .= " ORDER BY p.datep";
888 888
 
889
-		$resql=$this->db->query($sql);
889
+		$resql = $this->db->query($sql);
890 890
 		if ($resql)
891 891
 		{
892 892
 			$num = $this->db->num_rows($resql);
893
-			$i=0;
893
+			$i = 0;
894 894
 			while ($i < $num) {
895
-				$y+=3;
895
+				$y += 3;
896 896
 				$row = $this->db->fetch_object($resql);
897 897
 
898
-				$pdf->SetXY($tab3_posx, $tab3_top+$y);
899
-				$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
900
-				$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
898
+				$pdf->SetXY($tab3_posx, $tab3_top + $y);
899
+				$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
900
+				$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
901 901
 				$pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
902
-				$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
903
-				$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
902
+				$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
903
+				$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
904 904
 
905 905
 				$pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
906
-				$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
906
+				$pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
907 907
 				$pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
908 908
 
909
-				$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
909
+				$pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
910 910
 
911 911
 				$i++;
912 912
 			}
913 913
 		}
914 914
 		else
915 915
 		{
916
-			$this->error=$this->db->lasterror();
916
+			$this->error = $this->db->lasterror();
917 917
 			return -1;
918 918
 		}
919 919
 	}
@@ -936,35 +936,35 @@  discard block
 block discarded – undo
936 936
 
937 937
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
938 938
 
939
-		$pdf->SetFont('','', $default_font_size - 1);
939
+		$pdf->SetFont('', '', $default_font_size - 1);
940 940
 
941 941
 		// If France, show VAT mention if not applicable
942 942
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
943 943
 		{
944
-			$pdf->SetFont('','B', $default_font_size - 2);
944
+			$pdf->SetFont('', 'B', $default_font_size - 2);
945 945
 			$pdf->SetXY($this->marge_gauche, $posy);
946 946
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
947 947
 
948
-			$posy=$pdf->GetY()+4;
948
+			$posy = $pdf->GetY() + 4;
949 949
 		}
950 950
 
951
-		$posxval=52;
951
+		$posxval = 52;
952 952
 
953 953
 		// Show payments conditions
954 954
 		if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
955 955
 		{
956
-			$pdf->SetFont('','B', $default_font_size - 2);
956
+			$pdf->SetFont('', 'B', $default_font_size - 2);
957 957
 			$pdf->SetXY($this->marge_gauche, $posy);
958 958
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
959 959
 			$pdf->MultiCell(43, 4, $titre, 0, 'L');
960 960
 
961
-			$pdf->SetFont('','', $default_font_size - 2);
961
+			$pdf->SetFont('', '', $default_font_size - 2);
962 962
 			$pdf->SetXY($posxval, $posy);
963
-			$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);
964
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
965
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
963
+			$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);
964
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
965
+			$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
966 966
 
967
-			$posy=$pdf->GetY()+3;
967
+			$posy = $pdf->GetY() + 3;
968 968
 		}
969 969
 
970 970
 		if ($object->type != 2)
@@ -983,13 +983,13 @@  discard block
 block discarded – undo
983 983
 				$outputlangs->load("errors");
984 984
 
985 985
 				$pdf->SetXY($this->marge_gauche, $posy);
986
-				$pdf->SetTextColor(200,0,0);
987
-				$pdf->SetFont('','B', $default_font_size - 2);
988
-				$this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup",$object->mode_reglement_code);
989
-				$pdf->MultiCell(80, 3, $this->error,0,'L',0);
990
-				$pdf->SetTextColor(0,0,0);
986
+				$pdf->SetTextColor(200, 0, 0);
987
+				$pdf->SetFont('', 'B', $default_font_size - 2);
988
+				$this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
989
+				$pdf->MultiCell(80, 3, $this->error, 0, 'L', 0);
990
+				$pdf->SetTextColor(0, 0, 0);
991 991
 
992
-				$posy=$pdf->GetY()+1;
992
+				$posy = $pdf->GetY() + 1;
993 993
 			}
994 994
 
995 995
 			// Show payment mode
@@ -997,26 +997,26 @@  discard block
 block discarded – undo
997 997
 			&& $object->mode_reglement_code != 'CHQ'
998 998
 			&& $object->mode_reglement_code != 'VIR')
999 999
 			{
1000
-				$pdf->SetFont('','B', $default_font_size - 2);
1000
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1001 1001
 				$pdf->SetXY($this->marge_gauche, $posy);
1002 1002
 				$titre = $outputlangs->transnoentities("PaymentMode").':';
1003 1003
 				$pdf->MultiCell(80, 5, $titre, 0, 'L');
1004 1004
 
1005
-				$pdf->SetFont('','', $default_font_size - 2);
1005
+				$pdf->SetFont('', '', $default_font_size - 2);
1006 1006
 				$pdf->SetXY($posxval, $posy);
1007
-				$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);
1008
-				$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
1007
+				$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);
1008
+				$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
1009 1009
 
1010
-				$posy=$pdf->GetY()+2;
1010
+				$posy = $pdf->GetY() + 2;
1011 1011
 			}
1012 1012
 
1013 1013
 			// Show payment mode CHQ
1014 1014
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
1015 1015
 			{
1016 1016
 				// Si mode reglement non force ou si force a CHQ
1017
-				if (! empty($conf->global->FACTURE_CHQ_NUMBER))
1017
+				if (!empty($conf->global->FACTURE_CHQ_NUMBER))
1018 1018
 				{
1019
-					$diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE);
1019
+					$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1020 1020
 
1021 1021
 					if ($conf->global->FACTURE_CHQ_NUMBER > 0)
1022 1022
 					{
@@ -1024,31 +1024,31 @@  discard block
 block discarded – undo
1024 1024
 						$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1025 1025
 
1026 1026
 						$pdf->SetXY($this->marge_gauche, $posy);
1027
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
1028
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
1029
-						$posy=$pdf->GetY()+1;
1027
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1028
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
1029
+						$posy = $pdf->GetY() + 1;
1030 1030
 
1031 1031
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1032 1032
 			            {
1033 1033
 							$pdf->SetXY($this->marge_gauche, $posy);
1034
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
1034
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1035 1035
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
1036
-							$posy=$pdf->GetY()+2;
1036
+							$posy = $pdf->GetY() + 2;
1037 1037
 			            }
1038 1038
 					}
1039 1039
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
1040 1040
 					{
1041 1041
 						$pdf->SetXY($this->marge_gauche, $posy);
1042
-						$pdf->SetFont('','B', $default_font_size - $diffsizetitle);
1043
-						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
1044
-						$posy=$pdf->GetY()+1;
1042
+						$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
1043
+						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
1044
+						$posy = $pdf->GetY() + 1;
1045 1045
 
1046 1046
 			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1047 1047
 			            {
1048 1048
 							$pdf->SetXY($this->marge_gauche, $posy);
1049
-							$pdf->SetFont('','', $default_font_size - $diffsizetitle);
1049
+							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
1050 1050
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
1051
-							$posy=$pdf->GetY()+2;
1051
+							$posy = $pdf->GetY() + 2;
1052 1052
 			            }
1053 1053
 					}
1054 1054
 				}
@@ -1057,19 +1057,19 @@  discard block
 block discarded – undo
1057 1057
 			// If payment mode not forced or forced to VIR, show payment with BAN
1058 1058
 			if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
1059 1059
 			{
1060
-				if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
1060
+				if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
1061 1061
 				{
1062
-					$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
1063
-					if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
1062
+					$bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1063
+					if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
1064 1064
 					$account = new Account($this->db);
1065 1065
 					$account->fetch($bankid);
1066 1066
 
1067
-					$curx=$this->marge_gauche;
1068
-					$cury=$posy;
1067
+					$curx = $this->marge_gauche;
1068
+					$cury = $posy;
1069 1069
 
1070
-					$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
1070
+					$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1071 1071
 
1072
-					$posy+=2;
1072
+					$posy += 2;
1073 1073
 				}
1074 1074
 			}
1075 1075
 		}
@@ -1092,47 +1092,47 @@  discard block
 block discarded – undo
1092 1092
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1093 1093
 	{
1094 1094
         // phpcs:enable
1095
-		global $conf,$mysoc;
1095
+		global $conf, $mysoc;
1096 1096
 
1097
-        $sign=1;
1098
-        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1097
+        $sign = 1;
1098
+        if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
1099 1099
 
1100 1100
         $default_font_size = pdf_getPDFFontSize($outputlangs);
1101 1101
 
1102 1102
 		$tab2_top = $posy;
1103 1103
 		$tab2_hl = 4;
1104
-		$pdf->SetFont('','', $default_font_size - 1);
1104
+		$pdf->SetFont('', '', $default_font_size - 1);
1105 1105
 
1106 1106
 		// Tableau total
1107 1107
 		$col1x = 120; $col2x = 170;
1108 1108
 		if ($this->page_largeur < 210) // To work with US executive format
1109 1109
 		{
1110
-			$col2x-=20;
1110
+			$col2x -= 20;
1111 1111
 		}
1112 1112
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1113 1113
 
1114
-		$useborder=0;
1114
+		$useborder = 0;
1115 1115
 		$index = 0;
1116 1116
 
1117 1117
 		// Total HT
1118
-		$pdf->SetFillColor(255,255,255);
1118
+		$pdf->SetFillColor(255, 255, 255);
1119 1119
 		$pdf->SetXY($col1x, $tab2_top + 0);
1120
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1120
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1121 1121
 
1122 1122
 		$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1123 1123
 		$pdf->SetXY($col2x, $tab2_top + 0);
1124
-		$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
1124
+		$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0, $outputlangs), 0, 'R', 1);
1125 1125
 
1126 1126
 		// Show VAT by rates and total
1127
-		$pdf->SetFillColor(248,248,248);
1127
+		$pdf->SetFillColor(248, 248, 248);
1128 1128
 
1129 1129
 		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1130 1130
 
1131
-		$this->atleastoneratenotnull=0;
1131
+		$this->atleastoneratenotnull = 0;
1132 1132
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1133 1133
 		{
1134
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1135
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1134
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
1135
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1136 1136
 			{
1137 1137
 				// Nothing to do
1138 1138
 			}
@@ -1143,29 +1143,29 @@  discard block
 block discarded – undo
1143 1143
 				//Local tax 1 before VAT
1144 1144
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1145 1145
 				//{
1146
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1146
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1147 1147
 					{
1148
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1148
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1149 1149
 
1150
-						foreach( $localtax_rate as $tvakey => $tvaval )
1150
+						foreach ($localtax_rate as $tvakey => $tvaval)
1151 1151
 						{
1152
-							if ($tvakey!=0)    // On affiche pas taux 0
1152
+							if ($tvakey != 0)    // On affiche pas taux 0
1153 1153
 							{
1154 1154
 								//$this->atleastoneratenotnull++;
1155 1155
 
1156 1156
 								$index++;
1157 1157
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1158 1158
 
1159
-								$tvacompl='';
1160
-								if (preg_match('/\*/',$tvakey))
1159
+								$tvacompl = '';
1160
+								if (preg_match('/\*/', $tvakey))
1161 1161
 								{
1162
-									$tvakey=str_replace('*','',$tvakey);
1162
+									$tvakey = str_replace('*', '', $tvakey);
1163 1163
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1164 1164
 								}
1165 1165
 
1166
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1167
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1168
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1166
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1167
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1168
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1169 1169
 
1170 1170
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1171 1171
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1176,13 +1176,13 @@  discard block
 block discarded – undo
1176 1176
 				//Local tax 2 before VAT
1177 1177
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1178 1178
 				//{
1179
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1179
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1180 1180
 					{
1181
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1181
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1182 1182
 
1183
-						foreach( $localtax_rate as $tvakey => $tvaval )
1183
+						foreach ($localtax_rate as $tvakey => $tvaval)
1184 1184
 						{
1185
-							if ($tvakey!=0)    // On affiche pas taux 0
1185
+							if ($tvakey != 0)    // On affiche pas taux 0
1186 1186
 							{
1187 1187
 								//$this->atleastoneratenotnull++;
1188 1188
 
@@ -1191,15 +1191,15 @@  discard block
 block discarded – undo
1191 1191
 								$index++;
1192 1192
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1193 1193
 
1194
-								$tvacompl='';
1195
-								if (preg_match('/\*/',$tvakey))
1194
+								$tvacompl = '';
1195
+								if (preg_match('/\*/', $tvakey))
1196 1196
 								{
1197
-									$tvakey=str_replace('*','',$tvakey);
1197
+									$tvakey = str_replace('*', '', $tvakey);
1198 1198
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1199 1199
 								}
1200
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1201
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1202
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1200
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1201
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1202
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1203 1203
 
1204 1204
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1205 1205
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1214,20 +1214,20 @@  discard block
 block discarded – undo
1214 1214
 				if ($object->situation_cycle_ref && $object->situation_counter > 1) {
1215 1215
 
1216 1216
 					$sum_pdf_tva = 0;
1217
-					foreach($this->tva as $tvakey => $tvaval){
1218
-						$sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object
1217
+					foreach ($this->tva as $tvakey => $tvaval) {
1218
+						$sum_pdf_tva += $tvaval; // sum VAT amounts to compare to object
1219 1219
 					}
1220 1220
 
1221
-					if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one)
1221
+					if ($sum_pdf_tva != $object->total_tva) { // apply coef to recover the VAT object amount (the good one)
1222 1222
 						$coef_fix_tva = $object->total_tva / $sum_pdf_tva;
1223 1223
 
1224
-						foreach($this->tva as $tvakey => $tvaval) {
1225
-							$this->tva[$tvakey]=$tvaval * $coef_fix_tva;
1224
+						foreach ($this->tva as $tvakey => $tvaval) {
1225
+							$this->tva[$tvakey] = $tvaval * $coef_fix_tva;
1226 1226
 						}
1227 1227
 					}
1228 1228
 				}
1229 1229
 
1230
-				foreach($this->tva as $tvakey => $tvaval)
1230
+				foreach ($this->tva as $tvakey => $tvaval)
1231 1231
 				{
1232 1232
 					if ($tvakey != 0)    // On affiche pas taux 0
1233 1233
 					{
@@ -1236,15 +1236,15 @@  discard block
 block discarded – undo
1236 1236
 						$index++;
1237 1237
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1238 1238
 
1239
-						$tvacompl='';
1240
-						if (preg_match('/\*/',$tvakey))
1239
+						$tvacompl = '';
1240
+						if (preg_match('/\*/', $tvakey))
1241 1241
 						{
1242
-							$tvakey=str_replace('*','',$tvakey);
1242
+							$tvakey = str_replace('*', '', $tvakey);
1243 1243
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1244 1244
 						}
1245
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1246
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1247
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1245
+						$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
1246
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
1247
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1248 1248
 
1249 1249
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1250 1250
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1254,11 +1254,11 @@  discard block
 block discarded – undo
1254 1254
 				//Local tax 1 after VAT
1255 1255
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1256 1256
 				//{
1257
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1257
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1258 1258
 					{
1259
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1259
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1260 1260
 
1261
-						foreach( $localtax_rate as $tvakey => $tvaval )
1261
+						foreach ($localtax_rate as $tvakey => $tvaval)
1262 1262
 						{
1263 1263
 							if ($tvakey != 0)    // On affiche pas taux 0
1264 1264
 							{
@@ -1267,16 +1267,16 @@  discard block
 block discarded – undo
1267 1267
 								$index++;
1268 1268
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1269 1269
 
1270
-								$tvacompl='';
1271
-								if (preg_match('/\*/',$tvakey))
1270
+								$tvacompl = '';
1271
+								if (preg_match('/\*/', $tvakey))
1272 1272
 								{
1273
-									$tvakey=str_replace('*','',$tvakey);
1273
+									$tvakey = str_replace('*', '', $tvakey);
1274 1274
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1275 1275
 								}
1276
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1277
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1276
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1277
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1278 1278
 
1279
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1279
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1280 1280
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1281 1281
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1282 1282
 							}
@@ -1286,11 +1286,11 @@  discard block
 block discarded – undo
1286 1286
 				//Local tax 2 after VAT
1287 1287
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1288 1288
 				//{
1289
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1289
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1290 1290
 					{
1291
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1291
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1292 1292
 
1293
-						foreach( $localtax_rate as $tvakey => $tvaval )
1293
+						foreach ($localtax_rate as $tvakey => $tvaval)
1294 1294
 						{
1295 1295
 						    // retrieve global local tax
1296 1296
 							if ($tvakey != 0)    // On affiche pas taux 0
@@ -1300,16 +1300,16 @@  discard block
 block discarded – undo
1300 1300
 								$index++;
1301 1301
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1302 1302
 
1303
-								$tvacompl='';
1304
-								if (preg_match('/\*/',$tvakey))
1303
+								$tvacompl = '';
1304
+								if (preg_match('/\*/', $tvakey))
1305 1305
 								{
1306
-									$tvakey=str_replace('*','',$tvakey);
1306
+									$tvakey = str_replace('*', '', $tvakey);
1307 1307
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1308 1308
 								}
1309
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1309
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1310 1310
 
1311
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1312
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1311
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1312
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1313 1313
 
1314 1314
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1315 1315
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
 				{
1324 1324
 					$index++;
1325 1325
 					$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1326
-					$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
1326
+					$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RevenueStamp"), $useborder, 'L', 1);
1327 1327
 
1328 1328
 					$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1329 1329
 					$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $object->revenuestamp), $useborder, 'R', 1);
@@ -1332,28 +1332,28 @@  discard block
 block discarded – undo
1332 1332
 				// Total TTC
1333 1333
 				$index++;
1334 1334
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1335
-				$pdf->SetTextColor(0,0,60);
1336
-				$pdf->SetFillColor(224,224,224);
1337
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1335
+				$pdf->SetTextColor(0, 0, 60);
1336
+				$pdf->SetFillColor(224, 224, 224);
1337
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1338 1338
 
1339 1339
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1340 1340
 				$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1341 1341
 			}
1342 1342
 		}
1343 1343
 
1344
-		$pdf->SetTextColor(0,0,0);
1345
-		$creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);	// Warning, this also include excess received
1346
-		$depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
1344
+		$pdf->SetTextColor(0, 0, 0);
1345
+		$creditnoteamount = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
1346
+		$depositsamount = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
1347 1347
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1348 1348
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1349
-		if ($object->paye) $resteapayer=0;
1349
+		if ($object->paye) $resteapayer = 0;
1350 1350
 
1351 1351
 		if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
1352 1352
 		{
1353 1353
 			// Already paid + Deposits
1354 1354
 			$index++;
1355 1355
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1356
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
1356
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Paid"), 0, 'L', 0);
1357 1357
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1358 1358
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle + $depositsamount, 0, $outputlangs), 0, 'R', 0);
1359 1359
 
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 				$labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes");
1364 1364
 				$index++;
1365 1365
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1366
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $labeltouse, 0, 'L', 0);
1366
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0, 'L', 0);
1367 1367
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1368 1368
 				$pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0);
1369 1369
 			}
@@ -1372,26 +1372,26 @@  discard block
 block discarded – undo
1372 1372
 			if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT)
1373 1373
 			{
1374 1374
 				$index++;
1375
-				$pdf->SetFillColor(255,255,255);
1375
+				$pdf->SetFillColor(255, 255, 255);
1376 1376
 
1377 1377
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1378
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
1378
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
1379 1379
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1380 1380
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
1381 1381
 
1382
-				$resteapayer=0;
1382
+				$resteapayer = 0;
1383 1383
 			}
1384 1384
 
1385 1385
 			$index++;
1386
-			$pdf->SetTextColor(0,0,60);
1387
-			$pdf->SetFillColor(224,224,224);
1386
+			$pdf->SetTextColor(0, 0, 60);
1387
+			$pdf->SetFillColor(224, 224, 224);
1388 1388
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1389
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1389
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1390 1390
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1391 1391
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1392 1392
 
1393
-			$pdf->SetFont('','', $default_font_size - 1);
1394
-			$pdf->SetTextColor(0,0,0);
1393
+			$pdf->SetFont('', '', $default_font_size - 1);
1394
+			$pdf->SetTextColor(0, 0, 0);
1395 1395
 		}
1396 1396
 
1397 1397
 		$index++;
@@ -1411,48 +1411,48 @@  discard block
 block discarded – undo
1411 1411
 	 *   @param		string		$currency		Currency code
1412 1412
 	 *   @return	void
1413 1413
 	 */
1414
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1414
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1415 1415
 	{
1416 1416
 		global $conf;
1417 1417
 
1418 1418
 		// Force to disable hidetop and hidebottom
1419
-		$hidebottom=0;
1420
-		if ($hidetop) $hidetop=-1;
1419
+		$hidebottom = 0;
1420
+		if ($hidetop) $hidetop = -1;
1421 1421
 
1422 1422
 		$currency = !empty($currency) ? $currency : $conf->currency;
1423 1423
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1424 1424
 
1425 1425
 		// Amount in (at tab_top - 1)
1426
-		$pdf->SetTextColor(0,0,0);
1427
-		$pdf->SetFont('','', $default_font_size - 2);
1426
+		$pdf->SetTextColor(0, 0, 0);
1427
+		$pdf->SetFont('', '', $default_font_size - 2);
1428 1428
 
1429 1429
 		if (empty($hidetop))
1430 1430
 		{
1431
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1432
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1431
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1432
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1433 1433
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1434 1434
 
1435 1435
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1436
-			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));
1436
+			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));
1437 1437
 		}
1438 1438
 
1439
-		$pdf->SetDrawColor(128,128,128);
1440
-		$pdf->SetFont('','', $default_font_size - 1);
1439
+		$pdf->SetDrawColor(128, 128, 128);
1440
+		$pdf->SetFont('', '', $default_font_size - 1);
1441 1441
 
1442 1442
 		// Output Rect
1443
-		$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
1443
+		$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
1444 1444
 
1445 1445
 		if (empty($hidetop))
1446 1446
 		{
1447
-			$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
1447
+			$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
1448 1448
 
1449
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1450
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1449
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1450
+			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1451 1451
 		}
1452 1452
 
1453
-		if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
1453
+		if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
1454 1454
 		{
1455
-			$pdf->line($this->posxpicture-1, $tab_top, $this->posxpicture-1, $tab_top + $tab_height);
1455
+			$pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1456 1456
 			if (empty($hidetop))
1457 1457
 			{
1458 1458
 				//$pdf->SetXY($this->posxpicture-1, $tab_top+1);
@@ -1462,37 +1462,37 @@  discard block
 block discarded – undo
1462 1462
 
1463 1463
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1464 1464
 		{
1465
-			$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1465
+			$pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1466 1466
 			if (empty($hidetop))
1467 1467
 			{
1468
-				$pdf->SetXY($this->posxtva-3, $tab_top+1);
1469
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1468
+				$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1469
+				$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1470 1470
 			}
1471 1471
 		}
1472 1472
 
1473
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1473
+		$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1474 1474
 		if (empty($hidetop))
1475 1475
 		{
1476
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1477
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1476
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
1477
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1478 1478
 		}
1479 1479
 
1480
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1480
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1481 1481
 		if (empty($hidetop))
1482 1482
 		{
1483
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1483
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1484 1484
 
1485
-			if($this->situationinvoice)
1485
+			if ($this->situationinvoice)
1486 1486
 			{
1487
-				$pdf->MultiCell($this->posxprogress-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1487
+				$pdf->MultiCell($this->posxprogress - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1488 1488
 			}
1489
-			else if($conf->global->PRODUCT_USE_UNITS)
1489
+			else if ($conf->global->PRODUCT_USE_UNITS)
1490 1490
 			{
1491
-				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1491
+				$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1492 1492
 			}
1493 1493
 			else
1494 1494
 			{
1495
-				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1495
+				$pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1496 1496
 			}
1497 1497
 		}
1498 1498
 
@@ -1501,24 +1501,24 @@  discard block
 block discarded – undo
1501 1501
 
1502 1502
 			if (empty($hidetop)) {
1503 1503
 
1504
-				$pdf->SetXY($this->posxprogress, $tab_top+1);
1504
+				$pdf->SetXY($this->posxprogress, $tab_top + 1);
1505 1505
 
1506
-				if($conf->global->PRODUCT_USE_UNITS)
1506
+				if ($conf->global->PRODUCT_USE_UNITS)
1507 1507
 				{
1508
-					$pdf->MultiCell($this->posxunit-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C');
1508
+					$pdf->MultiCell($this->posxunit - $this->posxprogress, 2, $outputlangs->transnoentities("Progress"), '', 'C');
1509 1509
 				}
1510 1510
 				else if ($this->atleastonediscount)
1511 1511
 				{
1512
-					$pdf->MultiCell($this->posxdiscount-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C');
1512
+					$pdf->MultiCell($this->posxdiscount - $this->posxprogress, 2, $outputlangs->transnoentities("Progress"), '', 'C');
1513 1513
 				}
1514 1514
 				else
1515 1515
 				{
1516
-					$pdf->MultiCell($this->postotalht-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C');
1516
+					$pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities("Progress"), '', 'C');
1517 1517
 				}
1518 1518
 			}
1519 1519
 		}
1520 1520
 
1521
-		if($conf->global->PRODUCT_USE_UNITS) {
1521
+		if ($conf->global->PRODUCT_USE_UNITS) {
1522 1522
 			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1523 1523
 			if (empty($hidetop)) {
1524 1524
 				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -1527,23 +1527,23 @@  discard block
 block discarded – undo
1527 1527
 			}
1528 1528
 		}
1529 1529
 
1530
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1530
+		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1531 1531
 		if (empty($hidetop))
1532 1532
 		{
1533 1533
 			if ($this->atleastonediscount)
1534 1534
 			{
1535
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1536
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1535
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1536
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1537 1537
 			}
1538 1538
 		}
1539 1539
 
1540 1540
 		if ($this->situationinvoice)
1541 1541
 		{
1542
-			$pdf->line($this->postotalht+4, $tab_top, $this->postotalht+4, $tab_top + $tab_height);
1542
+			$pdf->line($this->postotalht + 4, $tab_top, $this->postotalht + 4, $tab_top + $tab_height);
1543 1543
 			if (empty($hidetop))
1544 1544
 			{
1545
-				$pdf->SetXY($this->postotalht-19, $tab_top+1);
1546
-				$pdf->MultiCell(30,2, $outputlangs->transnoentities("Situation"),'','C');
1545
+				$pdf->SetXY($this->postotalht - 19, $tab_top + 1);
1546
+				$pdf->MultiCell(30, 2, $outputlangs->transnoentities("Situation"), '', 'C');
1547 1547
 			}
1548 1548
 		}
1549 1549
 
@@ -1553,8 +1553,8 @@  discard block
 block discarded – undo
1553 1553
 		}
1554 1554
 		if (empty($hidetop))
1555 1555
 		{
1556
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1557
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1556
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1557
+			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1558 1558
 		}
1559 1559
 	}
1560 1560
 
@@ -1576,162 +1576,162 @@  discard block
 block discarded – undo
1576 1576
 
1577 1577
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1578 1578
 
1579
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1579
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1580 1580
 
1581 1581
 		// Show Draft Watermark
1582
-		if($object->statut==Facture::STATUS_DRAFT && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) )
1582
+		if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
1583 1583
         {
1584
-		      pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->FACTURE_DRAFT_WATERMARK);
1584
+		      pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
1585 1585
         }
1586 1586
 
1587
-		$pdf->SetTextColor(0,0,60);
1588
-		$pdf->SetFont('','B', $default_font_size + 3);
1587
+		$pdf->SetTextColor(0, 0, 60);
1588
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1589 1589
 
1590 1590
 		$w = 110;
1591 1591
 
1592
-		$posy=$this->marge_haute;
1593
-        $posx=$this->page_largeur-$this->marge_droite-$w;
1592
+		$posy = $this->marge_haute;
1593
+        $posx = $this->page_largeur - $this->marge_droite - $w;
1594 1594
 
1595
-		$pdf->SetXY($this->marge_gauche,$posy);
1595
+		$pdf->SetXY($this->marge_gauche, $posy);
1596 1596
 
1597 1597
 		// Logo
1598 1598
 		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1599 1599
 		{
1600
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1600
+			$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1601 1601
 			if ($this->emetteur->logo)
1602 1602
 			{
1603 1603
 				if (is_readable($logo))
1604 1604
 				{
1605
-				    $height=pdf_getHeightForLogo($logo);
1606
-					$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1605
+				    $height = pdf_getHeightForLogo($logo);
1606
+					$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1607 1607
 				}
1608 1608
 				else
1609 1609
 				{
1610
-					$pdf->SetTextColor(200,0,0);
1611
-					$pdf->SetFont('','B',$default_font_size - 2);
1612
-					$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1610
+					$pdf->SetTextColor(200, 0, 0);
1611
+					$pdf->SetFont('', 'B', $default_font_size - 2);
1612
+					$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1613 1613
 					$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1614 1614
 				}
1615 1615
 			}
1616 1616
 			else
1617 1617
 			{
1618
-				$text=$this->emetteur->name;
1618
+				$text = $this->emetteur->name;
1619 1619
 				$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1620 1620
 			}
1621 1621
 		}
1622 1622
 
1623
-		$pdf->SetFont('','B', $default_font_size + 3);
1624
-		$pdf->SetXY($posx,$posy);
1625
-		$pdf->SetTextColor(0,0,60);
1626
-		$title=$outputlangs->transnoentities("PdfInvoiceTitle");
1627
-		if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement");
1628
-		if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir");
1629
-		if ($object->type == 3) $title=$outputlangs->transnoentities("InvoiceDeposit");
1630
-		if ($object->type == 4) $title=$outputlangs->transnoentities("InvoiceProForma");
1631
-		if ($this->situationinvoice) $title=$outputlangs->transnoentities("InvoiceSituation");
1623
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1624
+		$pdf->SetXY($posx, $posy);
1625
+		$pdf->SetTextColor(0, 0, 60);
1626
+		$title = $outputlangs->transnoentities("PdfInvoiceTitle");
1627
+		if ($object->type == 1) $title = $outputlangs->transnoentities("InvoiceReplacement");
1628
+		if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir");
1629
+		if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit");
1630
+		if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma");
1631
+		if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation");
1632 1632
 		$pdf->MultiCell($w, 3, $title, '', 'R');
1633 1633
 
1634
-		$pdf->SetFont('','B',$default_font_size);
1634
+		$pdf->SetFont('', 'B', $default_font_size);
1635 1635
 
1636
-		$posy+=5;
1637
-		$pdf->SetXY($posx,$posy);
1638
-		$pdf->SetTextColor(0,0,60);
1639
-		$textref=$outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref);
1636
+		$posy += 5;
1637
+		$pdf->SetXY($posx, $posy);
1638
+		$pdf->SetTextColor(0, 0, 60);
1639
+		$textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
1640 1640
 		if ($object->statut == Facture::STATUS_DRAFT)
1641 1641
 		{
1642
-			$pdf->SetTextColor(128,0,0);
1643
-			$textref.=' - '.$outputlangs->transnoentities("NotValidated");
1642
+			$pdf->SetTextColor(128, 0, 0);
1643
+			$textref .= ' - '.$outputlangs->transnoentities("NotValidated");
1644 1644
 		}
1645 1645
 		$pdf->MultiCell($w, 4, $textref, '', 'R');
1646 1646
 
1647
-		$posy+=1;
1648
-		$pdf->SetFont('','', $default_font_size - 2);
1647
+		$posy += 1;
1648
+		$pdf->SetFont('', '', $default_font_size - 2);
1649 1649
 
1650 1650
 		if ($object->ref_client)
1651 1651
 		{
1652
-			$posy+=4;
1653
-			$pdf->SetXY($posx,$posy);
1654
-			$pdf->SetTextColor(0,0,60);
1655
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1652
+			$posy += 4;
1653
+			$pdf->SetXY($posx, $posy);
1654
+			$pdf->SetTextColor(0, 0, 60);
1655
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1656 1656
 		}
1657 1657
 
1658
-		$objectidnext=$object->getIdReplacingInvoice('validated');
1658
+		$objectidnext = $object->getIdReplacingInvoice('validated');
1659 1659
 		if ($object->type == 0 && $objectidnext)
1660 1660
 		{
1661
-			$objectreplacing=new Facture($this->db);
1661
+			$objectreplacing = new Facture($this->db);
1662 1662
 			$objectreplacing->fetch($objectidnext);
1663 1663
 
1664
-			$posy+=3;
1665
-			$pdf->SetXY($posx,$posy);
1666
-			$pdf->SetTextColor(0,0,60);
1664
+			$posy += 3;
1665
+			$pdf->SetXY($posx, $posy);
1666
+			$pdf->SetTextColor(0, 0, 60);
1667 1667
 			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R');
1668 1668
 		}
1669 1669
 		if ($object->type == 1)
1670 1670
 		{
1671
-			$objectreplaced=new Facture($this->db);
1671
+			$objectreplaced = new Facture($this->db);
1672 1672
 			$objectreplaced->fetch($object->fk_facture_source);
1673 1673
 
1674
-			$posy+=4;
1675
-			$pdf->SetXY($posx,$posy);
1676
-			$pdf->SetTextColor(0,0,60);
1674
+			$posy += 4;
1675
+			$pdf->SetXY($posx, $posy);
1676
+			$pdf->SetTextColor(0, 0, 60);
1677 1677
 			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
1678 1678
 		}
1679 1679
 		if ($object->type == 2 && !empty($object->fk_facture_source))
1680 1680
 		{
1681
-			$objectreplaced=new Facture($this->db);
1681
+			$objectreplaced = new Facture($this->db);
1682 1682
 			$objectreplaced->fetch($object->fk_facture_source);
1683 1683
 
1684
-			$posy+=3;
1685
-			$pdf->SetXY($posx,$posy);
1686
-			$pdf->SetTextColor(0,0,60);
1684
+			$posy += 3;
1685
+			$pdf->SetXY($posx, $posy);
1686
+			$pdf->SetTextColor(0, 0, 60);
1687 1687
 			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R');
1688 1688
 		}
1689 1689
 
1690
-		$posy+=4;
1691
-		$pdf->SetXY($posx,$posy);
1692
-		$pdf->SetTextColor(0,0,60);
1693
-		$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice")." : " . dol_print_date($object->date,"day",false,$outputlangs), '', 'R');
1690
+		$posy += 4;
1691
+		$pdf->SetXY($posx, $posy);
1692
+		$pdf->SetTextColor(0, 0, 60);
1693
+		$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice")." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
1694 1694
 
1695
-		if (! empty($conf->global->INVOICE_POINTOFTAX_DATE))
1695
+		if (!empty($conf->global->INVOICE_POINTOFTAX_DATE))
1696 1696
 		{
1697
-			$posy+=4;
1698
-			$pdf->SetXY($posx,$posy);
1699
-			$pdf->SetTextColor(0,0,60);
1700
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : " . dol_print_date($object->date_pointoftax,"day",false,$outputlangs), '', 'R');
1697
+			$posy += 4;
1698
+			$pdf->SetXY($posx, $posy);
1699
+			$pdf->SetTextColor(0, 0, 60);
1700
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : ".dol_print_date($object->date_pointoftax, "day", false, $outputlangs), '', 'R');
1701 1701
 		}
1702 1702
 
1703 1703
 		if ($object->type != 2)
1704 1704
 		{
1705
-			$posy+=3;
1706
-			$pdf->SetXY($posx,$posy);
1707
-			$pdf->SetTextColor(0,0,60);
1708
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateDue")." : " . dol_print_date($object->date_lim_reglement,"day",false,$outputlangs,true), '', 'R');
1705
+			$posy += 3;
1706
+			$pdf->SetXY($posx, $posy);
1707
+			$pdf->SetTextColor(0, 0, 60);
1708
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateDue")." : ".dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R');
1709 1709
 		}
1710 1710
 
1711 1711
 		if ($object->thirdparty->code_client)
1712 1712
 		{
1713
-			$posy+=3;
1714
-			$pdf->SetXY($posx,$posy);
1715
-			$pdf->SetTextColor(0,0,60);
1716
-			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1713
+			$posy += 3;
1714
+			$pdf->SetXY($posx, $posy);
1715
+			$pdf->SetTextColor(0, 0, 60);
1716
+			$pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
1717 1717
 		}
1718 1718
 
1719 1719
 		// Get contact
1720 1720
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1721 1721
 		{
1722
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1722
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1723 1723
 		    if (count($arrayidcontact) > 0)
1724 1724
 		    {
1725
-		        $usertmp=new User($this->db);
1725
+		        $usertmp = new User($this->db);
1726 1726
 		        $usertmp->fetch($arrayidcontact[0]);
1727
-                $posy+=4;
1728
-                $pdf->SetXY($posx,$posy);
1729
-		        $pdf->SetTextColor(0,0,60);
1727
+                $posy += 4;
1728
+                $pdf->SetXY($posx, $posy);
1729
+		        $pdf->SetTextColor(0, 0, 60);
1730 1730
 		        $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1731 1731
 		    }
1732 1732
 		}
1733 1733
 
1734
-		$posy+=1;
1734
+		$posy += 1;
1735 1735
 
1736 1736
 		$top_shift = 0;
1737 1737
 		// Show list of linked objects
@@ -1748,45 +1748,45 @@  discard block
 block discarded – undo
1748 1748
 			$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1749 1749
 
1750 1750
 			// Show sender
1751
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1752
-			$posy+=$top_shift;
1753
-			$posx=$this->marge_gauche;
1754
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1751
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1752
+			$posy += $top_shift;
1753
+			$posx = $this->marge_gauche;
1754
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1755 1755
 
1756
-			$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1757
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1756
+			$hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1757
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1758 1758
 
1759 1759
 
1760 1760
 			// Show sender frame
1761
-			$pdf->SetTextColor(0,0,0);
1762
-			$pdf->SetFont('','', $default_font_size - 2);
1763
-			$pdf->SetXY($posx,$posy-5);
1764
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1765
-			$pdf->SetXY($posx,$posy);
1766
-			$pdf->SetFillColor(230,230,230);
1761
+			$pdf->SetTextColor(0, 0, 0);
1762
+			$pdf->SetFont('', '', $default_font_size - 2);
1763
+			$pdf->SetXY($posx, $posy - 5);
1764
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1765
+			$pdf->SetXY($posx, $posy);
1766
+			$pdf->SetFillColor(230, 230, 230);
1767 1767
 			$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
1768
-			$pdf->SetTextColor(0,0,60);
1768
+			$pdf->SetTextColor(0, 0, 60);
1769 1769
 
1770 1770
 			// Show sender name
1771
-			$pdf->SetXY($posx+2,$posy+3);
1772
-			$pdf->SetFont('','B', $default_font_size);
1773
-			$pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1774
-			$posy=$pdf->getY();
1771
+			$pdf->SetXY($posx + 2, $posy + 3);
1772
+			$pdf->SetFont('', 'B', $default_font_size);
1773
+			$pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1774
+			$posy = $pdf->getY();
1775 1775
 
1776 1776
 			// Show sender information
1777
-			$pdf->SetXY($posx+2,$posy);
1778
-			$pdf->SetFont('','', $default_font_size - 1);
1779
-			$pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L');
1777
+			$pdf->SetXY($posx + 2, $posy);
1778
+			$pdf->SetFont('', '', $default_font_size - 1);
1779
+			$pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
1780 1780
 
1781 1781
 
1782 1782
 
1783 1783
 			// If BILLING contact defined on invoice, we use it
1784
-			$usecontact=false;
1785
-			$arrayidcontact=$object->getIdContact('external','BILLING');
1784
+			$usecontact = false;
1785
+			$arrayidcontact = $object->getIdContact('external', 'BILLING');
1786 1786
 			if (count($arrayidcontact) > 0)
1787 1787
 			{
1788
-				$usecontact=true;
1789
-				$result=$object->fetch_contact($arrayidcontact[0]);
1788
+				$usecontact = true;
1789
+				$result = $object->fetch_contact($arrayidcontact[0]);
1790 1790
 			}
1791 1791
 
1792 1792
 			//Recipient name
@@ -1797,39 +1797,39 @@  discard block
 block discarded – undo
1797 1797
 				$thirdparty = $object->thirdparty;
1798 1798
 			}
1799 1799
 
1800
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1800
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1801 1801
 
1802
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object);
1802
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1803 1803
 
1804 1804
 			// Show recipient
1805
-			$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1806
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1807
-			$posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1808
-			$posy+=$top_shift;
1809
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1810
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1805
+			$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1806
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1807
+			$posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1808
+			$posy += $top_shift;
1809
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1810
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1811 1811
 
1812 1812
 			// Show recipient frame
1813
-			$pdf->SetTextColor(0,0,0);
1814
-			$pdf->SetFont('','', $default_font_size - 2);
1815
-			$pdf->SetXY($posx+2,$posy-5);
1816
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1813
+			$pdf->SetTextColor(0, 0, 0);
1814
+			$pdf->SetFont('', '', $default_font_size - 2);
1815
+			$pdf->SetXY($posx + 2, $posy - 5);
1816
+			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1817 1817
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1818 1818
 
1819 1819
 			// Show recipient name
1820
-			$pdf->SetXY($posx+2,$posy+3);
1821
-			$pdf->SetFont('','B', $default_font_size);
1820
+			$pdf->SetXY($posx + 2, $posy + 3);
1821
+			$pdf->SetFont('', 'B', $default_font_size);
1822 1822
 			$pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
1823 1823
 
1824 1824
 			$posy = $pdf->getY();
1825 1825
 
1826 1826
 			// Show recipient information
1827
-			$pdf->SetFont('','', $default_font_size - 1);
1828
-			$pdf->SetXY($posx+2,$posy);
1827
+			$pdf->SetFont('', '', $default_font_size - 1);
1828
+			$pdf->SetXY($posx + 2, $posy);
1829 1829
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1830 1830
 		}
1831 1831
 
1832
-		$pdf->SetTextColor(0,0,0);
1832
+		$pdf->SetTextColor(0, 0, 0);
1833 1833
 		return $top_shift;
1834 1834
 	}
1835 1835
 
@@ -1842,10 +1842,10 @@  discard block
 block discarded – undo
1842 1842
 	 *      @param	int			$hidefreetext		1=Hide free text
1843 1843
 	 *      @return	int								Return height of bottom margin including footer text
1844 1844
 	 */
1845
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1845
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1846 1846
 	{
1847 1847
 		global $conf;
1848
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1849
-		return pdf_pagefoot($pdf,$outputlangs,'INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1848
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1849
+		return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1850 1850
 	}
1851 1851
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/facture/mod_facture_mars.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *	\ingroup    facture
24 24
  *	\brief      File containing class for numbering module Mars
25 25
  */
26
-require_once DOL_DOCUMENT_ROOT .'/core/modules/facture/modules_facture.php';
26
+require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
27 27
 
28 28
 /**
29 29
  * 	Classe du modele de numerotation de reference de facture Mars
@@ -34,20 +34,20 @@  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 $prefixinvoice='FA';
39
+	public $prefixinvoice = 'FA';
40 40
 
41
-	public $prefixreplacement='FR';
41
+	public $prefixreplacement = 'FR';
42 42
 
43
-	public $prefixdeposit='AC';
43
+	public $prefixdeposit = 'AC';
44 44
 
45
-	public $prefixcreditnote='AV';
45
+	public $prefixcreditnote = 'AV';
46 46
 
47 47
 	/**
48 48
 	 * @var string Error code (or message)
49 49
 	 */
50
-	public $error='';
50
+	public $error = '';
51 51
 
52 52
 
53 53
 	/**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	function __construct()
57 57
 	{
58
-		if (! empty($conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX))
58
+		if (!empty($conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX))
59 59
 		{
60 60
 			$this->prefixinvoice = $conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX;
61 61
 		}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	{
71 71
 		global $langs;
72 72
 		$langs->load("bills");
73
-		return $langs->trans('MarsNumRefModelDesc1',$this->prefixinvoice,$this->prefixreplacement,$this->prefixdeposit,$this->prefixcreditnote);
73
+		return $langs->trans('MarsNumRefModelDesc1', $this->prefixinvoice, $this->prefixreplacement, $this->prefixdeposit, $this->prefixcreditnote);
74 74
 	}
75 75
 
76 76
 	/**
@@ -91,50 +91,50 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	function canBeActivated()
93 93
 	{
94
-		global $langs,$conf,$db;
94
+		global $langs, $conf, $db;
95 95
 
96 96
 		$langs->load("bills");
97 97
 
98 98
 		// Check invoice num
99
-		$fayymm=''; $max='';
99
+		$fayymm = ''; $max = '';
100 100
 
101
-		$posindice=8;
102
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED) as max";	// This is standard SQL
103
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture";
104
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
105
-		$sql.= " AND entity = ".$conf->entity;
101
+		$posindice = 8;
102
+		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED) as max"; // This is standard SQL
103
+		$sql .= " FROM ".MAIN_DB_PREFIX."facture";
104
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
105
+		$sql .= " AND entity = ".$conf->entity;
106 106
 
107
-		$resql=$db->query($sql);
107
+		$resql = $db->query($sql);
108 108
 		if ($resql)
109 109
 		{
110 110
 			$row = $db->fetch_row($resql);
111
-			if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
111
+			if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; }
112 112
 		}
113
-		if ($fayymm && ! preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$fayymm))
113
+		if ($fayymm && !preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i', $fayymm))
114 114
 		{
115 115
 			$langs->load("errors");
116
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
116
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
117 117
 			return false;
118 118
 		}
119 119
 
120 120
 		// Check credit note num
121
-		$fayymm='';
121
+		$fayymm = '';
122 122
 
123
-		$posindice=8;
124
-		$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";	// This is standard SQL
125
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture";
126
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
127
-		$sql.= " AND entity = ".$conf->entity;
123
+		$posindice = 8;
124
+		$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; // This is standard SQL
125
+		$sql .= " FROM ".MAIN_DB_PREFIX."facture";
126
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
127
+		$sql .= " AND entity = ".$conf->entity;
128 128
 
129
-		$resql=$db->query($sql);
129
+		$resql = $db->query($sql);
130 130
 		if ($resql)
131 131
 		{
132 132
 			$row = $db->fetch_row($resql);
133
-			if ($row) { $fayymm = substr($row[0],0,6); $max=$row[0]; }
133
+			if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; }
134 134
 		}
135
-		if ($fayymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$fayymm))
135
+		if ($fayymm && !preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i', $fayymm))
136 136
 		{
137
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
137
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
138 138
 			return false;
139 139
 		}
140 140
 
@@ -149,31 +149,31 @@  discard block
 block discarded – undo
149 149
      * @param   string		$mode       'next' for next value or 'last' for last value
150 150
 	 * @return  string       			Value
151 151
 	 */
152
-	function getNextValue($objsoc, $invoice, $mode='next')
152
+	function getNextValue($objsoc, $invoice, $mode = 'next')
153 153
 	{
154 154
 		global $db;
155 155
 
156
-		$prefix=$this->prefixinvoice;
156
+		$prefix = $this->prefixinvoice;
157 157
 
158
-		if ($invoice->type == 1) $prefix=$this->prefixreplacement;
159
-		else if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
160
-		else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
161
-		else $prefix=$this->prefixinvoice;
158
+		if ($invoice->type == 1) $prefix = $this->prefixreplacement;
159
+		else if ($invoice->type == 2) $prefix = $this->prefixcreditnote;
160
+		else if ($invoice->type == 3) $prefix = $this->prefixdeposit;
161
+		else $prefix = $this->prefixinvoice;
162 162
 
163 163
 		// D'abord on recupere la valeur max
164
-		$posindice=8;
165
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
166
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture";
167
-		$sql.= " WHERE ref LIKE '".$prefix."____-%'";
168
-		$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
164
+		$posindice = 8;
165
+		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
166
+		$sql .= " FROM ".MAIN_DB_PREFIX."facture";
167
+		$sql .= " WHERE ref LIKE '".$prefix."____-%'";
168
+		$sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
169 169
 
170
-		$resql=$db->query($sql);
170
+		$resql = $db->query($sql);
171 171
 		dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
172 172
 		if ($resql)
173 173
 		{
174 174
 			$obj = $db->fetch_object($resql);
175 175
 			if ($obj) $max = intval($obj->max);
176
-			else $max=0;
176
+			else $max = 0;
177 177
 		}
178 178
 		else
179 179
 		{
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
 
183 183
 		if ($mode == 'last')
184 184
 		{
185
-    		if ($max >= (pow(10, 4) - 1)) $num=$max;	// If counter > 9999, we do not format on 4 chars, we take number as it is
186
-    		else $num = sprintf("%04s",$max);
185
+    		if ($max >= (pow(10, 4) - 1)) $num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is
186
+    		else $num = sprintf("%04s", $max);
187 187
 
188
-            $ref='';
188
+            $ref = '';
189 189
             $sql = "SELECT ref as ref";
190
-            $sql.= " FROM ".MAIN_DB_PREFIX."facture";
191
-            $sql.= " WHERE ref LIKE '".$prefix."____-".$num."'";
192
-            $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
190
+            $sql .= " FROM ".MAIN_DB_PREFIX."facture";
191
+            $sql .= " WHERE ref LIKE '".$prefix."____-".$num."'";
192
+            $sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
193 193
 
194 194
             dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
195
-            $resql=$db->query($sql);
195
+            $resql = $db->query($sql);
196 196
             if ($resql)
197 197
             {
198 198
                 $obj = $db->fetch_object($resql);
@@ -204,16 +204,16 @@  discard block
 block discarded – undo
204 204
 		}
205 205
 		else if ($mode == 'next')
206 206
 		{
207
-			$date=$invoice->date;	// This is invoice date (not creation date)
208
-    		$yymm = strftime("%y%m",$date);
207
+			$date = $invoice->date; // This is invoice date (not creation date)
208
+    		$yymm = strftime("%y%m", $date);
209 209
 
210
-    		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
211
-    		else $num = sprintf("%04s",$max+1);
210
+    		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
211
+    		else $num = sprintf("%04s", $max + 1);
212 212
 
213 213
     		dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
214 214
     		return $prefix.$yymm."-".$num;
215 215
 		}
216
-		else dol_print_error('','Bad parameter for getNextValue');
216
+		else dol_print_error('', 'Bad parameter for getNextValue');
217 217
 	}
218 218
 
219 219
 	/**
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
      * @param   string		$mode       	'next' for next value or 'last' for last value
225 225
      * @return  string      				Next free value
226 226
 	 */
227
-	function getNumRef($objsoc,$objforref,$mode='next')
227
+	function getNumRef($objsoc, $objforref, $mode = 'next')
228 228
 	{
229
-		return $this->getNextValue($objsoc,$objforref,$mode);
229
+		return $this->getNextValue($objsoc, $objforref, $mode);
230 230
 	}
231 231
 }
232 232
 
Please login to merge, or discard this patch.